Skip to content

Instantly share code, notes, and snippets.

@hyphaltip
Last active November 28, 2017 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyphaltip/210be02b1dad204eebc256da3f1889f1 to your computer and use it in GitHub Desktop.
Save hyphaltip/210be02b1dad204eebc256da3f1889f1 to your computer and use it in GitHub Desktop.
biopython fasta parser
>tr|E3Q6S8|E3Q6S8_COLGM RNAse P Rpr2/Rpp21/SNM1 subunit domain-containing protein OS=Colletotrichum graminicola (strain M1.001 / M2 / FGSC 10212) GN=GLRG_02386 PE=4 SV=1
MAKPKSESLPNRHAYTRVSYLHQAAAYLATVQSPTSDSTTNSSQPGHAPHAVDHERCLET
NETVARRFVSDIRAVSLKAQIRPSPSLKQMMCKYCDSLLVEGKTCSTTVENASKGGKKPW
ADVMVTKCKTCGNVKRFPVSAPRQKRRPFREQKAVEGQDTTPAVSEMSTGAD
#!/usr/bin/env python3
import sys
from Bio import SeqIO
from Bio.Seq import Seq
filename = "input.fasta"
for seq_record in SeqIO.parse( filename , "fasta"):
print(seq_record.id)
print(repr(seq_record.seq))
print(seq_record.seq)
print(len(seq_record))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment