src/pybel/io/line_utils.py
def parse_lines(
    graph: BELGraph,
    lines: Iterable[str],
    manager: Optional[Manager] = None,
    disallow_nested: bool = False,
    citation_clearing: bool = True,
    use_tqdm: bool = False,
    tqdm_kwargs: Optional[Mapping[str, Any]] = None,
    no_identifier_validation: bool = False,
    disallow_unqualified_translocations: bool = False,
    allow_redefinition: bool = False,
    allow_definition_failures: bool = False,
    allow_naked_names: bool = False,
    required_annotations: Optional[List[str]] = None,
    upgrade_urls: bool = False,
) -> None:
    """Parse an iterable of lines into this graph.

    Delegates to :func:`parse_document`, :func:`parse_definitions`, and :func:`parse_statements`.

    :param graph: A BEL graph
    :param lines: An iterable over lines of BEL script
    :param manager: A PyBEL database manager
    :param disallow_nested: If true, turns on nested statement failures
    :param citation_clearing: Should :code:`SET Citation` statements clear evidence and all annotations?
                                   Delegated to :class:`pybel.parser.ControlParser`
    :param use_tqdm: Use :mod:`tqdm` to show a progress bar?
    :param tqdm_kwargs: Keywords to pass to ``tqdm``
    :param disallow_unqualified_translocations: If true, allow translocations without TO and FROM clauses.
    :param required_annotations: Annotations that are required for all statements
    :param upgrade_urls: Automatically upgrade old namespace URLs. Defaults to false.

    .. warning::

        These options allow concessions for parsing BEL that is either **WRONG** or **UNSCIENTIFIC**. Use them at
        risk to reproducibility and validity of your results.

    :param no_identifier_validation: If true, turns off namespace validation
    :param allow_naked_names: If true, turns off naked namespace failures
    :param allow_redefinition: If true, doesn't fail on second definition of same name or annotation
    :param allow_definition_failures: If true, allows parsing to continue if a terminology file download/parse fails
    """
    docs, definitions, statements = split_file_to_annotations_and_definitions(lines)

    if manager is None:
        manager = Manager()

    metadata_parser = MetadataParser(
        manager,
        allow_redefinition=allow_redefinition,
        skip_validation=no_identifier_validation,
        upgrade_urls=upgrade_urls,
    )

    parse_document(
        graph,
        docs,
        metadata_parser,
    )

    parse_definitions(
        graph,
        definitions,
        metadata_parser,
        allow_failures=allow_definition_failures,
        use_tqdm=use_tqdm,
        tqdm_kwargs=tqdm_kwargs,
    )

    bel_parser = BELParser(
        graph=graph,
        # terminologies
        namespace_to_term_to_encoding=metadata_parser.namespace_to_term_to_encoding,
        namespace_to_pattern=metadata_parser.namespace_to_pattern,
        annotation_to_term=metadata_parser.annotation_to_term,
        annotation_to_pattern=metadata_parser.annotation_to_pattern,
        annotation_to_local=metadata_parser.annotation_to_local,
        # language settings
        disallow_nested=disallow_nested,
        citation_clearing=citation_clearing,
        skip_validation=no_identifier_validation,
        allow_naked_names=allow_naked_names,
        disallow_unqualified_translocations=disallow_unqualified_translocations,
        required_annotations=required_annotations,
    )

    parse_statements(
        graph,
        statements,
        bel_parser,
        use_tqdm=use_tqdm,
        tqdm_kwargs=tqdm_kwargs,
    )

    logger.info('Network has %d nodes and %d edges', graph.number_of_nodes(), graph.number_of_edges())
Parse an iterable of lines into this graph.

    Delegates to :func:`parse_document`, :func:`parse_definitions`, and :func:`parse_statements`.

    :param graph: A BEL graph
    :param lines: An iterable over lines of BEL script
    :param manager: A PyBEL database manager
    :param disallow_nested: If true, turns on nested statement failures
    :param citation_clearing: Should :code:`SET Citation` statements clear evidence and all annotations?
                                   Delegated to :class:`pybel.parser.ControlParser`
    :param use_tqdm: Use :mod:`tqdm` to show a progress bar?
    :param tqdm_kwargs: Keywords to pass to ``tqdm``
    :param disallow_unqualified_translocations: If true, allow translocations without TO and FROM clauses.
    :param required_annotations: Annotations that are required for all statements
    :param upgrade_urls: Automatically upgrade old namespace URLs. Defaults to false.

    .. warning::

        These options allow concessions for parsing BEL that is either **WRONG** or **UNSCIENTIFIC**. Use them at
        risk to reproducibility and validity of your results.

    :param no_identifier_validation: If true, turns off namespace validation
    :param allow_naked_names: If true, turns off naked namespace failures
    :param allow_redefinition: If true, doesn't fail on second definition of same name or annotation
    :param allow_definition_failures: If true, allows parsing to continue if a terminology file download/parse fails
    
Parse an iterable of lines into this graph.
Parse an iterable of lines into this graph .
def parse_lines(
    graph: BELGraph,
    lines: Iterable[str],
    manager: Optional[Manager] = None,
    disallow_nested: bool = False,
    citation_clearing: bool = True,
    use_tqdm: bool = False,
    tqdm_kwargs: Optional[Mapping[str, Any]] = None,
    no_identifier_validation: bool = False,
    disallow_unqualified_translocations: bool = False,
    allow_redefinition: bool = False,
    allow_definition_failures: bool = False,
    allow_naked_names: bool = False,
    required_annotations: Optional[List[str]] = None,
    upgrade_urls: bool = False,
) -> None:
    docs, definitions, statements = split_file_to_annotations_and_definitions(lines)
    if manager is None:
        manager = Manager()
    metadata_parser = MetadataParser(
        manager,
        allow_redefinition=allow_redefinition,
        skip_validation=no_identifier_validation,
        upgrade_urls=upgrade_urls,
    )
    parse_document(
        graph,
        docs,
        metadata_parser,
    )
    parse_definitions(
        graph,
        definitions,
        metadata_parser,
        allow_failures=allow_definition_failures,
        use_tqdm=use_tqdm,
        tqdm_kwargs=tqdm_kwargs,
    )
    bel_parser = BELParser(
        graph=graph,
        namespace_to_term_to_encoding=metadata_parser.namespace_to_term_to_encoding,
        namespace_to_pattern=metadata_parser.namespace_to_pattern,
        annotation_to_term=metadata_parser.annotation_to_term,
        annotation_to_pattern=metadata_parser.annotation_to_pattern,
        annotation_to_local=metadata_parser.annotation_to_local,
        disallow_nested=disallow_nested,
        citation_clearing=citation_clearing,
        skip_validation=no_identifier_validation,
        allow_naked_names=allow_naked_names,
        disallow_unqualified_translocations=disallow_unqualified_translocations,
        required_annotations=required_annotations,
    )
    parse_statements(
        graph,
        statements,
        bel_parser,
        use_tqdm=use_tqdm,
        tqdm_kwargs=tqdm_kwargs,
    )
    logger.info('Network has %d nodes and %d edges', graph.number_of_nodes(), graph.number_of_edges())
def parse_lines ( graph : BELGraph , lines : Iterable [ str ] , manager : Optional [ Manager ] = None , disallow_nested : bool = False , citation_clearing : bool = True , use_tqdm : bool = False , tqdm_kwargs : Optional [ Mapping [ str , Any ] ] = None , no_identifier_validation : bool = False , disallow_unqualified_translocations : bool = False , allow_redefinition : bool = False , allow_definition_failures : bool = False , allow_naked_names : bool = False , required_annotations : Optional [ List [ str ] ] = None , upgrade_urls : bool = False , ) -> None : docs , definitions , statements = split_file_to_annotations_and_definitions ( lines ) if manager is None : manager = Manager ( ) metadata_parser = MetadataParser ( manager , allow_redefinition = allow_redefinition , skip_validation = no_identifier_validation , upgrade_urls = upgrade_urls , ) parse_document ( graph , docs , metadata_parser , ) parse_definitions ( graph , definitions , metadata_parser , allow_failures = allow_definition_failures , use_tqdm = use_tqdm , tqdm_kwargs = tqdm_kwargs , ) bel_parser = BELParser ( graph = graph , namespace_to_term_to_encoding = metadata_parser . namespace_to_term_to_encoding , namespace_to_pattern = metadata_parser . namespace_to_pattern , annotation_to_term = metadata_parser . annotation_to_term , annotation_to_pattern = metadata_parser . annotation_to_pattern , annotation_to_local = metadata_parser . annotation_to_local , disallow_nested = disallow_nested , citation_clearing = citation_clearing , skip_validation = no_identifier_validation , allow_naked_names = allow_naked_names , disallow_unqualified_translocations = disallow_unqualified_translocations , required_annotations = required_annotations , ) parse_statements ( graph , statements , bel_parser , use_tqdm = use_tqdm , tqdm_kwargs = tqdm_kwargs , ) logger . info ( 'Network has %d nodes and %d edges' , graph . number_of_nodes ( ) , graph . number_of_edges ( ) )
Parse an iterable of lines into this graph.
Parse an iterable of lines into this graph .
"""Parse an iterable of lines into this graph.

    Delegates to :func:`parse_document`, :func:`parse_definitions`, and :func:`parse_statements`.

    :param graph: A BEL graph
    :param lines: An iterable over lines of BEL script
    :param manager: A PyBEL database manager
    :param disallow_nested: If true, turns on nested statement failures
    :param citation_clearing: Should :code:`SET Citation` statements clear evidence and all annotations?
                                   Delegated to :class:`pybel.parser.ControlParser`
    :param use_tqdm: Use :mod:`tqdm` to show a progress bar?
    :param tqdm_kwargs: Keywords to pass to ``tqdm``
    :param disallow_unqualified_translocations: If true, allow translocations without TO and FROM clauses.
    :param required_annotations: Annotations that are required for all statements
    :param upgrade_urls: Automatically upgrade old namespace URLs. Defaults to false.

    .. warning::

        These options allow concessions for parsing BEL that is either **WRONG** or **UNSCIENTIFIC**. Use them at
        risk to reproducibility and validity of your results.

    :param no_identifier_validation: If true, turns off namespace validation
    :param allow_naked_names: If true, turns off naked namespace failures
    :param allow_redefinition: If true, doesn't fail on second definition of same name or annotation
    :param allow_definition_failures: If true, allows parsing to continue if a terminology file download/parse fails
    """ # terminologies # language settings
graph
BELGraph
A BEL graph
A BEL graph
lines
Iterable[str]
An iterable over lines of BEL script
An iterable over lines of BEL script
manager
Optional[Manager]
A PyBEL database manager
A PyBEL database manager
disallow_nested
bool
If true, turns on nested statement failures
If true turns on nested statement failures
citation_clearing
bool
Should :code:`SET Citation` statements clear evidence and all annotations.
Delegated to :class:`pybel.parser.ControlParser`
Should : code : ` SET Citation ` statements clear evidence and all annotations . Delegated to : class : ` pybel . parser . ControlParser `
use_tqdm
bool
None
tqdm_kwargs
Optional[Mapping[str, Any]]
Keywords to pass to ``tqdm``
Keywords to pass to ` ` tqdm ` `
no_identifier_validation
bool
If true, turns off namespace validation
If true turns off namespace validation
disallow_unqualified_translocations
bool
If true, allow translocations without TO and FROM clauses.
If true allow translocations without TO and FROM clauses .
allow_redefinition
bool
If true, doesn't fail on second definition of same name or annotation
If true doesn ' t fail on second definition of same name or annotation
allow_definition_failures
bool
If true, allows parsing to continue if a terminology file download/parse fails
If true allows parsing to continue if a terminology file download / parse fails
allow_naked_names
bool
If true, turns off naked namespace failures
If true turns off naked namespace failures
required_annotations
Optional[List[str]]
Annotations that are required for all statements
Annotations that are required for all statements
upgrade_urls
bool
Automatically upgrade old namespace URLs. Defaults to false.
warning:.

These options allow concessions for parsing BEL that is either **WRONG** or **UNSCIENTIFIC**. Use them at
risk to reproducibility and validity of your results.
Automatically upgrade old namespace URLs . Defaults to false . warning : . These options allow concessions for parsing BEL that is either ** WRONG ** or ** UNSCIENTIFIC ** . Use them at risk to reproducibility and validity of your results .