[Tutor] A Multiple Concatenation Problem
Alan Gauld
alan.gauld at yahoo.co.uk
Sat Sep 19 17:19:02 EDT 2020
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.
The problem here is that you are assuming we know a lot more
about your problem than we do. We are software engineers who
are familiar with Python.
We have no idea about ligands. We have no idea about your analysis
nor about what data you are trying to generate/capture. As a
scientist, which I assume is what you are, you should be familiar
with the need for precision. But in your description it is
anything but precise:
> 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.
So you wish to affix a suffix to a ligand. What is a ligand?
What suffix do you wish to attach?
You mention both i and I above - are they the same thing?
> The list begins:
>
> 2-Phloroeckol
> 7-Phloroeckol plus 29 more names
So are we to assume that 2-Phloroeckol is an example of a single ligand?
> The script, so far, is:
>
> filename = 'Ligand.list'
> file = open(filename,mode='r')
> text = file.read()
> file.close()
So now we have a variable called text that contains the full contents
of your file Ligand.list
> for suf in range(1, 11):
> filename = f"{text}.{suf}.log"
And here we generate (but never store) 10 filenames.
Those filenames all have the format:
<the full contents of the file>.<suf>.log
where suf ranges from 1 to 10.
> The result is:
The result of what? You don't print anything or store anything?
The result should be a single filename of the format
<full content of file>.10.log
> a list of the 32 ligands
32? You said there were only 31. Where did the extra one come from?
> a blank line
> .10.log
For a blank line to appear you'd need to be printing something.
But you don't show us any print code. The .10.log suggests that
text is in fact empty.
You need to show us exactly what you want to produce and
from which data. Showing us all the code will help too,
otherwise we are just guessing.
> data = np.genfromtxt(fname, skip_header=28)
> Affinity = (data[0, 1])
Again, that means next to nothing to most of us.
It's just 2 lines of code that could do anything.
> 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.
That's not surprising since you have not yet fully described the
problem at a level that a computer can solve.
--
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