示例#1
0
    def define_instance_variables(self):
        """
        Define instance variables

        :return:
        """

        self.report_material = {}
        self.__compoundsAnnotationConfigs = file_utilities.read_conf_file(
            COMPOUNDS_ANNOTATION_CONFIGS_PATH)
        self.__reactionsAnnotationConfigs = file_utilities.read_conf_file(
            REACTIONS_ANNOTATION_CONFIGS_PATH)

        self.__compounds_ontology = CompoundsDBAccessor()

        self.__home_path__ = ROOT_DIR
        self.__configs = file_utilities.read_conf_file(TOOL_CONFIG_PATH)

        self.changed_reactions = []
        self.reactions_swapper = ReactionsChanger(
            self.model,
            self.__type,
            self.__model_database,
            self.__universal_model,
            compounds_converter=self.__compoundsIdConverter)
示例#2
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)
示例#3
0
    def __init__(self):
        super().__init__()

        # scraper = ReactionsIDConverterScraper()
        # path = scraper()
        self.__database_config = file_utilities.read_conf_file(
            DATABASE_CONFIGS)

        path = ROOT_DIR + self.__database_config[
            "path_model_seed_reactions_aliases"]
        self.__configs = file_utilities.read_conf_file(TOOL_CONFIG_PATH)
        self.__home_path__ = ROOT_DIR
        self.construct_reactions_converter(path)
示例#4
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)
示例#5
0
    def __init__(self):
        self.url_db = "https://raw.githubusercontent.com/ModelSEED/ModelSEEDDatabase/master/Biochemistry/Aliases/Unique_ModelSEED_Reaction_Aliases.txt"

        self.__database_config = file_utilities.read_conf_file(DATABASE_CONFIGS)
        up_to_date = self.__check_time()
        if not up_to_date:
            self.__download_modelseed_database()
示例#6
0
    def __init__(self, model, database_format):
        """
        Class constructor

        :param Model model: cobrapy model
        :param str database_format: ModelSEED, BiGG or KEGG
        """

        self.model = model

        self.objective = linear_reaction_coefficients(self.model)
        if self.objective:
            self.objective = list(self.objective.keys())[0]
        else:
            raise Exception("No objective found")

        self.__compounds_ontology = CompoundsDBAccessor()

        self.model = model
        self.__database_format = database_format
        self.__configs = file_utilities.read_conf_file(TOOL_CONFIG_PATH)
        self.__home_path__ = ROOT_DIR

        self.__modelseedCompoundsDb = ModelSeedCompoundsDB()

        self.__define_instance_variables()

        self.write_in_progress_bar("mapping model... ", 1)
        self.mapper.map_model(database_format)
        self.write_in_progress_bar("model mapped ", 10)
示例#7
0
    def __init__(self):

        self.__database_config = file_utilities.read_conf_file(DATABASE_CONFIGS)
        path = ROOT_DIR + self.__database_config["path_model_seed_db_reactions"]
        # scraper = ModelSeedReactionsDBScraper()
        # path = scraper()
        self.read_model_seed_reactions_database(path)
示例#8
0
    def read_config_file(self):
        configs = file_utilities.read_conf_file(definitions.BOIMMG_DATABASE)

        uri = configs["uri"]
        user = configs["user"]
        password = configs["password"]

        return uri, user, password
示例#9
0
    def get_reaction_annotation_format_by_aliases(aliases):
        reactionsAnnotationConfigs = file_utilities.read_conf_file(
            REACTIONS_ANNOTATION_CONFIGS_PATH)

        res = {}
        for alias in aliases:
            if alias in reactionsAnnotationConfigs.keys():
                new_alias = reactionsAnnotationConfigs[alias]
                res[new_alias] = aliases[alias]
        return res
示例#10
0
    def get_compound_annotation_format_by_aliases(aliases):
        compoundsAnnotationConfigs = file_utilities.read_conf_file(
            COMPOUNDS_ANNOTATION_CONFIGS_PATH)

        res = {}
        for alias in aliases:
            if alias in compoundsAnnotationConfigs.keys():
                new_alias = compoundsAnnotationConfigs[alias]
                res[new_alias] = aliases[alias]
        return res
示例#11
0
    def __init__(self,
                 model: Model,
                 type: int,
                 model_database: str,
                 universal_model: Model,
                 compounds_converter=None):
        """
        Class constructor

        :param cobrapy.Model model: COBRApy model
        :param int type: type of change (0,1,2 or 3)
        :param string model_database: database format of metabolites and reactions
        :param cobrapy.Model universal_model: universal model
        :param (optional) ReactionsIDConverter reactions_converter: a reaction identifier converter
        """

        if not compounds_converter:
            self.__compoundsIDConverter = CompoundsIDConverter()

        else:
            self.__compoundsIDConverter = compounds_converter

        if not universal_model:
            self.__universal_model = Model()
        else:
            self.__universal_model = universal_model
        self.__type = type
        self.__model_database = model_database
        self.__model = model
        self.__modelseed_hydrogen = "cpd00067"
        self.__reactionBalancer = CompoundsRevisor(self.__model)
        self.__not_found_reactions_num = 0

        self.__home_path__ = ROOT_DIR

        self.__configs = file_utilities.read_conf_file(TOOL_CONFIG_PATH)
        self.__compoundsAnnotationConfigs = file_utilities.read_conf_file(
            COMPOUNDS_ANNOTATION_CONFIGS_PATH)
        self.__reactionsAnnotationConfigs = file_utilities.read_conf_file(
            REACTIONS_ANNOTATION_CONFIGS_PATH)
