[Tutor] Why Doesn't the for loop Increment?
Stephen P. Molnar
s.molnar at sbcglobal.net
Wed Jan 13 11:28:14 EST 2021
On 01/13/2021 10:36 AM, Alan Gauld via Tutor wrote:
> On 13/01/2021 13:39, Stephen P. Molnar wrote:
>
>> At this point in the testing I ran the code line by line (printing out
>> everything that happened) and got an interesting result on the execution
>> of line 9 as well as the remaining lines of code.
> I'm not sure what you mean by that?
> It looks like you typed it into the iPython interpreter?
> Is that correct? If so the first error will cause all
> the subsequent ones since the preceding code is effectively
> not there.
>
>> for ligand in df:
>> File "<ipython-input-5-269745371905>", line 1
>> for ligand in df:
>> ^
>> SyntaxError: unexpected EOF while parsing
> I have no idea why yoiu are getting this but it could be an
> ipython issue. Try running it in the regular pythopn interpreter,
> or better still just as a script with actual print() statements
> in it. When debugging reduce the number of variables to the
> minimum and that means using the basic interpreter with a file.
>
>
>> for i in num:
>> File "<ipython-input-6-e91b9883e5b7>", line 1
>> for i in num:
>> ^
>> SyntaxError: unexpected EOF while parsing
> Again I'm not sure why. Looks like the same problem as above.
>
>> File "<ipython-input-7-6ad0f8600c09>", line 1, in <module>
>> name_in = "{}.{}.log".format(ligand, i)
>>
>> NameError: name 'ligand' is not defined
> This is just because the for line above failed so ligand never
> got created.
>
> Try putting the print statements into the code to print:
> - df - potentially big, but at least a sample of it(use slicing maybe?)
> - ligand - should see each value as the loop iterates - ie. N values
> - name_in - should be different for each iteration - 10xN in total
> - name_s - one per ligand - N values
> - data[0,1] - one per iteration, check against file contents
>
> Show us the output.
>
Thank you for your reply.
Here is the code as edited:
runfile('/home/comp/Apps/EMSKE/PythonSoftware/Test/SARS-CoV-2a/ExtractVinaActivity.py',
wdir='/home/comp/Apps/EMSKE/PythonSoftware/Test/SARS-CoV-2a',
current_namespace=True)
7-Phloroeckol
0 Aloeemodin
1 beta-Sitosterol
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
7-Phloroeckol
0 Aloeemodin
1 beta-Sitosterol
1
7-Phloroeckol.1.log
[[ 1. -9.24815359 0. 0. ]
[ 2. -8.77018617 4.382 11.138 ]
[ 3. -8.71121521 2.155 9.423 ]
[ 4. -8.69308629 5.334 11.567 ]
[ 5. -8.66932661 4.935 11.596 ]
[ 6. -8.43895798 4.145 10.894 ]
[ 7. -8.22467105 2.364 8.799 ]
[ 8. -8.20285633 4.968 9.419 ]
[ 9. -8.19827601 2.291 8.099 ]]
7-Phloroeckol-BE
2
7-Phloroeckol.2.log
[[ 1. -9.17474926 0. 0. ]
[ 2. -8.76125135 4.477 11.177 ]
[ 3. -8.62503496 2.549 9.246 ]
[ 4. -8.51929251 5.321 10.904 ]
[ 5. -8.32529487 6.085 12.541 ]
[ 6. -8.27908207 6.051 12.457 ]
[ 7. -8.23362526 5.207 11.747 ]
[ 8. -8.22360117 5.284 11.396 ]
[ 9. -8.1552274 4.603 11.329 ]]
7-Phloroeckol-BE
3
7-Phloroeckol.3.log
[[ 1. -8.94101715 0. 0. ]
[ 2. -8.14939511 1.608 2.504 ]
[ 3. -8.12218651 2.139 3.186 ]
[ 4. -7.95106339 19.754 23.455 ]
[ 5. -7.94903298 1.795 3.034 ]
[ 6. -7.87858203 2.159 2.52 ]
[ 7. -7.84398855 2.244 3.116 ]
[ 8. -7.83202941 2.66 4.225 ]
[ 9. -7.70585579 27.441 32.52 ]]
7-Phloroeckol-BE
4
7-Phloroeckol.4.log
[[ 1. -9.16256247 0. 0. ]
[ 2. -9.00875388 17.317 22.896 ]
[ 3. -8.76733608 4.486 11.171 ]
[ 4. -8.67364017 5.072 11.659 ]
[ 5. -8.52560114 4.954 11.513 ]
[ 6. -8.31454518 5.833 12.473 ]
[ 7. -8.17565187 4.665 11.309 ]
[ 8. -8.1713394 3.529 10.53 ]
[ 9. -8.14095062 2.225 9.547 ]]
7-Phloroeckol-BE
5
7-Phloroeckol.5.log
[[ 1. -9.17411506 0. 0. ]
[ 2. -8.8841462 5.333 11.643 ]
[ 3. -8.77081732 4.476 11.169 ]
[ 4. -8.62460864 2.552 9.244 ]
[ 5. -8.44033143 5.428 11.144 ]
[ 6. -8.33375966 5.844 12.486 ]
[ 7. -8.30255093 6.09 12.539 ]
[ 8. -8.15969455 4.608 11.328 ]
[ 9. -8.12005716 5.161 11.509 ]]
7-Phloroeckol-BE
6
7-Phloroeckol.6.log
[[ 1. -9.21752813 0. 0. ]
[ 2. -8.77520263 4.762 8.699 ]
[ 3. -8.68887368 4.926 11.579 ]
[ 4. -8.62601653 2.44 9.186 ]
[ 5. -8.59648372 5.352 11.044 ]
[ 6. -8.54099385 4.857 11.467 ]
[ 7. -8.44948087 5.404 11.073 ]
[ 8. -8.35845922 5.595 12.356 ]
[ 9. -8.33891506 2.213 8.436 ]]
7-Phloroeckol-BE
7
7-Phloroeckol.7.log
[[ 1. -9.13303038 0. 0. ]
[ 2. -8.6670965 3.327 6.935 ]
[ 3. -8.6251615 1.807 2.586 ]
[ 4. -8.33583451 3.692 8.01 ]
[ 5. -8.22558254 2.925 3.56 ]
[ 6. -8.11645005 2.539 3.359 ]
[ 7. -8.0962971 3.272 7.159 ]
[ 8. -8.0926511 3.148 6.203 ]
[ 9. -8.08398821 1.936 2.303 ]]
7-Phloroeckol-BE
8
7-Phloroeckol.8.log
[[ 1. -9.18235525 0. 0. ]
[ 2. -8.67150999 3.414 6.913 ]
[ 3. -8.51768291 3.213 11.461 ]
[ 4. -8.46914231 3.628 6.385 ]
[ 5. -8.44830485 3.113 10.84 ]
[ 6. -8.3596531 3.637 7.896 ]
[ 7. -8.27598525 2.886 3.775 ]
[ 8. -8.26197225 1.969 3.09 ]
[ 9. -8.18242741 3.622 6.408 ]]
7-Phloroeckol-BE
9
7-Phloroeckol.9.log
[[ 1. -9.29877154 0. 0. ]
[ 2. -9.04913298 3.136 6.735 ]
[ 3. -9.0223066 2.33 9.597 ]
[ 4. -8.95225114 2.821 5.26 ]
[ 5. -8.80905279 1.812 2.432 ]
[ 6. -8.73525232 2.965 5.919 ]
[ 7. -8.62100389 2.822 5.276 ]
[ 8. -8.5245415 3.515 7.867 ]
[ 9. -8.44223426 2.803 3.531 ]]
7-Phloroeckol-BE
10
7-Phloroeckol.10.log
[[ 1. -9.30057716 0. 0. ]
[ 2. -9.25630706 0.387 2.023 ]
[ 3. -9.22213674 2.752 9.371 ]
[ 4. -8.97532518 3.228 6.707 ]
[ 5. -8.87955892 2.877 5.421 ]
[ 6. -8.616238 3.09 6.056 ]
[ 7. -8.44447012 3.477 7.787 ]
[ 8. -8.30902987 3.338 10.74 ]
[ 9. -8.29915536 3.162 6.544 ]]
7-Phloroeckol-BE
and the output:
runfile('/home/comp/Apps/EMSKE/PythonSoftware/Test/SARS-CoV-2a/ExtractVinaActivity.py',
wdir='/home/comp/Apps/EMSKE/PythonSoftware/Test/SARS-CoV-2a',
current_namespace=True)
7-Phloroeckol
0 Aloeemodin
1 beta-Sitosterol
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
7-Phloroeckol
0 Aloeemodin
1 beta-Sitosterol
1
7-Phloroeckol.1.log
[[ 1. -9.24815359 0. 0. ]
[ 2. -8.77018617 4.382 11.138 ]
[ 3. -8.71121521 2.155 9.423 ]
[ 4. -8.69308629 5.334 11.567 ]
[ 5. -8.66932661 4.935 11.596 ]
[ 6. -8.43895798 4.145 10.894 ]
[ 7. -8.22467105 2.364 8.799 ]
[ 8. -8.20285633 4.968 9.419 ]
[ 9. -8.19827601 2.291 8.099 ]]
7-Phloroeckol-BE
2
7-Phloroeckol.2.log
[[ 1. -9.17474926 0. 0. ]
[ 2. -8.76125135 4.477 11.177 ]
[ 3. -8.62503496 2.549 9.246 ]
[ 4. -8.51929251 5.321 10.904 ]
[ 5. -8.32529487 6.085 12.541 ]
[ 6. -8.27908207 6.051 12.457 ]
[ 7. -8.23362526 5.207 11.747 ]
[ 8. -8.22360117 5.284 11.396 ]
[ 9. -8.1552274 4.603 11.329 ]]
7-Phloroeckol-BE
3
7-Phloroeckol.3.log
[[ 1. -8.94101715 0. 0. ]
[ 2. -8.14939511 1.608 2.504 ]
[ 3. -8.12218651 2.139 3.186 ]
[ 4. -7.95106339 19.754 23.455 ]
[ 5. -7.94903298 1.795 3.034 ]
[ 6. -7.87858203 2.159 2.52 ]
[ 7. -7.84398855 2.244 3.116 ]
[ 8. -7.83202941 2.66 4.225 ]
[ 9. -7.70585579 27.441 32.52 ]]
7-Phloroeckol-BE
4
7-Phloroeckol.4.log
[[ 1. -9.16256247 0. 0. ]
[ 2. -9.00875388 17.317 22.896 ]
[ 3. -8.76733608 4.486 11.171 ]
[ 4. -8.67364017 5.072 11.659 ]
[ 5. -8.52560114 4.954 11.513 ]
[ 6. -8.31454518 5.833 12.473 ]
[ 7. -8.17565187 4.665 11.309 ]
[ 8. -8.1713394 3.529 10.53 ]
[ 9. -8.14095062 2.225 9.547 ]]
7-Phloroeckol-BE
5
7-Phloroeckol.5.log
[[ 1. -9.17411506 0. 0. ]
[ 2. -8.8841462 5.333 11.643 ]
[ 3. -8.77081732 4.476 11.169 ]
[ 4. -8.62460864 2.552 9.244 ]
[ 5. -8.44033143 5.428 11.144 ]
[ 6. -8.33375966 5.844 12.486 ]
[ 7. -8.30255093 6.09 12.539 ]
[ 8. -8.15969455 4.608 11.328 ]
[ 9. -8.12005716 5.161 11.509 ]]
7-Phloroeckol-BE
6
7-Phloroeckol.6.log
[[ 1. -9.21752813 0. 0. ]
[ 2. -8.77520263 4.762 8.699 ]
[ 3. -8.68887368 4.926 11.579 ]
[ 4. -8.62601653 2.44 9.186 ]
[ 5. -8.59648372 5.352 11.044 ]
[ 6. -8.54099385 4.857 11.467 ]
[ 7. -8.44948087 5.404 11.073 ]
[ 8. -8.35845922 5.595 12.356 ]
[ 9. -8.33891506 2.213 8.436 ]]
7-Phloroeckol-BE
7
7-Phloroeckol.7.log
[[ 1. -9.13303038 0. 0. ]
[ 2. -8.6670965 3.327 6.935 ]
[ 3. -8.6251615 1.807 2.586 ]
[ 4. -8.33583451 3.692 8.01 ]
[ 5. -8.22558254 2.925 3.56 ]
[ 6. -8.11645005 2.539 3.359 ]
[ 7. -8.0962971 3.272 7.159 ]
[ 8. -8.0926511 3.148 6.203 ]
[ 9. -8.08398821 1.936 2.303 ]]
7-Phloroeckol-BE
8
7-Phloroeckol.8.log
[[ 1. -9.18235525 0. 0. ]
[ 2. -8.67150999 3.414 6.913 ]
[ 3. -8.51768291 3.213 11.461 ]
[ 4. -8.46914231 3.628 6.385 ]
[ 5. -8.44830485 3.113 10.84 ]
[ 6. -8.3596531 3.637 7.896 ]
[ 7. -8.27598525 2.886 3.775 ]
[ 8. -8.26197225 1.969 3.09 ]
[ 9. -8.18242741 3.622 6.408 ]]
7-Phloroeckol-BE
9
7-Phloroeckol.9.log
[[ 1. -9.29877154 0. 0. ]
[ 2. -9.04913298 3.136 6.735 ]
[ 3. -9.0223066 2.33 9.597 ]
[ 4. -8.95225114 2.821 5.26 ]
[ 5. -8.80905279 1.812 2.432 ]
[ 6. -8.73525232 2.965 5.919 ]
[ 7. -8.62100389 2.822 5.276 ]
[ 8. -8.5245415 3.515 7.867 ]
[ 9. -8.44223426 2.803 3.531 ]]
7-Phloroeckol-BE
10
7-Phloroeckol.10.log
[[ 1. -9.30057716 0. 0. ]
[ 2. -9.25630706 0.387 2.023 ]
[ 3. -9.22213674 2.752 9.371 ]
[ 4. -8.97532518 3.228 6.707 ]
[ 5. -8.87955892 2.877 5.421 ]
[ 6. -8.616238 3.09 6.056 ]
[ 7. -8.44447012 3.477 7.787 ]
[ 8. -8.30902987 3.338 10.74 ]
[ 9. -8.29915536 3.162 6.544 ]]
7-Phloroeckol-BE
finally, 7-Phloroeckol-BE
-9.248153586
-9.174749259
-8.941017151
-9.162562472
-9.17411506
-9.217528128
-9.133030378
-9.182355251
-9.298771543
-9.300577161
There you have it.
--
Stephen P. Molnar, Ph.D.
www.molecular-modeling.net
614.312.7528 (c)
Skype: smolnar1
More information about the Tutor
mailing list