Exemplo n.º 1
0
    def __init__(
        self,
        *,
        name: str,
        version: str,
        repositories: List[Union[BELRepository, BELSheetsRepository]],
        directory: Optional[str] = None,
    ) -> None:
        """Initialize a distributed repository.

        :param name: The name of the distributed repository
        :param version: The version of the distributed repository, independent of the constituent
         repositories' versions
        :param repositories: A list of BEL repositories
        """
        self.name = name
        self.repositories = repositories
        self.directory = directory

        for repository in self.repositories:
            if not hasattr(repository, 'metadata'):
                raise TypeError(f'Missing metadata: {repository}')

        self.dependency_version = '/'.join(repository.metadata.version
                                           for repository in self.repositories)
        self.version = f'{version} ({self.dependency_version})'
        self.authors = serialize_authors({
            author.strip()
            for repository in self.repositories
            for author in repository.metadata.authors.split(',')
        })
        self.description = """A distributed repository of several repositories: {}""".format(
            f'{repository.metadata.name} v{repository.metadata.version}'
            for repository in self.repositories)
        self.metadata = BELMetadata(
            name=self.name,
            version=self.version,
            authors=self.authors,
            description=self.description,
        )
Exemplo n.º 2
0
# Author list will be sorted by name
AUTHORS = [
    'Alpha Tom Kodamullil',
    'Daniel Domingo-Fernández',
    'Martin Hofmann-Apitius',
    'Reagon Karki',
    'Shounak Baksi',
    'Yojana Gadiya',
]

# All metadata is grouped here
metadata = BELMetadata(
    name='COVID-19 Knowledge Graph',
    version=VERSION,
    authors=serialize_authors(AUTHORS),
    contact='*****@*****.**',
    description=
    "Knowledge graph for analysis of COVID-19 disease and potential drug and drug-targets.",
    license='Creative Commons Zero v1.0 Universal',
)

repository = BELRepository(
    HERE,
    metadata=metadata,
)

get_graph = repository.get_graph
get_graphs = repository.get_graphs
get_summary_df = repository.get_summary_df

main = repository.build_cli()
Exemplo n.º 3
0
    'metadata',
    'main',
]

HERE = os.path.dirname(__file__)
VERSION = '0.0.1-dev'

# Author list will be sorted by last name
AUTHORS = [
    'Stephan Gebel',
    'Vanessa Lage-Rupprecht',
]

# All metadata is grouped here
metadata = BELMetadata(
    name='Enzyme Technology Internship 2019',
    version=VERSION,
    authors=serialize_authors(AUTHORS),
    contact='*****@*****.**',
    description=
    "BEL Curation from the Enzyme Technology Internship 2019 at B-IT and Fraunhofer SCAI.",
    license='CC BY 4.0',
)

repository = BELRepository(
    HERE,
    bel_metadata=metadata,
)

main = repository.build_cli()
Exemplo n.º 4
0
    'metadata',
    'get_graph',
    'get_graphs',
    'get_summary_df',
    'main',
]

HERE = os.path.dirname(__file__)
VERSION = '20150611'

# All metadata is grouped here
metadata = BELMetadata(
    name='Selventa Corpora',
    version=VERSION,
    authors='Selventa',
    contact='*****@*****.**',
    description="Selventa Large and Small Corpora.",
    license='Creative Commons Attribution-Non-Commercial-ShareAlike 3.0 Unported License',
    copyright='Copyright (c) 2011-2015, Selventa. All Rights Reserved.',
)

repository = BELRepository(
    HERE,
    metadata=metadata,
    from_path_kwargs=dict(
        allow_nested=True,
        citation_clearing=False,
    ),
)

get_graph = repository.get_graph
Exemplo n.º 5
0
    'Rana Al Disi',
    'Lingling Xu',
    'Kristian Kolpeja',
]

AUTHOR_STRING = serialize_authors(AUTHORS)

# Folder pointers
HERE = os.path.abspath(os.path.dirname(__file__))
CURATION_DIRECTORY = os.path.join(HERE, 'curation')

VERSION = '0.1.1'