示例#12
0
    def __init__(self,model,universal_model = None,compoundsAnnotationConfigs = None):
        if not universal_model:
            self.__universal_model = Model()
        else:
            self.__universal_model=universal_model

        if not compoundsAnnotationConfigs:
            self.compoundsAnnotationConfigs = file_utilities.read_conf_file(COMPOUNDS_ANNOTATION_CONFIGS_PATH)

        else:
            self.compoundsAnnotationConfigs = compoundsAnnotationConfigs

        self.__model = model
        self.__get_hydrogen_from_model()
        self.__changed_reaction = None
示例#13
0
    def read_config_file(self):

        configs = file_utilities.read_conf_file(definitions.BOIMMG_DATABASE)

        if "uri" in configs.keys() and "user" in configs.keys(
        ) and "password" in configs.keys():

            uri = configs["uri"]
            user = configs["user"]
            password = configs["password"]

            return uri, user, password

        else:

            raise Exception("Please insert the required database information")
示例#14
0
    def define_instance_variables(self):
        """
        Instance variables definition

        :return:
        """

        self.__compounds_ontology = CompoundsDBAccessor()

        self.__added_reactions_and_respective_target = {}

        self.__reactionsAnnotationConfigs = file_utilities.read_conf_file(
            REACTIONS_ANNOTATION_CONFIGS_PATH)

        self.metabolite_report_material = {}
        self.reaction_report_material = {}
        self.__set_components()
示例#15
0
    def define_instance_variables(self):
        """
        Instance variables definition

        :return:
        """

        self.__compounds_ontology = CompoundsDBAccessor()

        self.__added_reactions_and_respective_target = {}

        self.__reactionsAnnotationConfigs = file_utilities.read_conf_file(
            REACTIONS_ANNOTATION_CONFIGS_PATH)

        print("setting components...")
        start = time.time()
        self.__set_components()
        end = time.time()
        print("components set: %d" % (end - start))
示例#16
0
    def __init__(self, model: Model, database_format: str, db_accessor = CompoundsDBAccessor()):
        """
        Class constructor

        :param Model model: model being analysed
        :param database_format: database format (ModelSEED, BiGG or KEGG)
        :param modelseed_compoundsdb:
        """

        self.report_material = {}
        self.__universal_model = Model("universal_model")
        self.model = model
        self.__database_format = database_format
        self.__configs = file_utilities.read_conf_file(TOOL_CONFIG_PATH)
        self.__home_path__ = ROOT_DIR
        self.__compounds_ontology = db_accessor

        self.__modelseedCompoundsDb = ModelSeedCompoundsDB()

        self.__define_instance_variables()
示例#17
0
    def get_annotation_from_cobra_annotation(compound):
        compoundsAnnotationConfigs = file_utilities.read_conf_file(
            COMPOUNDS_ANNOTATION_CONFIGS_PATH)
        inverse = {
            value: key
            for key, value in compoundsAnnotationConfigs.items()
        }

        res = {}
        for annotation_key in compound.annotation:
            if annotation_key in inverse.keys():
                boimmg_database = inverse[annotation_key]

                aliases = compound.annotation[annotation_key]

                if isinstance(aliases, list):
                    res[boimmg_database] = aliases
                else:
                    res[boimmg_database] = [aliases]

        return res
示例#18
0
                                                 compoundsAnnotationConfigs,
                                                 compoundsIDConverter)
    found_2 = compare_models_metabolites(model, model2)

    print(len(found_1))
    print(len(found_2))
    for met2 in found_2:
        if met2 not in found_1:
            print(met2)

    for reaction2 in found_reactions_2:
        if reaction2 not in found_reactions_1:
            print(reaction2)


if __name__ == "__main__":
    import cobra

    compoundsIDConverter = CompoundsIDConverter()
    compoundsAnnotationConfigs = file_utilities.read_conf_file(
        COMPOUNDS_ANNOTATION_CONFIGS_PATH)
    model_database = "BiGG"

    model1 = definitions.ROOT_DIR + "/case_studies/redundant_representation_case/iML1515_mapped.xml"
    model3 = definitions.ROOT_DIR + "/case_studies/redundant_representation_case/iJR904_mapped.xml"
    model2 = definitions.ROOT_DIR + "/case_studies/redundant_representation_case/granulated_gap_filled_iJR904.xml"

    # compare_lipids_ecoli_granulated(model_database, compoundsAnnotationConfigs, compoundsIDConverter)
    compare_models(model1, model2, model3, model_database,
                   compoundsAnnotationConfigs, compoundsIDConverter)
示例#19
0
    def __init__(self):

        conf = file_utilities.read_conf_file(definitions.BOIMMG_DATABASE)
        self.rest_uri = conf["rest_uri"]