View Single Post
Old 09-20-2017, 02:54 PM   #6
Junior Member
Location: USA

Join Date: Sep 2017
Posts: 5

This sort of task is nearly trivial in Python, it is well worth your while to learn it and the important packages such as BioPython which make jokes like seen in this thread all the more funny.

So here is a quick and dirty way. A little thought could make it more elegant and/or generalizable. This would just parse through your multifasta file and spit back the longest sequence.

from Bio import SeqIO

myList = []

for seq_record in SeqIO.parse("test.fa", "fasta"):
    myList.append([, str(seq_record.seq), len(seq_record)])

myList.sort(key=lambda x: x[2])

print("the longest sequence is:")
print(">", myList[-1][0], sep='')
Biocomputronics is offline   Reply With Quote