marrink-lab / polyply_1.0

Generate input parameters and coordinates for atomistic and coarse-grained simulations of polymers, ssDNA, and carbohydrates
Apache License 2.0
119 stars 21 forks source link

is it possible to run in Jupyter cell? #326

Closed thangckt closed 1 year ago

thangckt commented 1 year ago

Dear developers,

I wonder how to run polyply in a Jupyter cell? Something like

! polyply -list-lib

Or can you allow a python interface (API) that we can access polyply functions directly using Python syntax?

Thank you so much

fgrunewald commented 1 year ago

Hi @thangckt,

You should be able to do both. You can do a pip install and then access it from within a jupyter or Google Collab notebook. Here is an example for a Jupiter notebook.

All top-level functions are also accessible via API. For example, if you would call polyply gen_params from CLI you can instead also import gen_params from the polyply package directly. Same for gen_coords and gen_seq.

I hope this helps!

thangckt commented 1 year ago

Dear @fgrunewald

Thank you so much for your guidance. I now can run ! polyply -list-lib in google colab. But I failed on my local conda env with python=3.9. May I know which is the highest python that polyply supported?

It is hard to find the document for the polyply API. Does it exist? or can you have a little hint on where I can find it?

I want to output the coordinate and forcefield parameters to be used in LAMMPS. Do you have a manual for such a case?

Thank you so much for your help.

fgrunewald commented 1 year ago

@thangckt I think the '-list-lib' command seems to break in version 3.9 and higher (?). That seems to be an actual bug. Everything else works fine given that polyply is tested up to version 3.11. As the '-list-lib' lives in the top-level script we don't really test it. Perhaps we should.

Currently there is no API doc for polyply. All function contains doc-strings, so the best I can offer at the moment is to look at the function doc-strings or raise an issue / discussion.

Currently, we do not support LAMMPS input/output. However, if you look in the Supplementary Table 2, we list a number of programs that can convert between GROMACS format and LAMMPS format. So you'd probably want to use a converter.

If you fancy coding LAMMPS output/input, I'm more than happy to help with that either.

fgrunewald commented 1 year ago

@thangckt the error indicates that polyply as package was not installed correctly and cannot be found in the jupyter notebook. Depending on how your environments are setup jupyter does not always find executables right away. Which OS are you using? Can you simply run the command in the terminal?

Regarding your other questions / suggestions: We are currently working on having some basic tutorials that can be launched via binder. This might however still take a few weeks to complete. Your documentation page looks cool! However, our current issue is not so much how to launch a documentation page rather than cleaning the doc-strings and writing sensible documentation. Lot's of practical information can be found in our wiki, which is the current substitute for documentation.

thangckt commented 1 year ago

Dear @fgrunewald

I don't think that there is any problem with the installation, I try with this:

import polyply
help(polyply.src)

and output is:

Help on package polyply.src in polyply:

NAME
    polyply.src

DESCRIPTION
    # Copyright 2020 University of Groningen
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #    http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.

PACKAGE CONTENTS
    annotate_ligands
    apply_links
    apply_modifications
    backmap
...
FILE
    [c:\devprogram\miniconda3\envs\py11\lib\site-packages\polyply\src\__init__.py](file:///C:/devprogram/miniconda3/envs/py11/lib/site-packages/polyply/src/__init__.py)

When I try in the terminal, then the error is same as in Jupyter cell, it means:

'polyply' is not recognized as an internal or external command, operable program or batch file.

My OS: Windows 11 Conda env with python 3.9 ( I try with python 3.7 , 3.10 and 3.11. but still fail)

thangckt commented 1 year ago

We are currently working on having some basic tutorials that can be launched via binder

It sounds great. I am looking for this. Please make some tutorials that use Python API to access polyply's functions, not just about how to run terminal commands in a Jupyter cell.

Thank you for your help.

fgrunewald commented 1 year ago

Well this is for sure an installation issue. We seen this before when trying to install things on windows with conda. The reason is that somehow the PATH variables get messed up. More details are discussed here

thangckt commented 1 year ago

Dear @fgrunewald

I think that the problem maybe due to polyply has failed to generate an adequate .exe file When a python package is installed into a conda env, a .exe file should be generated in that env's folder (e.g., miniconda3/envs/py39/Scripts)

But, when I look at such a folder, there is not polyply.exe, figure below is my folder image

You can see a polyply plain text file, but not an execution file polyply.exe. Therefore, polyply can not be recognized as a command.

Please correct me if I am wrong. Thank you so much

fgrunewald commented 1 year ago

@thangckt to be quite honest I haven't used a windows OS in probably 10 years. I think we need to consult someone with more expreience. Calling on @pckroon

pckroon commented 1 year ago

This is an issue with the PATH variable . Try running <FULL-PATH-TO-MINICONDA>/miniconda3/envs/py39/Scripts/polyply -list-lib. If that works it's not a polyply issue, but an issue with your particular setup/installation.

thangckt commented 1 year ago

hi,

As I said, instead of generating an execution file polyply.exe, there is the plain text polyply is generated. You can not run a plain text file.

Try to reproduce the problem on your site if you like. I will stop here and don't want to give any feedback.

Ps: I try on a Linux system, and this problem did not appear.

pckroon commented 1 year ago

You can not run a plain text file.

Of course you can. See also .bat and powershell scripts. And Python scripts of course.

thangckt commented 1 year ago

Of course you can. See also .bat and powershell scripts. And Python scripts of course.

This mean

'polyply' is not recognized as an internal or external command, operable program or batch file.