pyhiv.split package

Submodules

pyhiv.split.split module

pyhiv.split.split.feature_output_location(feature_name, hierarchical)[source]

Return the output directory and filename suffix for a feature.

HXB2-only splitting keeps the original feature names so fine-grained regions such as v3 remain directly visible. Subtyping output uses a stable hierarchy to group equivalent features under their parent genes.

Parameters:
  • feature_name (str)

  • hierarchical (bool)

Return type:

tuple[Path, str]

pyhiv.split.split.get_gene_region(test_aligned, ref_aligned, aligned_gene_ranges)[source]

Identify the gene region(s) with the highest alignment score.

Parameters:
  • test_aligned (str) – The aligned test sequence (with gaps).

  • ref_aligned (str) – The aligned reference sequence (with gaps).

  • aligned_gene_ranges (dict) – Dictionary mapping gene names to (start, end) positions in the alignment coordinates (0-based).

Returns:

A list of gene names corresponding to the region(s) with the highest alignment score. If multiple genes share the same maximum score, all of them are returned.

Return type:

list

pyhiv.split.split.get_present_gene_regions(test_aligned, aligned_gene_ranges)[source]

Identify gene regions that contain at least one base (non-gap) in the aligned test sequence.

Parameters:
  • test_aligned (str) – The aligned test sequence (with gaps).

  • aligned_gene_ranges (dict) – Dictionary mapping gene names to (start, end) positions in the alignment coordinates (0-based).

Returns:

A list of gene names where the test sequence contains non-gap characters within the region.

Return type:

list

pyhiv.split.split.map_ref_coords_to_alignment(ref_aligned)[source]

Build a mapping from reference coordinates without gaps (GenBank) to alignment columns with gaps.

Parameters:

ref_aligned (str) – The aligned reference sequence (may contain ‘-’ characters representing gaps).

Returns:

A dictionary mapping 1-based reference positions (without gaps) to 0-based alignment positions (with gaps).

Return type:

dict

pyhiv.split.split.safe_output_label(value)[source]

Sanitize an arbitrary string into a stable, filesystem-friendly label.

Parameters:

value (str)

Return type:

str

pyhiv.split.split.sequence_output_label(file_name, sequence_name)[source]

Build the output filename label for a sequence.

Combines the source FASTA file’s path (relative to the input directory, extension stripped) with the sequence id so that same-named records from different input files don’t collide — including files with the same name in different subdirectories, since input discovery is recursive. Used both when PyHIV writes alignment/split files and when PyHIVReporter looks them back up, so the two must stay in sync.

Parameters:
  • file_name (str | None)

  • sequence_name (str)

Return type:

str

pyhiv.split.split.slugify_feature_name(feature_name)[source]

Convert a feature name into a stable filesystem-friendly label.

Parameters:

feature_name (str)

Return type:

str

Module contents