bjtully / BioData

All of my various bioinformatic scripts fit for public consumption (loosely defining "fit")
MIT License
69 stars 37 forks source link

Running a customized KEGG_decoder.py #43

Closed cssulliv closed 4 years ago

cssulliv commented 4 years ago

Hi!

I love the program and the visualizations! I have a question regarding using/running a customized KEGG_decoder.py. I created a copy of the KEGG_decoder.py from my /anaconda3/envs/KEGGDecoder/lib/python3.6/site-packages/KEGGDecoder directory and added KO terms associated with the pentose phosphate pathway and methyltransferases associated in the Wood-Ljungdahl pathway. I then ran python KEGG_decoder_cs_copy.py --input GhostKO_JGI_KEGGDecoder_copy.txt --output GhostKO_JGI_KEGGDecoder_heatmap -v interactive in that same directory and got a ModuleNotFoundError: No module named 'Plotly_viz.py'; 'Plotly_viz' is not a package error. It repeats a similar error when I use -v static

I am not an experienced python coder but I would like to be able to use the customized KEGG_decoder_cs_copy.py. My question is how can I tweak the script so that it can "call" plotly_viz, make_tanglegram and hClust_euclidean.

I have attached the main directory as a zip file, which includes the KEGG_decoder_cs_copy.py.

KEGGDecoder.zip

Mahalo nui loa for any suggestions!

bjtully commented 4 years ago

Plotly_viz.py is needed to create the visualizations from KEGG-decoder. It stands separate from KEGG-Decoder to keep the two elements easy to modify separately. All you need is to have Plotly_viz.py in the same directory as your KEGG-decoder modifications.

cssulliv commented 4 years ago

Hi!

The .py files are all in the same directory. I re-ran the script again but this time got this error but it did generate the heatmap file but no .html file.

File "KEGG_decoder_cs_copy.py", line 1620, in <module>
    main()
  File "KEGG_decoder_cs_copy.py", line 1609, in main
    from .Plotly_viz import plotly_viz
ModuleNotFoundError: No module named '__main__.Plotly_viz'; '__main__' is not a package

I then deleted the following lines and did not get any error messages but that did not produce any files.

if __name__ == "__main__":
    main()

Would I need to edit that last bit of code and if so how can I implement those changes so that it can generate the .svg, .html files?

bjtully commented 4 years ago

Definitely do not delete if __name__ == "__main__":

Because KEGG-Decoder is designed to pull commands from the other scripts in your install directory the scripts have a '.' in front of them. For all the custom scripts you need to remove the '.' So from .KEGG_clustering import hClust_euclidean would be from KEGG_clustering import hClust_euclidean

Rinse and repeat for .Plotly_viz & .MakeTanglegram

cssulliv commented 4 years ago

Hi,

Thank you for clarifying. I kept the if __name__ == "__main__":. I removed the '.' in the custom script (Plotly_viz.py) and in the KEGG-decoder.py and re-ran KEGG-decoder.py with '-v interactive' and it works so long as I activate the KEGG-Decoder conda environment!

Thank you!