doubt loading pages
Peter Otten
__peter__ at web.de
Wed Feb 1 07:29:26 EST 2017
José Manuel Suárez Sierra wrote:
> El miércoles, 1 de febrero de 2017, 11:55:11 (UTC+1), José Manuel Suárez
> Sierra escribió:
>> hello everyone,
>> Im trying to make a program that takes an archive from pdb (for instance
>> this link http://www.rcsb.org/pdb/files/fasta.txt?structureIdList=5HXY
>>
>> after reading it I want it to save in a list only this part of the
>> archive:
>>
>> MGSSHHHHHHSSG...
>>
>> I have written this:
>>
>> import urllib2
>>
>>
>> seq=raw_input("Introduce pdb code \n")
>>
>>
>>
>> seq =
>>
urllib2.urlopen("http://www.rcsb.org/pdb/files/fasta.txt?structureIdList="+seq)
>> print seq.read()
>>
>>
>> seq.close()
>>
>>
>> My question is, how do I save this into a python list?
>>
>> Thank you!
>
> What I need is to convert the whole archive into a list, how could I do
> it?
Dunno. Perhaps
$ cat retrieve_fasta2.py
import urllib2
import Bio.SeqIO
seq = raw_input("Introduce pdb code \n")
seq = urllib2.urlopen(
"http://www.rcsb.org/pdb/files/fasta.txt?structureIdList="
+ seq
)
seqs = [record.seq.tostring() for record in Bio.SeqIO.parse(seq, "fasta")]
print seqs
$ python retrieve_fasta2.py
Introduce pdb code
5HXY
['MGS...PRY',
'MGS...PRY',
'MGS...PRY',
'MGS...PRY',
'MGS...PRY',
'MGS...PRY']
More information about the Python-list
mailing list