Reputation: 111
I want to put a list of sequences in an csv, however everything is returned as "seq('DNA sequence')". How do I print just the NT sequence.
primers = [Seq("CCGCGTTACATAGCATCGTACGCGTACG"),Seq("TGTTTGGTCCTGCCGGCCCTGCCTCAGCCGGATCCATGGTGAGCAAGGG")] # list is made in another function
print(primers)# Prints as "[Seq('CCGCGTTACATAGCATCGTACGCGTACG'), Seq('TGTTTGGTCCTGCCGGCCCTGCCTCAGCCGGATCCATGGTGAGCAAGGG')]"
Upvotes: 0
Views: 611
Reputation: 41198
Printing a list of Seq()
objects returns the repr()
representation rather than the str()
representation. The solution is to convert to str()
or print each Seq()
object individually:
>>> from Bio.Seq import Seq
>>> s = Seq("CCG")
>>> print(s)
CCG
>>> print([s])
[Seq('CCG')]
>>> print(repr(s))
Seq('CCG')
>>> print(repr(str(s)))
'CCG'
>>> print([str(s)])
['CCG']
>>> print(list(map(str,[s, s])))
['CCG', 'CCG']
Upvotes: 4