metadata = BELMetadata(
    name='HBP Semi-Automated Curation',
    version=VERSION,
    description="This knowledge graph contains content generated with the semi-automated curation workflow"
                "in the Human Brain Pharmacome project.",
    authors=AUTHOR_STRING,
    contact='*****@*****.**',
    license='CC BY 4.0',
)

repository = BELSheetsRepository(
    directory=CURATION_DIRECTORY,
    output_directory=HERE,
    metadata=metadata,
)

main = repository.build_cli()
Exemplo n.º 6
0
class DistributedRepo:
    """A repository dependent on several BEL repositories."""
    def __init__(
        self,
        *,
        name: str,
        version: str,
        repositories: List[Union[BELRepository, BELSheetsRepository]],
        directory: Optional[str] = None,
    ) -> None:
        """Initialize a distributed repository.

        :param name: The name of the distributed repository
        :param version: The version of the distributed repository, independent of the constituent
         repositories' versions
        :param repositories: A list of BEL repositories
        """
        self.name = name
        self.repositories = repositories
        self.directory = directory

        for repository in self.repositories:
            if not hasattr(repository, 'metadata'):
                raise TypeError(f'Missing metadata: {repository}')

        self.dependency_version = '/'.join(repository.metadata.version
                                           for repository in self.repositories)
        self.version = f'{version} ({self.dependency_version})'
        self.authors = serialize_authors({
            author.strip()
            for repository in self.repositories
            for author in repository.metadata.authors.split(',')
        })
        self.description = """A distributed repository of several repositories: {}""".format(
            f'{repository.metadata.name} v{repository.metadata.version}'
            for repository in self.repositories)
        self.metadata = BELMetadata(
            name=self.name,
            version=self.version,
            authors=self.authors,
            description=self.description,
        )

    def get_graphs(self, use_tqdm: bool = True) -> Mapping[str, BELGraph]:
        """Get a mapping of all BEL graphs in the repository."""
        return {
            repository.metadata.name: repository.get_graph(use_tqdm=use_tqdm)
            for repository in self.repositories
        }

    def get_graph(
        self,
        directory: Optional[str] = None,
        use_cached: bool = True,
        use_tqdm: bool = True,
    ) -> BELGraph:
        """Get the graph from all sources."""
        if directory is None:
            if self.directory is None:
                raise ValueError
            directory = self.directory

        pickle_path = os.path.join(directory, f'{self.name}.bel.pickle')
        if use_cached and os.path.exists(pickle_path):
            return pybel.from_pickle(pickle_path)

        rv = union(self.get_graphs(use_tqdm=use_tqdm))
        self.metadata.update(rv)

        pybel.to_pickle(rv, pickle_path)

        nodelink_path = os.path.join(directory,
                                     f'{self.name}.bel.nodelink.json')
        pybel.to_json_path(rv, nodelink_path)

        sif_path = os.path.join(directory, f'{self.name}.bel.sif')
        pybel.to_sif_path(rv, sif_path)

        gsea_path = os.path.join(directory, f'{self.name}.bel.gmt')
        pybel.to_gsea_path(rv, gsea_path)

        graphml_path = os.path.join(directory, f'{self.name}.bel.graphml')
        pybel.to_graphml(rv, graphml_path)

        try:
            statements = pybel.to_indra_statements(rv)
        except ImportError:
            pass
        else:
            indra_path = os.path.join(directory, f'{self.name}.indra.pickle')
            with open(indra_path, 'wb') as file:
                pickle.dump(statements, file)

        try:
            from pybel_cx import to_cx_file
        except ImportError:
            pass
        else:
            cx_path = os.path.join(directory, f'{self.name}.bel.cx.json')
            with open(cx_path, 'w') as file:
                to_cx_file(rv, file)

        try:
            from pybel_tools.assembler.html import to_html
        except ImportError:
            pass
        else:
            html_path = os.path.join(directory, 'index.html')
            with open(html_path, 'w') as file:
                print(to_html(rv), file=file)

        return rv

    def get_indra_statements(
            self,
            directory: str,
            use_cached: bool = True) -> List['indra.statements.Statement']:
        """Get INDRA statements for the graph."""
        return pybel.to_indra_statements(
            self.get_graph(directory, use_cached=use_cached))
Exemplo n.º 7
0
    'Kristian Kolpeja',
]

AUTHOR_STRING = serialize_authors(AUTHORS)

