phe.variant¶
Submodules¶
Module contents¶
Classes and methods to work with _variants and such.
Implementing Variant Caller¶
Similarly to Implementing Mapper and Implementing Filter
adding your variant caller is easy and sraight forward. Implement
VariantCaller
class with the following attributes/methods:
VariantCaller.name
- Name of your variant caller, used to dynamically load it.VariantCaller.make_vcf()
- Create a VCF from input BAM. SeeVariantCaller.make_vcf()
for input list.VariantCaller.get_version()
- Return the version of this variant caller.VariantCaller.get_info()
- Return information about this caller and included in the VCF header.VariantCaller.create_aux_files()
- Create auxilliary files needed by the caller. Also used in phenix.
Save your new variant caller in the variant directiry and it will be automatically picked up by the system. To verify run:
run_snp_pipeline.py --help
It should appear in the list of available callers.
Date: | 22 Sep, 2015 |
---|---|
Modified: | 04 September, 2018 |
Author: | Alex Jironkin |
-
class
VCFTemplate
(vcf_reader)[source]¶ Bases:
object
This is a small hack class for the Template used in generating VCF file.
-
class
VariantCaller
(cmd_options=None)[source]¶ Bases:
phe.metadata.PHEMetaData
Abstract class used for access to the implemented variant callers.
Methods
create_aux_files
(ref)Create needed (if any) auxiliary files. get_info
([plain])Get information about this variant caller. get_meta
()Get the metadata about this variant caller. get_version
()Get the version of the underlying command used. make_vcf
(*args, **kwargs)Create a VCF from BAM file. validate
()Check if the command can run. -
create_aux_files
(ref)[source]¶ Create needed (if any) auxiliary files. These files are required for proper functioning of the variant caller.
-
make_vcf
(*args, **kwargs)[source]¶ Create a VCF from BAM file.
Parameters: - ref: str
Path to the reference file.
- bam: str
Path to the indexed BAM file for calling _variants.
- vcf_file: str
path to the VCF file where data will be written to.
- make_aux: bool, optional
True/False create auxilliary files (default: False).
Returns: - bool:
True if variant calling was successful, False otherwise.
-
-
class
VariantSet
(vcf_in, filters=None, reference=None)[source]¶ Bases:
object
A convenient representation of set of _variants. TODO: Implement iterator and generator for the variant set.
Methods
add_metadata
(info)Add metadata to the variant set. filter_variants
([keep_only_snps, only_good])Filter the VCF records. variants
([only_good])Generator over the variant set. write_to_json
(vcf_file_name[, verbose])Write _variants to a json file. write_variants
(vcf_out[, only_snps, only_good])Write _variants to a VCF file. -
add_metadata
(info)[source]¶ Add metadata to the variant set.
Parameters: - info: dict
Dictionary of key value pairs to be inserted into metadata.
-
filter_variants
(keep_only_snps=False, only_good=False)[source]¶ Filter the VCF records.
Parameters: - keep_only_snps: bool, optional
Retain only SNP variants (default: False).
- only_good: bool, optional
True/False if only SNPs that PASS should output.
Returns: - list of records is returned.
-
variants
(only_good=False)[source]¶ Generator over the variant set.
Parameters: - only_good: bool, optional
Iff True good and bad variants are returned, otherwise only good are returned (default: False).
-
write_variants
(vcf_out, only_snps=False, only_good=False)[source]¶ Write _variants to a VCF file.
Parameters: - vcf_out: str
Path to the file where VCF data is written.
- only_snps: bool, optional
True is only SNP are to be written to the output (default: False).
- only_good: bool, optional
True if only those records that PASS all filters should be written (default: False).
- Returns:
- int:
Number of records written.
-