Git Product home page Git Product logo

modelseedpy's People

Contributors

cshenry avatar cvoleti avatar dmlb2000 avatar freiburgermsu avatar fxe avatar jjacobson95 avatar jplfaria avatar nitkiew2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modelseedpy's Issues

pathways in modelseed

Hi there.

I was wondering if there's any way one could get the model's reactions that belong to a certain pathway as in the following screenshot from the web interface:

image

Is there a way for example to get the 22 reactions of the "Bisphenol degradation" pathway?

Thanks a lot.

Bugs

Hello!

I merged the upstream MSpy into my fork and was reacquainted with some bugs that I corrected in my fork. A few of them here:

  1. Self is already passed as an argument (here and here) by calling the function from the Class object, so explicitly listing the argument (when the function does not accept any other argument) will cause an error.
  2. The model. is missing from these calls, where the Class object does not directly store the metabolites.
  3. I believe that rxn.id is a string here, and not a function, so this would throw an error.
  4. There are many instances of editing an objective (e.g. here and here) after it has been assigned to a model, which I believe does not track the changes to the model and therefore deviates from the author's intentions of editing the model objective.
  5. The group variable in this line is never defined. I think that the author intended to extract the matched regex content in m, so group should be replaced with m.

I will share more bugs through this medium, since it seems to be more amenable than a PR with my whole fork.

Thank you :)
Andrew

Using genomes annotated with PATRIC

Is it possible to use genomes annotated in PATRIC to build models using ModelSEEDpy instead of the web server?
Currently, when I try :

import modelseedpy
from modelseedpy import MSBuilder, MSGenome
from modelseedpy.helpers import get_template
from modelseedpy.core.mstemplate import MSTemplateBuilder
from cobra.io import write_sbml_model
import pandas as pd

#load dataframe with info on genomes
df_genomes = pd.read_csv('best_per_genus.tsv', sep='\t')
gram_pos_phyla = ['Firmicutes', 'Actinobacteria']

for patric_id, genome_path, phylum in zip(df_genomes['genome_id'], df_genomes['path_2_faa'], df_genomes['phylum']):
  #Select template based on phylum
  if(phylum in gram_pos_phyla):
    template_name = 'template_gram_pos'
  else:
    template_name = 'template_gram_neg'
  print(patric_id)
  #Load the genome as a fasta file (.faa)
    genome = MSGenome.from_fasta(genome_path, split=' ')
    print(len(genome.features))
  # Build template
    template = MSTemplateBuilder.from_dict(get_template(template_name)).build()
  # Build model
    model = MSBuilder.build_metabolic_model(str(patric_id), genome, template=template, allow_all_non_grp_reactions=False, annotate_with_rast=True, gapfill_model=False)
    print(len(model.reactions))
  # Save model
     write_sbml_model(model, folder+'/'+str(patric_id)+'.sbml') 

I get models with significantly different reactions then the ones I get in the webserver.

Gapfilling error

Hello!

The Gapfilling function in MSBuilder returns the original, ungapfilled, model instead of the gapfilled model. This seems counter-intuitive and to be a bug instead of a feature. How is the user expected to acquire the gapfilled model from a static method unless it is returned??

dependencies versions

Hi there.

Could you please add in the requirements file the versions of the dependencies?
I am running on some issues that come up from example a conflict with scikit-learn.

Here is how it behaves:

genome_class = genome_classifier.classify(genome)

returned the following error:


---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In [4], line 2
      1 from modelseedpy.helpers import get_classifier
----> 2 genome_classifier = get_classifier('knn_filter')
      3 genome_class = genome_classifier.classify(genome)
      4 print(genome_class)

File ~/.local/lib/python3.10/site-packages/modelseedpy/helpers.py:46, in get_classifier(classifier_id)
     44 print(cls_features)
     45 with open(cls_pickle, "rb") as fh:
---> 46     model_filter = pickle.load(fh)
     47 with open(cls_features, "r") as fh:
     48     features = json.load(fh)

ModuleNotFoundError: No module named 'sklearn.neighbors._dist_metrics'

When I downgraded my scikit-learn to the 0.24.0 version it worked fine.

However, I then tried to run

genome_class = genome_classifier.classify(genome)

and I got this:

genome_class = genome_classifier.classify(genome)
Traceback (most recent call last):
  File "/home/luna.kuleuven.be/u0156635/.conda/envs/modelseed/lib/python3.9/site-packages/modelseedpy/ml/predict_phenotype.py", line 94, in create_indicator_matrix
    indicators[np.array(matching_index)] = 1
IndexError: arrays used as indices must be of integer (or boolean) type

I am not sure if the last error is due to a version conflict but i guess something is not installed as it should .

Thanks !

KBaseMediaPkg class missing 'mediacompounds' attribute

Hello,
I ran into the following error when attempting to run the 'build_metabolic_model.ipynb' example notebook. Do you have any suggestions for fixing this issue? I didn't make any edits to your example notebook. I was able to get the function to run by commenting out lines 47-61 in 'kbasemediapkg.py', however the model output has far more reactions and metabolites than the one shown in the example output.
Thanks in advance for any help you can provide!

AttributeError Traceback (most recent call last)
Input In [6], in
----> 1 model = MSBuilder.build_metabolic_model('ecoli.core', genome, template, None, allow_all_non_grp_reactions=True, annotate_with_rast=True)
2 model

File ~/anaconda3/envs/genre/lib/python3.10/site-packages/ModelSEEDpy-0.2.2-py3.10.egg/modelseedpy/core/msbuilder.py:616, in MSBuilder.build_metabolic_model(model_id, genome, gapfill_media, template, index, allow_all_non_grp_reactions, annotate_with_rast, gapfill_model)
614 # Gapfilling model
615 if gapfill_model:
--> 616 model = MSBuilder.gapfill_model(model, 'bio1', builder.template, gapfill_media)
617 return model

File ~/anaconda3/envs/genre/lib/python3.10/site-packages/ModelSEEDpy-0.2.2-py3.10.egg/modelseedpy/core/msbuilder.py:630, in MSBuilder.gapfill_model(original_mdl, target_reaction, template, media)
623 pkgmgr = MSPackageManager.get_pkg_mgr(model)
624 pkgmgr.getpkg("GapfillingPkg").build_package({
625 "default_gapfill_templates": [template],
626 "gapfill_all_indecies_with_default_templates": 1,
627 "minimum_obj": 0.01,
628 "set_objective": 1
629 })
--> 630 pkgmgr.getpkg("KBaseMediaPkg").build_package(media)
631 #with open('Gapfilling.lp', 'w') as out:
632 # out.write(str(model.solver))
633 sol = model.optimize()

File ~/anaconda3/envs/genre/lib/python3.10/site-packages/ModelSEEDpy-0.2.2-py3.10.egg/modelseedpy/fbapkg/kbasemediapkg.py:49, in KBaseMediaPkg.build_package(self, media_or_parameters, default_uptake, default_excretion)
45 reaction.update_variable_bounds() # FIXME: this seems unnecessary
47 if self.parameters["media"]:
48 # Searching for media compounds in model
---> 49 for compound in self.parameters["media"].mediacompounds:
50 mdlcpds = self.find_model_compounds(compound.id)
51 for mdlcpd in mdlcpds:

AttributeError: 'NewModelTemplate' object has no attribute 'mediacompounds'

reproducing a reconstruction from the ModelSEED platform

Hi!

Using the attached .faa file and through the ModelSEED platform I built the also attached .sbml growing model.
I am now trying to reproduce that through the CLI and here is what I have done so far:

# modelseedpy
from modelseedpy import KBaseMediaPkg
from modelseedpy import MSBuilder, MSGenome

# cobrakbase 
import cobrakbase

genome = MSGenome.from_fasta('data/genomes/s_infantis/s_inf_all_contigs_default.faa')

kbase_api    = cobrakbase.KBaseAPI()
kb_template = kbase_api.get_from_ws("GramNegModelTemplateV4","NewKBaseModelTemplates")

model = MSBuilder.build_metabolic_model('salmonella infantis', genome, template = kb_template, allow_all_non_grp_reactions = True)

#Pulling a KBase media to specify an environment for gapfilling
media = kbase_api.get_from_ws("Complete","KBaseMedia")

#Gapfilling the model in the specified media
model = MSBuilder.gapfill_model(model, "bio1", kb_template, media)

#Applying the same media to the resulting model
kmp = KBaseMediaPkg(model)
kmp.build_package(media)

However, my media is just empty and therefore, my new model is not growing.

print(media.data)
{'source_id': 'Complete',
 'isMinimal': 0,
 'name': 'Complete',
 'type': 'unknown',
 'id': 'kb|media.626',
 'mediacompounds': [],
 'isDefined': 1,
 '__VERSION__': 1,
 'exclude_dict': set(),
 'data_keys': {'source_id': str,
  'isMinimal': int,
  'name': str,
  'type': str,
  'id': str,
  'mediacompounds': list,
  'isDefined': int,
  '__VERSION__': int},
 'info': <cobrakbase.kbase_object_info.KBaseObjectInfo at 0x7f210d4ab220>,
 'data': {...},
 'provenance': [{'time': '2013-06-20T17:04:46+0000',
   'epoch': 1371747886000,
   'service': 'KBaseFBAModeling',
   'service_ver': '0',
   'method': 'load_media_from_bio',
   'method_params': [],
   'input_ws_objects': [],
   'resolved_ws_objects': [],
   'intermediate_incoming': [],
   'intermediate_outgoing': [],
   'external_data': [],
   'subactions': [],
   'custom': {}}],
 'path': ['262/34/1'],
 'creator': 'chenry',
 'orig_wsid': None,
 'created': '2014-01-18T09:09:51+0000',
 'epoch': 1390036191265,
 'refs': [],
 'copied': None,
 'copy_source_inaccessible': 0}

I would like to ask you:

  • is my approach valid in order to reproduce the platform workflow or am i missing something?
  • how could I use the complete medium like the default case on the modelseed web platform?

Thank you very much for your time and help!

p.s. I have a .txt suffix on the files so GitHub allows them as attached

s_inf_all_contigs_default.faa.txt

s_inf_from_modelseed.sbml.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.