Skip to content

Instantly share code, notes, and snippets.

@glwinsor
Created May 22, 2018 23:25
Show Gist options
  • Save glwinsor/93d8d437eedefe7673b75f460bdc0ac1 to your computer and use it in GitHub Desktop.
Save glwinsor/93d8d437eedefe7673b75f460bdc0ac1 to your computer and use it in GitHub Desktop.
[read fasta] Reads in a fasta file using biopython and prints the sequence id and sequence string #biopython
from Bio import SeqIO
# read in the fasta file and create seq object. File name is stored in fasta variable and the following "fasta" in quotes means the type of format being input
for seq_record in SeqIO.parse(fasta,"fasta"):
# Prints the sequence ID
print(seq_record.id)
# Prints string representation of the sequence
print(str(seq_record.seq))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment