Append only sequence itself to list, no metadata
1
1
Entering edit mode
4.4 years ago

when doing this:

from Bio.Alphabet import generic_protein
from Bio.Seq import Seq

    seq_records = SeqIO.parse(filename, 'fasta', alphabet=generic_protein)
    for record in seq_records:
        total.append(record.seq)
    print(total)

I get the output

[Seq('SRTRMKLDNKTQVGVHDQGVDGMSKQLMPKYTYVLKIILWCVAPYREDARFWMC...HLL', ProteinAlphabet()), Seq('YMQGCKKQRMRRRCNKYHATIIMNIMHDYQDVSWFTIQDSPLQYPNYQPWSCTI...IDM', ProteinAlphabet()), Seq('RLLFDEVVFTITPRYFYQLEDLYFNGLAYQIWARFARAINTLIRYHGCMQQHIK...CGQ', ProteinAlphabet()), Seq('RWPMDQFGCFMAGNWEAYGGSIFFCMHHFFLNYMNISSQTVWLGNTKWVDTYSC...DCA', ProteinAlphabet()), Seq('NFPGLFRDRPQTEDRTVKYLEGIAHLEINDAQVWLWFSDKDTCRRPEYNQYIFV...KVD', ProteinAlphabet()), Seq('TGVFYSWGWFADEVLVDTWQNTSEYEDPPHWDFYVFTCYNVLRNWWGESSWPGL...NHP', ProteinAlphabet()), Seq('HFYIGLFEMLSFEGMTDTIITMTQNVNQSNVTDADYWDKGIARHGSQRWAWYAD...HKN', ProteinAlphabet()), Seq('NMKVGPYWGCYACWQFPYFDNCFEPKNDMILEECDAYHPLLRRRCHWYFFALKP...SMV', ProteinAlphabet()), Seq('VEQWVLTHPVDPVCACDTPHSQQNQEGIANHAGLHAKYNVPFERIYWWCTSYLG...TSN', ProteinAlphabet()),...

Why don't I just get a list of the sequences themself? If I just use print(record.seq) for each record individually I just get the sequences themselves. I want a list of only the sequences.

python biopython fasta • 788 views
ADD COMMENT
2
Entering edit mode
4.4 years ago

Replace total.append(record.seq) with total.append(str(record.seq)).

ADD COMMENT

Login before adding your answer.

Traffic: 2331 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6