[BioPython] error with Fasta.Record?
Karin Lagesen
karin.lagesen at labmed.uio.no
Wed Mar 31 11:43:54 EST 2004
I use the following code to read in a fasta file:
genes = quick_FASTA_reader(geneFile)
genelist = {}
rec = Fasta.Record()
iterator = 10001
for entry in genes:
g = ecoligene.EcoliGene(entry)
oname = os.path.join(over300, str(iterator))
if dofiles:
rec.title, rec.sequence = entry
print iterator, rec.title, rec.sequence
ofile = open(oname, 'w')
ofile.write(str(rec))
ofile.close()
I do this with a test file:
adenine:18:38> cat /med/adenine/u2/projects/locator/gard/testfile
>1_dapB_to_carA_29196_29650
gtctataagtgccaaaaattacatgttttgtcttctgtttttgttgttttaatgtaaatt
ttgaccatttggtccacttttttctgctcgtttttatttcatgcaatc
>2_caiT_to_fixA_41932_42366
aattattattaacctcgtggacgcgttaatggctaactcataatgggtattcaataagct
gtattct
>3_caiT_to_fixA_41932_42366
aattattattaacctcgtggacgcgttaatggctaactcataatgggtattcaataagct
gtattctgtgattggtatcacatttttgtttcgggtgaatagagggcgttttttcgttaa
t
>4_caiT_to_fixA_41932_42366
aattattattaacctcgtggacgcgttaatggctaactcataatgggtattcaataagct
gtattctgtgattggtatcacatttttgtttcgggtgaatagagggcgttttttcgttaa
ttttgattaataatcagtttgttatgctctgttgtgagtaaaaaataacatctgac
>5_fruR_to_yabB_89033_89633
gcttcgcacgttggacgtaaaataaacaacgctgatattagccgtaaacatcgggttttt
tacctcggtatgccttgtgac
>6_fruR_to_yabB_89033_89633
aaacaacgctgatattagccgtaaacatcgggttttttacctcggtatgccttgtgac
>7_aroP_to_pdhR_121552_122091
gtttacatcaaagaagtttgaattgttacaaaaagacttccgtcagatcaagaataatgg
tatg
adenine:18:38>
And the files I get look like this:
adenine:18:37> cat /med/adenine/u2/projects/locator/gard/singles/10001
>1_dapB_to_carA_29196_29650
GTCTATAAGTGCCAAAAATTACATGTTTTGTCTTCTGTTTTTGTTGTTTTAATGTAAATT
adenine:18:37> cat /med/adenine/u2/projects/locator/gard/singles/10002
>2_caiT_to_fixA_41932_42366
AATTATTATTAACCTCGTGGACGCGTTAATGGCTAACTCATAATGGGTATTCAATAAGCT
adenine:18:37> cat /med/adenine/u2/projects/locator/gard/singles/10003
>3_caiT_to_fixA_41932_42366
AATTATTATTAACCTCGTGGACGCGTTAATGGCTAACTCATAATGGGTATTCAATAAGCT
GTATTCTGTGATTGGTATCACATTTTTGTTTCGGGTGAATAGAGGGCGTTTTTTCGTTAA
adenine:18:37> cat /med/adenine/u2/projects/locator/gard/singles/10004
>4_caiT_to_fixA_41932_42366
AATTATTATTAACCTCGTGGACGCGTTAATGGCTAACTCATAATGGGTATTCAATAAGCT
GTATTCTGTGATTGGTATCACATTTTTGTTTCGGGTGAATAGAGGGCGTTTTTTCGTTAA
adenine:18:37> cat /med/adenine/u2/projects/locator/gard/singles/10005
>5_fruR_to_yabB_89033_89633
GCTTCGCACGTTGGACGTAAAATAAACAACGCTGATATTAGCCGTAAACATCGGGTTTTT
adenine:18:38> cat /med/adenine/u2/projects/locator/gard/singles/10006
>6_fruR_to_yabB_89033_89633
adenine:18:38> cat /med/adenine/u2/projects/locator/gard/singles/10007
>7_aroP_to_pdhR_121552_122091
GTTTACATCAAAGAAGTTTGAATTGTTACAAAAAGACTTCCGTCAGATCAAGAATAATGG
adenine:18:38>
I try printing the rec object to test if the sequences are read in
correctly, and they are. Thus it seems to be a problem with writing
this object to file.
Is this something I do wrong, or is it something else?
Karin
--
Karin Lagesen, PhD student
karin.lagesen at labmed.uio.no
More information about the BioPython
mailing list