Conversation
|
@djinnome can this be merged? |
I would like @tiekneeshrimp to go through it and clean up the code first. I don't think it will run as is. |
| from micom import load_pickle | ||
| from micom.viz import plot_tradeoff, plot_exchanges_per_sample, plot_growth | ||
|
|
||
| com1 = load_pickle("/Users/rodr579/Library/CloudStorage/OneDrive-PNNL/venv/CarbStor_Community/One.pickle") |
There was a problem hiding this comment.
Convert absolute path names to relative pathnames
| # In[4]: | ||
|
|
||
|
|
||
| com2 = load_pickle("/Users/rodr579/Library/CloudStorage/OneDrive-PNNL/venv/CarbStor_Community_NoCurtobacterium/One.pickle") |
There was a problem hiding this comment.
Convert absolute pathnames to relative pathnames
Thought this would be solved withhh issue 15? Maybe it can be merged? |
Changed to relative (github) filepath
There was a problem hiding this comment.
These paths are close, but could benefit from slight tweaking. The way they are written, it could break if run on different systems. Let's add in a pathlib Path to make sure that everyone who runs this will be able to get the data.
First we should add:
from pathlib import Pathwith the top imports.
Then we can set a few variables:
HERE = Path(__file__).parent.resolve()
ROOT = HERE.parent.resolve()
COM_MODEL = HERE.joinpath("One.pickle")
NO_CURTO = ROOT.joinpath("CarbStor_Community_NoCurtobacterium/One.pickle")These will resolve to PosixPaths that we can leverage for the load_pickle methods.
com1 = load_pickle(COM_MODEL)
com2 = load_pickle(NO_CURTO)this will make it so we don't have to guess at the folder structure of people using the code, it will just get there for us.
| from micom.viz import plot_tradeoff, plot_exchanges_per_sample, plot_growth | ||
|
|
||
| com1 = load_pickle("/Users/rodr579/Library/CloudStorage/OneDrive-PNNL/venv/CarbStor_Community/One.pickle") | ||
| com1 = load_pickle("/CarbStor_Community_Models/One.pickle") |
There was a problem hiding this comment.
When you put a / in front of the path, it makes it absolute. I think since the code is already in the CarbStor_Community_Models directory. you can just load_pickle("CarbStor_Community/One.pickle")
| # In[4]: | ||
|
|
||
|
|
||
| com2 = load_pickle("CarbStor_Community_NoCurtobacterium/One.pickle") |
|
The last thing this needs @tiekneeshrimp is to remove a few things that are normally captured in a There are 2 things that are typically not committed to the repo.
Let's remove those for this PR. If you look in the Files Changed tab on this PR you can see where those things are located. I think the |
There was a problem hiding this comment.
This entire directory should be removed. Just a rm -rf __pycache__ while in the utils directory
|
@mcnaughtonadm resolved! |
|
Alright great, I pulled the branch and tried to run the code, there are a few things I noticed that are throwing errors and some formatting things that can be fixed to make this a full script! I'll try to comment on each part of the file that needs some modification. |
| #!/usr/bin/env python | ||
| # coding: utf-8 | ||
|
|
||
| # In[ ]: |
There was a problem hiding this comment.
This # In[ ]: should be removed throughout the script, they are artifacts from saving a jupyter notebook to python script and are just unnecessary clutter now.
| import pandas as pd | ||
| from cobra.io import read_sbml_model | ||
| from pathlib import Path | ||
|
|
||
| from micom import Community | ||
| from micom.workflows import build, grow, tradeoff, fix_medium,build_database | ||
| from micom import load_pickle | ||
| from micom.viz import plot_tradeoff, plot_exchanges_per_sample, plot_growth |
There was a problem hiding this comment.
We actually only need 2 of these import statements:
from pathlib import Path
from micom import load_picklethe rest are unused in this script.
| #set variables for importing data | ||
| HERE = Path(__file__).parent.resolve() | ||
| ROOT = HERE.parent.resolve() | ||
| COM_MODEL = HERE.joinpath("One.pickle") |
There was a problem hiding this comment.
I think this needs an additional folder:
COM_MODEL = HERE.joinpath("CarbStor_Community/One.pickle"There was a problem hiding this comment.
Also I think I messed you up with giving the ROOT, I wasn't sure where that file was being run from. Try something like this:
# set variables for importing data
HERE = Path(__file__).parent.resolve()
COM_MODEL = HERE.joinpath("Carbstor_Community/One.pickle")
NO_CURTO = HERE.joinpath("CarbStor_Community_NoCurtobacterium/One.pickle")| #load communities and define parameters | ||
| com1 = load_pickle(COM_MODEL) | ||
| result1 = com1.optimize(fluxes=True, pfba=True) | ||
| #result1 | ||
| result1.summary() | ||
|
|
||
|
|
||
| # In[4]: | ||
|
|
||
| com2 = load_pickle(NO_CURTO) | ||
| result2 = com2.optimize(fluxes=True, pfba=True) | ||
| #result2 | ||
| result2.summary() | ||
|
|
||
|
|
||
| # In[ ]: |
There was a problem hiding this comment.
2 things here. First let's wrap this code into a main() method:
def main():
com1 = load_pickle(COM_MODEL)
... the rest of the code on same indentation level ...
result2.summary()then adding at the bottom of the file:
if __name__ == "__main__":
main()Second thing is that result1.summary() and result2.summary() don't actually work outside of a jupyter notebook with micom for some weird cobrapy integration reason. Therefore we need to do something else here as an output to this script.
One thing I think we can do is return the community members. This can be done by replacing those summary() lines with print(result1.members) and the same for result2.
…a imports, redefined variables
There was a problem hiding this comment.
Can we do the same pathlib treatment for the paths present in this file?
djinnome
left a comment
There was a problem hiding this comment.
looks good to me. Tests pass according to @tiekneeshrimp
|
@tiekneeshrimp will move directories:
|
… Metabolites_Data_Files to ./testing
… in Test_ and changed name of Program_to_Test (now Metabolite_Data)
Uploading 6 files related to the creation of the Exchange Metabolomics Data File used at AgileBioCyc to create a SmartTable and omics Dashboard analysis for each 5 organisms of the CarbStor project.