pyhml package

pyhml

class pyhml.pyhml.HmlParser(hmlversion: str = None, verbose: bool = False)[source]

Bases: object

A python HML parser that converts any valid HML file into an python object. Allows users to easily interact with HML data as python objects. Users can also easily convert the HML data to a pandas DataFrame. If no hmlversion is provided, then the schemas for all HML versions are loaded.

Examples:

>>> import pyhml
>>> hmlparser = pyhml.HmlParser(verbose=True)
>>> hml = hmlparser.parse(hml_file)
>>> hml_df = hml.toPandas()
Parameters:
  • hmlversion (str) – A specific HML version to load.
  • verbose (bool) – Flag for running in verbose.
parse(hml_file: str) → pyhml.models.hml.HML[source]

Parses an HML file into a python object.

>>> hml = hmlparser.parse(hml_file)
Parameters:hml_file – A valid HML file
Type:str
Returns:Object containing HML data
Return type:HML

Data Objects

HML

class pyhml.models.hml.HML(project_name: str = None, version: str = None, schema_location: str = None, reporting_center: pyhml.models.reporting_center.ReportingCenter = None, sample: List[pyhml.models.sample.Sample] = None)[source]

Bases: pyhml.models.base_model_.Model

NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.

classmethod from_dict(dikt) → pyhml.models.hml.HML[source]

Returns the dict as a model

Parameters:dikt – A dict.
Type:dict
Returns:The HML of this HML.
Return type:HML
project_name

Gets the project_name of this HML.

Returns:The project_name of this HML.
Return type:str
reporting_center

Gets the reporting_center of this HML.

Returns:The reporting_center of this HML.
Return type:ReportingCenter
sample

Gets the sample of this HML.

Returns:The sample of this HML.
Return type:List[Sample]
schema_location

Gets the schema_location of this HML.

Returns:The schema_location of this HML.
Return type:str
toPandas() → pandas.core.frame.DataFrame[source]

Returns all the HML data as a pandas DataFrame.

Examples:

>>> import pyhml
>>> hmlparser = pyhml.HmlParser(verbose=True)
>>> hml = hmlparser.parse(hml_file)
>>> hml_df = hml.toPandas()
Returns:Pandas dataframe
Return type:DataFrame
tobiotype(outdir, dtype='fasta', by='file')[source]

Converts an HML object to a BioPython data fromat

Examples:

>>> import pyhml
>>> hmlparser = pyhml.HmlParser(verbose=True)
>>> hml = hmlparser.parse(hml_file)
>>> hml.tobiotype("output/directory",dtype='imgt', by='subject')
Parameters:
  • outdir (str) – The output directory
  • dtype – The BioPython output type
  • by (str) – What to print out the HML file by
version

Gets the version of this HML.

Returns:The version of this HML.
Return type:str

Sample

class pyhml.models.sample.Sample(center_code: int = None, id: str = None, collection_method: str = None, typing: List[pyhml.models.typing.Typing] = None)[source]

Bases: pyhml.models.base_model_.Model

Examples:

>>> from pyhml.models.typing import Typing
>>> from pyhml.models.sample import Sample
center_code

Gets the center_code of this Sample.

Returns:The center_code of this Sample.
Return type:int
collection_method

Gets the collection_method of this Sample.

Returns:The collection_method of this Sample.
Return type:str
create_seqrecords()[source]

Creates the seq_records for this Sample.

classmethod from_dict(dikt) → pyhml.models.sample.Sample[source]

Returns the dict as a model

Parameters:dikt – A dict.
Type:dict
Returns:The Sample of this Sample.
Return type:Sample
id

Gets the id of this Sample.

Returns:The id of this Sample.
Return type:str
seq_records

Gets the seq_records of this Sample.

Returns:The seq_records of this Sample.
Return type:Dict
typing

Gets the typing of this Sample.

Returns:The typing of this Sample.
Return type:List[Typing]

Typing

class pyhml.models.typing.Typing(date: str = None, gene_family: str = None, allele_assignment: List[pyhml.models.allele_assignment.AlleleAssignment] = None, consensus_sequence: List[pyhml.models.consensus.Consensus] = None, typing_method: pyhml.models.typing_method.TypingMethod = None)[source]

Bases: pyhml.models.base_model_.Model

NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.

allele_assignment

Gets the allele_assignment of this Typing.

Returns:The allele_assignment of this Typing.
Return type:List[AlleleAssignment]
consensus_sequence

Gets the consensus_sequence of this Typing.

Returns:The consensus_sequence of this Typing.
Return type:List[Consensus]
create_seqrecord(subid)[source]
date

Gets the date of this Typing.

Returns:The date of this Typing.
Return type:str
classmethod from_dict(dikt) → pyhml.models.typing.Typing[source]

Returns the dict as a model

Parameters:dikt – A dict.
Type:dict
Returns:The Typing of this Typing.
Return type:Typing
gene_family

Gets the gene_family of this Typing.

Returns:The gene_family of this Typing.
Return type:str
seq_records

Gets the seq_records of this ReferenceData.

Returns:The seq_records of this ReferenceData.
Return type:List[SeqRecord]
typing_method

Gets the typing_method of this Typing.

Returns:The typing_method of this Typing.
Return type:TypingMethod

Consensus

class pyhml.models.consensus.Consensus(date: str = None, consensus_sequence_block: List[pyhml.models.consensus_seq_block.ConsensusSeqBlock] = None, reference_database: List[pyhml.models.ref_database.RefDatabase] = None)[source]

