[Tutor] Taking FASTA file as an input in Python 3
Alan Gauld
alan.gauld at yahoo.co.uk
Sun Oct 20 13:49:52 EDT 2019
On 20 October 2019, at 18:36, Mihir Kharate <kharatemihir at gmail.com> wrote:
>
>I found the following code online and tried to print it to see whether the
>first line is overread:
>> DNA_sequence = open ("sequence.fasta" , "r")
>> DNA_sequence.readline()
>> print ("DNA_sequence")
>However, this prints the following statement;
>> <_io.TextIOWrapper name='sequence.fasta' mode='r' encoding='cp1252'>
I assume the quotes around DNA_sequence in the print are an error? If so then the output is As expected since that is the file object. The line has been read but not stored. The next line you read will be the first line of the sequence so you can put it in a variable like this
line = DNA_sequence.readline()
Alan g.
More information about the Tutor
mailing list