# Folder pointers
HERE = os.path.abspath(os.path.dirname(__file__))
ROUNDS_DIRECTORY = os.path.join(HERE, 'rounds')
DATA_DIRECTORY = os.path.join(HERE, 'data')
VERSION = '0.1.0'

metadata = BELMetadata(
    name='HBP - INDRA Curation',
    version=VERSION,
    description="This knowledge graph contains content generated by the rational enrichment approach described by "
                "Hoyt et al. (2019) applied to the NeuroMMSig inventory.",
    authors=AUTHOR_STRING,
    contact='*****@*****.**',
    license='CC BY 4.0',
)

repository = BELSheetsRepository(
    directory=ROUNDS_DIRECTORY,
    output_directory=DATA_DIRECTORY,
    metadata=metadata,
    prior=neurommsig_knowledge.repository,
)

main = repository.build_cli()

if __name__ == '__main__':
Exemplo n.º 8
0
    'Yojana Gadiya',
    'Trusha Adeshara',
    'Stephan Gebel',
    'Sepehr Golriz',
]

description = "Mechanistic knowledge surrounding several neurodegenerative diseases," \
              " with specific focus on protein aggregation, nicotinic receptor signalling," \
              " proteostasis, and other mechanisms."

# All metadata is grouped here
metadata = BELMetadata(
    name='Curation of Neurodegeneration in BEL (CONIB)',
    version=VERSION,
    authors=serialize_authors(AUTHORS),
    contact='*****@*****.**',
    description=description,
    license='CC BY 4.0',
    copyright='Copyright © 2019 Fraunhofer SCAI, All rights reserved.',
)

repository = BELRepository(
    HERE,
    metadata=metadata,
)

get_graph = repository.get_graph
get_graphs = repository.get_graphs
get_indra_statements = repository.get_indra_statements
get_summary_df = repository.get_summary_df
Exemplo n.º 9
0
HERE = os.path.dirname(__file__)
VERSION = '0.0.1-dev'

# Author list will be sorted by last name
AUTHORS = [
    'Farah Humayun',
    'Daniel Domingo-Fernández',
]

# All metadata is grouped here
metadata = BELMetadata(
    name='Heme Curation',
    version=VERSION,
    authors=serialize_authors(AUTHORS),
    contact='*****@*****.**',
    description="Mechanistic knowledge surrounding hemes",
    license='Private Ownership to Fraunhofer Institute SCAI',
    copyright='Copyright © 2019 Fraunhofer SCAI, All rights reserved.',
)

repository = BELRepository(
    HERE,
    bel_metadata=metadata,
)

get_graph = repository.get_graph
get_graphs = repository.get_graphs
get_summary_df = repository.get_summary_df

main = repository.build_cli()
Exemplo n.º 10
0
HERE = os.path.dirname(__file__)
VERSION = '0.0.1-dev'

# Author list will be sorted by last name
AUTHORS = [
    'Farah Humayun',
    'Daniel Domingo-Fernández',
]

# All metadata is grouped here
metadata = BELMetadata(
    name='HemeKG',
    version=VERSION,
    authors=serialize_authors(AUTHORS),
    contact='*****@*****.**',
    description=
    "Mechanistic knowledge surrounding heme and hemolytic disorders.",
    license='CC BY 4.0',
)

repository = BELRepository(
    HERE,
    metadata=metadata,
)

get_graph = repository.get_graph
get_graphs = repository.get_graphs
get_summary_df = repository.get_summary_df

main = repository.build_cli()
Exemplo n.º 11
0
HERE = os.path.dirname(__file__)
VERSION = '0.0.1-dev'

# Author list will be sorted by last name
AUTHORS = [
    'Farah Humayun',
    'Daniel Domingo-Fernández',
]

# All metadata is grouped here
metadata = BELMetadata(
    name='Heme Curation',
    version=VERSION,
    authors=serialize_authors(AUTHORS),
    contact='*****@*****.**',
    description="Mechanistic knowledge surrounding heme",
    license='MIT License',
    copyright='',
)

repository = BELRepository(
    HERE,
    bel_metadata=metadata,
)

get_graph = repository.get_graph
get_graphs = repository.get_graphs
get_summary_df = repository.get_summary_df

main = repository.build_cli()