Bases: pyhml.models.base_model_.Model

NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.

consensus_sequence_block

Gets the consensus_sequence_block of this Consensus.

Returns:The consensus_sequence_block of this Consensus.
Return type:List[ConsensusSeqBlock]
date

Gets the date of this Consensus.

Returns:The date of this Consensus.
Return type:str
classmethod from_dict(dikt) → pyhml.models.consensus.Consensus[source]

Returns the dict as a model

Parameters:dikt – A dict.
Type:dict
Returns:The Consensus of this Consensus.
Return type:Consensus
reference_database

Gets the reference_database of this Consensus.

Returns:The reference_database of this Consensus.
Return type:List[RefDatabase]

Consensus Block

class pyhml.models.consensus_seq_block.ConsensusSeqBlock(continuity: bool = None, description: str = None, end: int = None, expected_copy_number: int = None, phase_set: str = None, reference_sequence_id: str = None, start: int = None, strand: str = None, sequence: Bio.Seq.Seq = None, sequence_quality: List[pyhml.models.seq_quality.SeqQuality] = None, variant: List[pyhml.models.variant.Variant] = None)[source]

Bases: pyhml.models.base_model_.Model

NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.

continuity

Gets the continuity of this ConsensusSeqBlock.

Returns:The continuity of this ConsensusSeqBlock.
Return type:bool
description

Gets the description of this ConsensusSeqBlock.

Returns:The description of this ConsensusSeqBlock.
Return type:str
end

Gets the end of this ConsensusSeqBlock.

Returns:The end of this ConsensusSeqBlock.
Return type:int
expected_copy_number

Gets the expected_copy_number of this ConsensusSeqBlock.

Returns:The expected_copy_number of this ConsensusSeqBlock.
Return type:int
classmethod from_dict(dikt) → pyhml.models.consensus_seq_block.ConsensusSeqBlock[source]

Returns the dict as a model

Parameters:dikt – A dict.
Type:dict
Returns:The ConsensusSeqBlock of this ConsensusSeqBlock.
Return type:ConsensusSeqBlock
phase_set

Gets the phase_set of this ConsensusSeqBlock.

Returns:The phase_set of this ConsensusSeqBlock.
Return type:str
reference_sequence_id

Gets the reference_sequence_id of this ConsensusSeqBlock.

Returns:The reference_sequence_id of this ConsensusSeqBlock.
Return type:str
sequence

Gets the sequence of this ConsensusSeqBlock.

Returns:The sequence of this ConsensusSeqBlock.
Return type:Seq
sequence_quality

Gets the sequence_quality of this ConsensusSeqBlock.

Returns:The sequence_quality of this ConsensusSeqBlock.
Return type:List[SeqQuality]
start

Gets the start of this ConsensusSeqBlock.

Returns:The start of this ConsensusSeqBlock.
Return type:int
strand

Gets the strand of this ConsensusSeqBlock.

Returns:The strand of this ConsensusSeqBlock.
Return type:str
variant

Gets the variant of this ConsensusSeqBlock.

Returns:The variant of this ConsensusSeqBlock.
Return type:List[Variant]

Allele Assignment

class pyhml.models.allele_assignment.AlleleAssignment(allele_db: str = None, allele_version: str = None, date: str = None, glstring: List[str] = None, haploid: List[pyhml.models.haploid.Haploid] = None)[source]

Bases: pyhml.models.base_model_.Model

NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.

allele_db

Gets the allele_db of this AlleleAssignment.

Returns:The allele_db of this AlleleAssignment.
Return type:str
allele_version

Gets the allele_version of this AlleleAssignment.

Returns:The allele_version of this AlleleAssignment.
Return type:str
date

Gets the date of this AlleleAssignment.

Returns:The date of this AlleleAssignment.
Return type:str
classmethod from_dict(dikt) → pyhml.models.allele_assignment.AlleleAssignment[source]

Returns the dict as a model

Parameters:dikt – A dict.
Type:dict
Returns:The AlleleAssignment of this AlleleAssignment.
Return type:AlleleAssignment
glstring

Gets the glstring of this AlleleAssignment.

Returns:The glstring of this AlleleAssignment.
Return type:List[str]
haploid

Gets the haploid of this AlleleAssignment.

Returns:The haploid of this AlleleAssignment.
Return type:List[Haploid]

Allele Assignment

class pyhml.models.allele_assignment.AlleleAssignment(allele_db: str = None, allele_version: str = None, date: str = None, glstring: List[str] = None, haploid: List[pyhml.models.haploid.Haploid] = None)[source]

Bases: pyhml.models.base_model_.Model

NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.

allele_db

Gets the allele_db of this AlleleAssignment.

Returns:The allele_db of this AlleleAssignment.
Return type:str
allele_version

Gets the allele_version of this AlleleAssignment.

Returns:The allele_version of this AlleleAssignment.
Return type:str
date

Gets the date of this AlleleAssignment.

Returns:The date of this AlleleAssignment.
Return type:str
classmethod from_dict(dikt) → pyhml.models.allele_assignment.AlleleAssignment[source]

Returns the dict as a model

Parameters:dikt – A dict.
Type:dict
Returns:The AlleleAssignment of this AlleleAssignment.
Return type:AlleleAssignment
glstring

Gets the glstring of this AlleleAssignment.

Returns:The glstring of this AlleleAssignment.
Return type:List[str]
haploid

Gets the haploid of this AlleleAssignment.

Returns:The haploid of this AlleleAssignment.
Return type:List[Haploid]