添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I would like to know if there is there a way to sort a biopython alignment by a feature other then ID? In the biopython cookbook ( http://www.bio-cloud.info/Biopython/en/ch6.html ) there is a way to sort the alignment by ID. Is it possible to sort the sequence records in the alignment by another feature such as description or name?

I am not sure if the alignment object is same as a python iterable array. You can try:

myAligment.sort(key = lambda x : x[column you want to sort by])

If that doesn't work, you can always restructure your alignment into an array of tuples:

newArray = [(x[column you want to sorty by], x) for x in myAlignment]

Then sort by the first element of the tuple which contain data of the column you want to sorty by:

newArray.sort(key = lambda x : x[0])