[Tutor] A Multiple Concatenation Problem
Stephen P. Molnar
s.molnar at sbcglobal.net
Sat Sep 19 17:09:50 EDT 2020
On 09/19/2020 03:40 PM, Mark Lawrence wrote:
> On 19/09/2020 19:52, Stephen P. Molnar wrote:
>> Thanks to help I've received from folks on this list I have gotten to
>> a place where I am well land truly stuck.
>>
>> In a modeling problem that I have, I have a list of 31 ligands to
>> which I wish to attach a suffix . i.log where I runs from 1 to 10.
>>
>> The list begins:
>>
>> 2-Phloroeckol
>>
>> 7-Phloroeckol plus 29 more names
>>
>
> How do you propose adding 10 suffix names to 31 ligand names?
>
>> The script, so far, is:
>>
>>
>> filename = 'Ligand.list'
>> file = open(filename,mode='r')
>> text = file.read()
>> file.close()
>>
>
> You've been informed at least twice that the prefered idiom is to use
> 'with open' so that you don't have to explicitly close the file.
>
>> for suf in range(1, 11):
>> filename = f"{text}.{suf}.log"
>
> You don't do anything with filename here so at the end of the loop you
> have effectively done nothing. Assuming that 'text' is from the
> 'Ligand.list' file do you actually want the entire contents of the
> file used to create your 10 log file names?
>
>>
>> The result is:
>>
>> a list of the 32 ligands
>> a blank line
>> .10.log
>>
> Where is the code that gives this result? Your 'text' name will hold
> the 31 :) ligands but I see nothing that will produce a blank line nor
> the '.10.log' bit.
>
>> Eventually in the script I'll get to a point where I use:
>>
>> data = np.genfromtxt(fname, skip_header=28)
>> Affinity = (data[0, 1])
>>
>> Which is exactly what I need to proceed further with the modeling.
>>
>> However, until I get the correct output from the first portion of the
>> script I can get no further. I'm sure that I have missed something
>> fundamental, but I can't faind any references to a solution to the
>> problem. Quite frankly, I'm more that a bit embarrassed at this point.
>
> I'm still uncertain what 'correct output' is meant to be. Until that
> gets answered we're all stuck so please provide a mapping of input
> data to output data.
>
>>
>> Thanks in advance.
>>
>
>
input output
<ligand> ----> ligand .i.log where i in range(1,11)
--
Stephen P. Molnar, Ph.D.
www.molecular-modeling.net
614.312.7528 (c)
Skype: smolnar1
More information about the Tutor
mailing list