Re: [Tutor] Search for Text in File

2019-08-15 Thread Alan Gauld via Tutor
On 15/08/2019 15:10, Stephen P. Molnar wrote:
> I need to find a phrase in i text file in order to read a unique text 
> string into a python3 application.
> 
> I have become stuck and Google has not been of any use.

I'm sorry but there is so much wrong here it is difficult
to know where to begin.


> #!/usr/bin/env python3
> # -*- coding: utf-8 -*-
> #
> #  Extract.Data.py
> 
> import re

You don't need re since you are not using any regular expressions.

> name = input("Enter Molecule Name: ")
> 
> name_in = name+'_apo-1acl.dlg'

This creates a string called name_in.


> re.search("RMSD TABLE",name_in())

And here you search for the string(not regular expression)
"RMSD TABLE" in the return value from name_in()
But name_in is a string, you cannot call a string.

>>> "foo"()
Traceback (most recent call last):
  File "", line 1, in 
"foo"()
TypeError: 'str' object is not callable

> and here is the portion of the text file (Acetyl_apo-1acl.dlg) 
> containing the information:
> 

> Number of multi-member conformational clusters found = 4, out of 20 runs.
> 
>  RMSD TABLE
>  __

And this is the only line containing your string so, even if
your code worked, this is the only line you would locate.
It doesn't look very useful...

> Everything that I have tried returns 'TypeError: 'str' object is not 
> callable'.

See my comments above.


-- 
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


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Search for Text in File

2019-08-15 Thread Peter Otten
Stephen P. Molnar wrote:

> I need to find a phrase in i text file in order to read a unique text
> string into a python3 application.
> 
> I have become stuck and Google has not been of any use.
> 
> Here is my attempt:

> import re
> 
> name = input("Enter Molecule Name: ")
> 
> name_in = name+'_apo-1acl.dlg'
> re.search("RMSD TABLE",name_in())

Stephen, you cannot throw random snippets of Python-lookalike code at a 
problem and expect it to work. When I wrote

> Work your way through a Python tutorial to pick up the basics

some two years ago I really meant it. If you can't be bothered have a look 
at preshrunk tools like grep, or find someone to write the code for you.
 
> Thanks in advance.

You're welcome.


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Search for Text in File

2019-08-15 Thread David Rock

> On Aug 15, 2019, at 09:10, Stephen P. Molnar  wrote:
> 
> 
> Everything that I have tried returns 'TypeError: 'str' object is not 
> callable’.

As a rule, posting actual output is better than paraphrasing.

We can’t tell what you have tried, or what the expected result actually is.  We 
also don’t know the context in which the TypeError occurs.
Please paste the actual text session showing your interaction with the program 
_and_ the full traceback so we can see what the TypeError is related to in the 
code.

— 
David Rock
da...@graniteweb.com




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Search for Text in File

2019-08-15 Thread Stephen P. Molnar
I need to find a phrase in i text file in order to read a unique text 
string into a python3 application.


I have become stuck and Google has not been of any use.

Here is my attempt:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#  Extract.Data.py
#
#
#
#  "


import re

name = input("Enter Molecule Name: ")

name_in = name+'_apo-1acl.dlg'
re.search("RMSD TABLE",name_in())

and here is the portion of the text file (Acetyl_apo-1acl.dlg) 
containing the information:




 |   | |   | |
Clus | Lowest| Run | Mean  | Num | Histogram
-ter | Binding   | | Binding   | in  |
Rank | Energy| | Energy| Clus|510   15   20 25   30   35
_|___|_|___|_|:|:|:|:___
   1 | -4.39 |  15 | -4.29 |   2 |##
   2 | -4.38 |  13 | -4.27 |   6 |##
   3 | -4.29 |  11 | -4.15 |  10 |##
   4 | -3.90 |   9 | -3.90 |   2 |##
_|___|_|___|_|__


Number of multi-member conformational clusters found = 4, out of 20 runs.

RMSD TABLE
__

_
 |  |  |   | | |
Rank | Sub- | Run  | Binding   | Cluster | Reference   | Grep
 | Rank |  | Energy| RMSD| RMSD| Pattern
_|__|__|___|_|_|___
   1  1 15   -4.39  0.00 92.25   RANKING
   1  2 17   -4.19  0.99 92.15   RANKING
   2  1 13   -4.38  0.00 93.14   RANKING
   2  2  6   -4.37  1.21 92.80   RANKING
   2  3 18   -4.35  0.87 93.26   RANKING
   2  4  5   -4.33  1.23 92.85   RANKING
   2  5  3   -4.17  1.17 93.40   RANKING
   2  6  7   -3.99  1.33 92.98   RANKING
   3  1 11   -4.29  0.00 91.37   RANKING
   3  2 19   -4.29  0.31 91.27   RANKING
   3  3 16   -4.25  1.08 91.14   RANKING
   3  4 10   -4.25  0.86 91.13   RANKING
   3  5  1   -4.13  0.94 91.83   RANKING
   3  6 20   -4.11  1.03 91.89   RANKING
   3  7 12   -4.11  0.60 91.28   RANKING
   3  8  2   -4.10  0.86 91.56   RANKING
   3  9  8   -4.09  0.73 91.52   RANKING
   3 10  4   -3.89  1.24 91.91   RANKING
   4  1  9   -3.90  0.00 95.00   RANKING
   4  2 14   -3.90  0.92 94.92   RANKING
___



INFORMATION ENTROPY ANALYSIS FOR THIS CLUSTERING



Information entropy for this clustering = 0.39  (rmstol = 2.00 Angstrom)

Everything that I have tried returns 'TypeError: 'str' object is not 
callable'.


Assistance will be much appreciated.

Thanks in advance.

--
Stephen P. Molnar, Ph.D.Life is a fuzzy set
http://www.Molecular-Modeling.net   Multivariate and stochastic
614.312.7528 (c)
Skype:  smolnar1

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor