Ejemplo n.º 1
0
    def __define_instance_variables(self):
        """
        Define instance variables

        :return:
        """

        self.__universal_model = Model("universal_model")
        self.__swapped = []

        self.__compounds_ontology = CompoundsDBAccessor()

        self.__compoundsAnnotationConfigs = file_utilities.read_conf_file(
            COMPOUNDS_ANNOTATION_CONFIGS_PATH)
        self.__reactionsAnnotationConfigs = file_utilities.read_conf_file(
            REACTIONS_ANNOTATION_CONFIGS_PATH)

        self.__compoundsIdConverter = CompoundsIDConverter()

        self.__compounds_revisor = CompoundsRevisor(self.model,
                                                    self.__universal_model)

        biocyc.set_organism("meta")

        self.mapper = ModelMapper(self.model,
                                  self.__compoundsAnnotationConfigs,
                                  self.__compoundsIdConverter)

        self.__compounds_revisor.set_model_mapper(self.mapper)

        self.granulator = Granulator(self.model, self.mapper,
                                     self.__database_format,
                                     self.__compoundsIdConverter,
                                     self.__compoundsAnnotationConfigs)
Ejemplo n.º 2
0
    def __define_instance_variables(self):
        """
        Method to define a set of instance values

        :return:
        """

        self.__swapped = []
        self.lineage = []

        # self.__compounds_ontology = CompoundsDBAccessor()

        self.__compoundsAnnotationConfigs = file_utilities.read_conf_file(
            COMPOUNDS_ANNOTATION_CONFIGS_PATH)

        self.__reactionsAnnotationConfigs = file_utilities.read_conf_file(
            REACTIONS_ANNOTATION_CONFIGS_PATH)

        self.__compoundsAnnotationConfigs = file_utilities.read_conf_file(
            COMPOUNDS_ANNOTATION_CONFIGS_PATH)
        self.__reactionsAnnotationConfigs = file_utilities.read_conf_file(
            REACTIONS_ANNOTATION_CONFIGS_PATH)
        self.__compoundsIdConverter = CompoundsIDConverter()

        # self.__ptw_handler_quinones = PathwayHandler(self.__modelseedCompoundsDb, self.__compoundsIdConverter)
        # self.__ptw_handler_quinones.load_from_file(self.__home_path__ + self.__configs["quinones_pathways"])

        self.__not_to_change_classes = ["cpd03476"]
        self.__set_not_to_change_compounds()

        self.__compounds_revisor = CompoundsRevisor(self.model,
                                                    self.__universal_model)
        biocyc.set_organism("meta")

        self.__swapper = MetaboliteSwapper(
            self.model,
            None,
            None,
            0,
            self.__modelseedCompoundsDb,
            model_database=self.__database_format,
            compoundsIdConverter=self.__compoundsIdConverter,
            universal_model=self.__universal_model,
            not_to_change_compounds=self.__not_to_change_compounds)

        self.__mapper = ModelMapper(self.model,
                                    self.__compoundsAnnotationConfigs,
                                    self.__compoundsIdConverter)

        self.__swapper.set_model_mapper(self.__mapper)
        self.__compounds_revisor.set_model_mapper(self.__mapper)
Ejemplo n.º 3
0
    def __init__(self,compounds_database = None, compounds_converter = None):
        self.target_pathways_map = {}
        self.__pathways_map = {}
        self.taxID_map = {}
        self.__home_path__ = ROOT_DIR

        if not compounds_converter:
            self.__compoundsIdConverter = CompoundsIDConverter()
        else:
            self.__compoundsIdConverter = compounds_converter

        if not compounds_database:
            self.__compounds_database = ModelSeedCompoundsDB()
        else:
            self.__compounds_database = compounds_database

        # if compounds_ontology:
        #     self.__compounds_ontology = compounds_ontology

        biocyc.set_organism('meta')
Ejemplo n.º 4
0
    def add_metacyc_pathway(self,metacyc_pathway_id,generic = False):
        biocyc.set_organism('meta')
        ptw = biocyc.get(metacyc_pathway_id)

        network = self.scrap_metacyc_path(ptw,generic)
        self.convert_compounds_into_modelseedid(network)


        pathway = network.get_pathway()
        if pathway:
            target_reaction = pathway[-1]
            last_reaction = biocyc.get(target_reaction)
            products = last_reaction.compounds_right
            targets = []

            for product in products:
                modelseedids = self.__compoundsIdConverter.convert_dbID_into_modelSeedId("MetaCyc",product.id)
                if modelseedids is not None:
                    targets.extend(modelseedids)

            self.__pathways_map[ptw.id] = network
            self.target_pathways_map[ptw.id]=targets
Ejemplo n.º 5
0
from pathminer import mining
import pandas as pd
import numpy as np
import os

from biocyc import biocyc

biocyc.set_organism('HUMAN')
biocyc.secondary_cache_paths.append( os.path.join(_pathomx_database_path, 'biocyc') )

# Flatten input data to single row

data = []
for input_data in input_1, input_2, input_3, input_4:
    if input_data is not None:
        datam = input_data.mean()
        # We need BioCyc identifiers
        if 'BioCyc' in input_data.columns.names:
            if type(input_data.columns) == pd.MultiIndex:
                entities = [k[input_data.columns.names.index('BioCyc')] for k in input_1.columns.values]
            else:
                entities = input_data.columns.values
            # Map to BioCyc if not already
            biocyc_entities = []
            for e in entities:
                if hasattr(e, 'id'):
                    biocyc_entities.append(e)
                elif type(e) is str:
                    try:
                        biocyc_entities[n] = biocyc.get(o)
                    except:
Ejemplo n.º 6
0
from pathminer import mining
import pandas as pd
import numpy as np
import os

from biocyc import biocyc

biocyc.set_organism('HUMAN')
biocyc.secondary_cache_paths.append(
    os.path.join(_pathomx_database_path, 'biocyc'))
# Flatten input data to single row

data = []
for input_data in input_1, input_2, input_3, input_4:
    if input_data is not None:
        datam = input_data.mean()
        # We need BioCyc identifiers
        if 'BioCyc' in input_data.columns.names:
            if type(input_data.columns) == pd.MultiIndex:
                entities = [
                    k[input_data.columns.names.index('BioCyc')]
                    for k in input_1.columns.values
                ]
            else:
                entities = input_data.columns.values
            # Map to BioCyc if not already
            biocyc_entities = []
            for e in entities:
                if hasattr(e, 'id'):
                    biocyc_entities.append(e)
                elif type(e) is str: