Entering edit mode
3.0 years ago
trejomarco6
•
0
from Bio import Entrez
from Bio import SeqIO
Entrez.email = "trejomarco@test.edu"
file = open("humanSeq.txt")
sequences = open("humanSeq.fasta", "w")
l=[]
for line in file:
fields=line.split()
l.append(fields[0])
try:
handle = Entrez.efetch(db="nucleotide", id=l, rettype="fasta", retmode="text")
fasta_str = handle.read()
handle.close()
sequences.write(fasta_str)
except:
continue
sequences.close()
file.close()
So in my fasta file I get the id for example: AY195771.1 Homo sapiens haplotype As2A mitochondrion, complete genome but I want to only have AY195771.1 and not the rest. Can anyone tell me to remove the extra information?
This issue has been addressed multiple times on the forum. Please search the forum for "fasta header" and you'll get a bunch of leads.