Esempio n. 1
0
    def load_associations_from_file(self, associations_type: DataType,
                                    associations_url: str,
                                    associations_cache_path: str,
                                    config: GenedescConfigParser) -> None:
        """load go associations from file

        Args:
            associations_type (DataType): the type of associations to set
            associations_url (str): url to the association file
            associations_cache_path (str): path to cache file for the associations
            config (GenedescConfigParser): configuration object where to read properties
        """
        assoc_config = AssocParserConfig(remove_double_prefixes=True,
                                         paint=True)
        if associations_type == DataType.GO:
            logger.info("Loading GO associations from file")
            self.go_associations = AssociationSetFactory().create_from_assocs(
                assocs=GafParser(config=assoc_config).parse(
                    file=self._get_cached_file(
                        cache_path=associations_cache_path,
                        file_source_url=associations_url),
                    skipheader=True),
                ontology=self.go_ontology)
            self.go_associations = self.remove_blacklisted_annotations(
                association_set=self.go_associations,
                ontology=self.go_ontology,
                terms_blacklist=config.get_module_property(
                    module=Module.GO, prop=ConfigModuleProperty.EXCLUDE_TERMS))
        elif associations_type == DataType.DO:
            logger.info("Loading DO associations from file")
            self.do_associations = AssociationSetFactory().create_from_assocs(
                assocs=GafParser(config=assoc_config).parse(
                    file=self._get_cached_file(
                        cache_path=associations_cache_path,
                        file_source_url=associations_url),
                    skipheader=True),
                ontology=self.do_ontology)
            self.do_associations = self.remove_blacklisted_annotations(
                association_set=self.do_associations,
                ontology=self.do_ontology,
                terms_blacklist=config.get_module_property(
                    module=Module.DO_EXP_AND_BIO,
                    prop=ConfigModuleProperty.EXCLUDE_TERMS))
        elif associations_type == DataType.EXPR:
            logger.info("Loading Expression associations from file")
            self.expression_associations = AssociationSetFactory(
            ).create_from_assocs(assocs=GafParser(config=assoc_config).parse(
                file=self._get_cached_file(cache_path=associations_cache_path,
                                           file_source_url=associations_url),
                skipheader=True),
                                 ontology=self.expression_ontology)
            self.expression_associations = self.remove_blacklisted_annotations(
                association_set=self.expression_associations,
                ontology=self.expression_ontology,
                terms_blacklist=config.get_module_property(
                    module=Module.EXPRESSION,
                    prop=ConfigModuleProperty.EXCLUDE_TERMS))
Esempio n. 2
0
    def __init__(self, config=None):
        """
        Arguments:
        ---------

        config : a AssocParserConfig object
        """
        if config is None:
            config = AssocParserConfig()
        self.config = config
        self.report = Report()
Esempio n. 3
0
    def load_associations_from_file(self, associations_type: DataType,
                                    associations_url: str,
                                    associations_cache_path: str,
                                    config: GenedescConfigParser) -> None:
        """load go associations from file

        Args:
            associations_type (DataType): the type of associations to set
            associations_url (str): url to the association file
            associations_cache_path (str): path to cache file for the associations
            config (GenedescConfigParser): configuration object where to read properties
        """
        logger.info("Loading associations from file")
        assoc_config = AssocParserConfig(remove_double_prefixes=True,
                                         paint=True)
        assocs = AssociationSetFactory().create_from_assocs(
            assocs=GafParser(config=assoc_config).parse(
                file=self._get_cached_file(cache_path=associations_cache_path,
                                           file_source_url=associations_url),
                skipheader=True),
            ontology=self.get_ontology(associations_type))
        self.set_associations(associations_type=associations_type,
                              associations=assocs,
                              config=config)
Esempio n. 4
0
 def __init__(self):
     # Needed to retain IBA annotations
     config = AssocParserConfig()
     config.paint = True
     GafParser.__init__(self, config=config)