0

I have a python code backward.py that reads multiple inputs and options and then output one file. What this script does is turning a coarse grained structure(in gro file) in molecular dynamics simulation to an all atom structure using some sort of mapping algorithm.

backward.py: https://github.com/Tsjerk/MartiniTools/blob/master/backward.py

gro file format is like:

14839
    1MET     BB    1   4.173   3.275   1.812 -0.0069 -0.3280 -0.2983
    1MET    SC1    2   4.360   3.461   1.580  0.0581 -0.0052 -0.4273
    2ALA     BB    3   4.285   3.091   1.885 -0.1281 -0.1166 -0.0674
    3SER     BB    4   4.514   2.881   1.673 -0.2956 -0.3708  0.0155
    3SER    SC1    5   4.536   3.017   1.449 -0.1433 -0.1251 -0.0305
    4GLU     BB    6   4.862   2.935   1.836  0.0310 -0.1089  0.0899
    4GLU    SC1    7   5.152   2.907   1.567 -0.0071 -0.1857 -0.1227

To run it, the command looks like:

python backward.py -f PRO-PHE-PHE_unwrapped3.gro -o PRO-PHE-PHE_aa.gro -from martini  -to charmm36 -p prophephe_aa.top

However, it can only deal with one frame(one structure) but not a trajectory that consists of many time continuous frames. Now, I write another python code that splits a trajectory into those individual frames and calls the backward.py to transfer them to atomistic structures and then merge them back into one file as a trjectory. I need to use backward.py in this script. But, I found that I cannot directly use import backward in my code as it gives error without including those options.

In the second python script, What should be the proper way to use the backward.py in the same manner as it is used alone.

Sean
  • 11
  • 2
  • Does this answer your question? [python calling a module that uses argparser](https://stackoverflow.com/questions/44734858/python-calling-a-module-that-uses-argparser) – Tomerikoo Feb 23 '21 at 09:02
  • 1
    `backward.py` seems to be a standalone script. It requires those options to function. It may not be intended to be used as a module. Impossible to tell without knowing what it is though. – rdas Feb 23 '21 at 09:02
  • If you can post `backward.py` that will help, as you probably could swap the argument reading into a `open("file.txt", "r")` – PythonSnek Feb 23 '21 at 12:16
  • Have you tried putting the main code of backward.py in a dedicate function? I'm still a beginner with python, but maybe something like this could give you an idea https://gist.github.com/JackLilhammers/45cef2ff245c42b5053d3ccb6538dc28 – Jack Lilhammers Feb 23 '21 at 12:31

0 Answers0