varlens package
Subpackages
- varlens.read_evidence package
- Submodules
- varlens.read_evidence.pileup module
- varlens.read_evidence.pileup_collection module
MatchingEvidencePileupCollectionPileupCollection.allele_summary()PileupCollection.at()PileupCollection.filter()PileupCollection.from_bam()PileupCollection.group_by_allele()PileupCollection.group_by_match()PileupCollection.linePileupCollection.loci()PileupCollection.matchPileupCollection.match_summary()PileupCollection.merge()PileupCollection.num_reads()PileupCollection.pileup()PileupCollection.read_attribute()PileupCollection.read_attributes()PileupCollection.reads()
to_locus()
- varlens.read_evidence.pileup_element module
- varlens.read_evidence.util module
- Module contents
PileupPileupCollectionPileupCollection.allele_summary()PileupCollection.at()PileupCollection.filter()PileupCollection.from_bam()PileupCollection.group_by_allele()PileupCollection.group_by_match()PileupCollection.linePileupCollection.loci()PileupCollection.matchPileupCollection.match_summary()PileupCollection.merge()PileupCollection.num_reads()PileupCollection.pileup()PileupCollection.read_attribute()PileupCollection.read_attributes()PileupCollection.reads()
PileupElementalignment_key()read_key()
Submodules
varlens.fusions module
Supplied fusion RNA -> Isovar evidence -> Topiary protein fragments.
This adapter does not discover fusions from BAMs or infer a coding frame from gene names. Isovar validates the supplied sequence, mappings, references and read observations, retaining every supported frame and unresolved outcome.
- varlens.fusions.analyze_fusion(payload, *, alleles=(), epitope_lengths=(8, 9, 10, 11), min_fragments=2, predictor=None)[source]
Return a JSON-serializable reconstruction, fragments and predictions.
payloadfollows Isovar’s supplied-fusion input contract (fusion,references,reads, optionalreference_names). The Sid fixture envelope fieldsnoteandoriginal_recordsare preserved but not passed to Isovar as evidence. Unknown fields are rejected by Isovar.All coding hypotheses, including ambiguous/partial-CDS hypotheses, become separately identified fragments. Their status is carried onto prediction rows; no hypothesis is selected as the true protein. No alleles/predictor means reconstruction only.
predictormay be a configured TopiaryPredictor for a Python caller; otherwise supplied alleles select mhctools.NetMHCpan.
varlens.loci_util module
- class varlens.loci_util.Loci(locus_iterator=(), contig_map=None, insertions=())[source]
Bases:
object
- varlens.loci_util.load_from_args(args)[source]
Return a Loci object giving the loci specified on the command line.
If no loci-related arguments are specified, return None. This makes it possible to distinguish an empty set of loci, for example due to filters removing all loci, from the case where the user didn’t specify any arguments.
varlens.locus module
- class varlens.locus.Locus(contig, start, end)[source]
Bases:
LocusA genomic interval in 0-indexed interbase coordinates.
- See this blog post for a discussion on coordinate systems:
http://alternateallele.blogspot.com/2012/03/genome-coordinate-conventions.html
- static from_inclusive_coordinates(contig, start, end=None)[source]
Given coordinates in 1-based coordinates that are inclusive on start and end, return a Locus instance. Locus instances are always 0-based “interbase” coordinates.
- static from_interbase_coordinates(contig, start, end=None)[source]
Given coordinates in 0-based interbase coordinates, return a Locus instance.
- property inclusive_end
- property inclusive_start
- property pileup_positions
Reference bases needed to query this interval (left anchor for insertions).
- property position
If this locus spans a single base, this property gives that position. Otherwise, raises a ValueError.
- property positions
A Python range object giving the bases included in this locus.
varlens.mhc_binding module
- varlens.mhc_binding.binding_affinities(variants, alleles, epitope_lengths=(8, 9, 10, 11))[source]
Return each variant’s lowest mutant-peptide affinity (nM) and allele.
Variants without an affinity prediction have a missing affinity and allele. Topiary’s presentation scores are deliberately excluded from this summary.
- varlens.mhc_binding.fragment_predictions(fragments, alleles=(), epitope_lengths=(8, 9, 10, 11), *, predictor=None)[source]
Predict target-overlapping peptides, retaining all fragment metadata.
Unlike the small-variant best-affinity summary, this returns Topiary’s full prediction rows, with score kinds, fragment/sample identity and evidence. Target overlap is not a claim of proteome-wide novelty.
varlens.read_source module
varlens.reads_util module
varlens.sequence_context module
- varlens.sequence_context.variant_context(reference_fasta, contig, inclusive_start, inclusive_end, alt, context_length)[source]
Retrieve the surronding reference region from a variant.
SNVs are canonicalized so the reference base is a pyrmidine (C/T). For indels the reverse complement will still be taken if the first base of the reference is not a pyrmidine, but since the reference will also be reversed, that doesn’t guarantee it will start with a pyrmidine.
- Parameters:
- reference_fastaFastaReference
reference sequence from pyfaidx package
- contigstr
Chromosome of the variant
- inclusive_startint
start of the variant in 1-based inclusive coordinates
- inclusive_endint
end of the variant in 1-based inclusive coordinates
- altstring
alt sequence
- context_lengthint
number of bases on either side of the variant to return
- Returns:
- A tuple of (5’, mutation, 3’) where
5’ - bases immediately 5 prime to the mutation
3’ - bases immediately 3 prime to the mutation
- mutation - the ref sequence followed by a > character followed by the
the alt sequence
varlens.support module
- varlens.support.allele_support_df(loci, sources)[source]
Returns a DataFrame of allele counts for all given loci in the read sources
- varlens.support.variant_support(variants, allele_support_df, ignore_missing=False)[source]
Collect the read evidence support for the given variants.
- Parameters:
- variantsiterable of varcode.Variant
- allele_support_dfdataframe
Allele support dataframe, as output by the varlens-allele-support tool. It should have columns: source, contig, interbase_start, interbase_end, allele, and count (the number of supporting reads).
- ignore_missingboolean
If True, variants with no allele counts have zero depth. Otherwise missing counts raise ValueError.
- Returns:
- pandas.DataFrame
Rows are variants; columns have two named levels,
measurementandsource. Metrics are num_alt, num_ref, num_other, total_depth, alt_fraction, and any_alt_fraction. For example,frame["num_alt"]selects all sources’ alternate-read counts.
varlens.util module
varlens.variant_includes module
- class varlens.variant_includes.Context(reference, context_num_bases)[source]
Bases:
Includeable- columns = ['context_5_prime', 'context_3_prime', 'context_mutation']
- name = 'variant sequence context'
- string_columns = ['context_5_prime', 'context_3_prime', 'context_mutation']
- class varlens.variant_includes.Effect[source]
Bases:
Includeable- columns = ['effect', 'effect_candidates']
- name = 'variant effect annotations'
- string_columns = ['effect', 'effect_candidates']
- class varlens.variant_includes.Gene[source]
Bases:
Includeable- columns = ['gene']
- name = 'gene annotations'
- string_columns = ['gene']
- class varlens.variant_includes.Includeable[source]
Bases:
object- columns = None
- float_columns = ()
- string_columns = ()
- class varlens.variant_includes.MHCBindingAffinity(hla=None, hla_dataframe=None, donor_to_hla=None)[source]
Bases:
Includeable- columns = ['binding_affinity', 'binding_allele']
- float_columns = ['binding_affinity']
- name = 'MHC binding affinity'
- noncoding_effects = {"3' UTR", "5' UTR", 'intergenic', 'intronic', 'non-coding-transcript', 'silent'}
- string_columns = ['binding_allele']
- class varlens.variant_includes.ReadEvidence(read_sources=None, read_sources_df=None, column_format='{source}_count_{allele_group}', survive_errors=False)[source]
Bases:
Includeable- column_name(source, allele_group)[source]
- Parameters:
- sourcestring
name of the ReadSource
- allele_groupstring
one of: num_ref, num_alt, total_depth
- Returns:
- column namestring
- default_column_format = '{source}_count_{allele_group}'
- name = 'read evidence'
varlens.variants_util module
- varlens.variants_util.load_as_dataframe(filename, loader=None, name=None, genome=None, max_variants=None, only_passing=True, metadata_column_prefix='')[source]
- varlens.variants_util.load_from_args_as_dataframe(args)[source]
Given parsed variant-loading arguments, return a pandas DataFrame.
If no variant loading arguments are specified, return None.