Hello, I have recently prepared a script for Pymol that works well in evaluating RMSD values for a list of residues from proteins of interest (targetted residues are generated by script embedded commands). However, I wished to implement the script to allow the user to select what residues to analyse. I have tried to use the INPUT function, but it fails to work. Since the code is a bit long, I simplified progressively the scripts to find out the problem. In that way, I ended up with the following two scripts:
"test.py": ``` import Bio.PDB import numpy as np from pymol import cmd import os,glob from LFGA_functions import user_entered List_tot = user_entered() print (List_tot) ``` which calls the simple "user_entered" function that is inside the "My_function.py" script, which generates the residue numbers for the same residue in a hexameric protein: ``` def user_entered(): List_res = [] List_tot = [] a = input("Please indicate the number of residues to analyze/per monomer:") numberRes =int(a) for i in range(numberRes): Res = input("Please provide each residue NUMBER and hit ENTER:") Res1 = int(Res) Res2 = Res1+2000 Res3 = Res1+3000 Res4 = Res1+4000 Res5 = Res1+5000 Res6 = Res1+6000 List_res = (str(Res1),str(Res2),str(Res3),str(Res4),str(Res5),str(Res6)) List_tot.append(List_res) return List_tot ``` The script "test.py" works well when directly executed by Python (3.7.5, which is installed with Pymol 2.3.4,under Windows 7 Prof) from a windows command line. This is an example of what I get: [first input "3" indicates that 3 cases will be treated, followed by the identification number for each residue] However, when the script is run from Pymol GUI, I get the following error message: INPUT():LOST SYS.STDIN Here the error in more detail: File "C:\Program Files\PyMOL\lib\site-packages\pymol\parsing.py", line 527, in execfile exec(co, global_ns, local_ns) File "C:/Program Files/PyMOL/Lib/test.py", line 7, in <module> List_tot = user_entered() File "C:\Program Files\PyMOL\lib\LFGA_functions.py", line 18, in user_entered a = input("Please indicate the number of residues to analyze/per monomer:") Does anybody know what is the problem. Please, take into account that I am a very basic Python user... I profit also to ask something related to this problem... in the original script that works well when run from Pymol (before trying to implement the "input" option), I stored transiently some data (residue name, type and chain) in the form of a Python "set". I need a set, and not a list, because it removes automatically data repeatitions. However, when I try to run the script from Python (with intention to overcome the abovementioned problem with INPUT from Pymol), it stops with a message: name 'close_to_A' not defined. This name corresponds to the set name, which is defined as follows within the script: ``` cmd.select("in_A", "Average and chain A near_to 5 of chain B+C") close_to_A = set() cmd.iterate("(around_A)","close_to_A.add((chain,resi,resn))") ``` How shall I define a set in Python 3 ? Why does it work when run from Pymol ? I would really appreciate if you could help me to solve these two problems. Thank you in advance, Best regards, Luis
_______________________________________________ PyMOL-users mailing list Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net Unsubscribe: https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe