Parser

The parser section contains functions to parse the master data, such as hpo.obo and phenotype... files. These methods should mostly be left untouched and there is very little need for client-side code to interact with these methods. The documentation here is mostly for developers of the library.

Public methods

build_ontology_annotations

pyhpo.parser.build_ontology_annotations(data_folder, ontology)[source]

Builds all annotations and associated genes and diseases to the HPO terms in the Ontology.

Parameters:
  • data_folder (str) – The full path to the folder that contains the master data files

  • ontology (OntologyClass) – The ontology of HPO terms

Return type:

None

id_from_string

pyhpo.parser.generics.id_from_string(hpo_string)[source]

Formats the HPO-type Term-ID into an integer id

Parameters:

hpo_string (str) –

HPO term ID.

(e.g.: HP:000001)

Returns:

Integer representation of provided HPO ID

(e.g.: 1)

Return type:

int

remove_outcommented_rows

pyhpo.parser.generics.remove_outcommented_rows(fh, ignorechar='#')[source]

Removes all rows from a filereader object that start with a comment character

Parameters:
  • fh (Iterator[str]) – any object which supports the iterator protocol and returns a string each time its __next__() method is called — file objects and list objects are both suitable

  • ignorechar (str) – All lines starting with this character(s) will be ignored

Yields:

row (str) – One row of the fh iterator

Return type:

Iterator[str]

add_decipher_to_term

pyhpo.parser.diseases.add_decipher_to_term(decipher, term)[source]

Recursive function to add Decipher Disease to an HPOTerm and all its parents

Parameters:
  • decipher (DecipherDisease) – Disease to add to term

  • term (HPOTerm) – HPOTerm that is associated with diseease

Return type:

None

add_negative_decipher_to_term

pyhpo.parser.diseases.add_negative_decipher_to_term(decipher, term)[source]

Recursive function to add excluded Decipher Disease to an HPOTerm and all its parents

Parameters:
  • decipher (DecipherDisease) – Disease to exclude from term

  • term (HPOTerm) – HPOTerm that is not associated with diseease

Return type:

None

add_omim_to_term

pyhpo.parser.diseases.add_omim_to_term(omim, term)[source]

Recursive function to add OMIM Disease to an HPOTerm and all its parents

Parameters:
  • omim (OmimDisease) – Disease to add to term

  • term (HPOTerm) – HPOTerm that is associated with diseease

Return type:

None

add_negative_omim_to_term

pyhpo.parser.diseases.add_negative_omim_to_term(omim, term)[source]

Recursive function to add excluded OMIM Disease to an HPOTerm and all its parents

Parameters:
  • omim (OmimDisease) – Disease to exclude from term

  • term (HPOTerm) – HPOTerm that is not associated with diseease

Return type:

None

add_orpha_to_term

pyhpo.parser.diseases.add_orpha_to_term(orpha, term)[source]

Recursive function to add Orpha Disease to an HPOTerm and all its parents

Parameters:
  • orpha (OrphaDisease) – Disease to add to term

  • term (HPOTerm) – HPOTerm that is associated with diseease

Return type:

None

add_negative_orpha_to_term

pyhpo.parser.diseases.add_negative_orpha_to_term(orpha, term)[source]

Recursive function to add excluded Orpha Disease to an HPOTerm and all its parents

Parameters:
  • orpha (OrphaDisease) – Disease to exclude from term

  • term (HPOTerm) – HPOTerm that is not associated with diseease

Return type:

None

all_decipher_diseases

pyhpo.parser.diseases.all_decipher_diseases()[source]
Return type:

Set[DecipherDisease]

all_omim_diseases

pyhpo.parser.diseases.all_omim_diseases()[source]
Return type:

Set[OmimDisease]

all_orpha_diseases

pyhpo.parser.diseases.all_orpha_diseases()[source]
Return type:

Set[OrphaDisease]

add_gene_to_term

pyhpo.parser.genes.add_gene_to_term(gene, term)[source]

Recursive function to add Gene to an HPOTerm and all its parents

Parameters:
  • gene (GeneSingleton) – Gene to add to term

  • term (HPOTerm) – HPOTerm that is associated with the gene

Return type:

None

all_genes

pyhpo.parser.genes.all_genes()[source]
Return type:

Set[GeneSingleton]

terms_from_file

pyhpo.parser.obo.terms_from_file(data_folder)[source]

Reads an obo file line by line to yield a dict for building an HPOTerm

Parameters:

data_folder (str) – Full path to obo file

Return type:

Iterator[dict]

parse_obo_section

pyhpo.parser.obo.parse_obo_section(term_section)[source]

Parses the section of an OBO file for one single HPO term

Parameters:

term_section (List[str]) – Lines of the obo file that describe the HPO term

Return type:

dict