[Tutor] Why Doesn't the for loop Increment?
Alan Gauld
alan.gauld at yahoo.co.uk
Thu Jan 14 16:28:03 EST 2021
On 14/01/2021 20:33, Stephen P. Molnar wrote:
>>> NUM = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> LIGAND = 7-Phloroeckol
>> While you "think" this is the first of three data items, as far as
>> pandas is concerned, this is the LABEL of the first (of only one) "data
>> series", and you are never accessing the data series content. And since
>> there is only one data series in the frame, the loop exits.
>>
> Upon refection, I think that you are absolutely correct. That would
> explain why there was no incrementation. In actuality there are going to
> be quite a few more ligands, the first round that I am contemplating
> will be 298, to be exact. Now, if you consider that I initially will be
> doing ten repetitions of the docking of each ligand to seven different
> proteins that would be on the order of 20860 sets of data to be
> processed. Not a particularly unwieldy number as this sort of study is
> concerned.
>
> The question, and my problem, then becomes how do I get a list of
> ligands into the script to extract the one number from each file?
> A solution would be greatly appreciated.
It depends on the file format but if it is just a list of ligand names
then just treat it as a refgular text file:
with open(filename) as ligand_file:
for ligand in ligand_file:
for num in range(1,11):
# code as before
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list