Example #1
0
    def test__save_tabular(self):
        ''' check that _save_tabular() works correctly
        '''

        temp = tempfile.NamedTemporaryFile(suffix='.txt',
                                           dir=self.temp_dir,
                                           delete=False)
        report = Report(temp.name, None, None)

        var = (self.variants[0], ["single_variant"], ["Monoallelic"], ["TEST"])
        var[0].child.format['GQ'] = 40
        _save_tabular(temp.name, [var], self.trio)

        with open(temp.name, 'r') as handle:
            lines = handle.readlines()

        expected = [
            'proband\tsex\tchrom\tposition\tgene\t'
            'mutation_ID\ttranscript\tconsequence\tref/alt_alleles\tMAX_MAF\t'
            'inheritance\ttrio_genotype\tmom_aff\tdad_aff\tresult\tpp_dnm\t'
            'exac_allele_count\tGQ\thas_parents\tcnv_length\n',
            'child\tF\tX\t150\tTEST\tNA\tNA\t'
            'missense_variant\tA/G\t0.0005\tMonoallelic\t1/0/0\t1\t1\t'
            'single_variant\t0.99\tNA\t40\tTrue\tNA\n'
        ]

        self.assertEqual(lines, expected)
Example #2
0
    def setUp(self):
        """ define a family and variant, and start the Allosomal class
        """

        # generate a test family
        child_gender = "F"
        mom_aff = "1"
        dad_aff = "1"

        self.trio = self.create_family(child_gender, mom_aff, dad_aff)

        # generate a test variant
        child = create_snv(child_gender,
                           "0/1",
                           chrom='X',
                           pos=150,
                           extra_info='HGNC=TEST;MAX_AF=0.0005')
        mom = create_snv("F", "0/0", chrom='X', pos=150)
        dad = create_snv("M", "0/0", chrom='X', pos=150)

        self.variants = [TrioGenotypes('X', '150', child, mom, dad)]

        self.report = Report(None, None, None)
        Info.set_populations([
            "AFR_AF", "AMR_AF", "ASN_AF", "DDD_AF", "EAS_AF", "ESP_AF",
            "EUR_AF", "MAX_AF", "SAS_AF", "UK10K_cohort_AF"
        ])
    def __init__(self, opts):
        """intialise the class with the some definitions
        """

        self.set_definitions(opts)
        self.report = Report(self.output_path, self.export_vcf, self.ID_mapper,
                             self.known_genes_date)
Example #4
0
    def __init__(self, population_tags=None, count=0, known_genes=None, date=None,
            regions=None, lof_sites=None, pp_filter=0.0, sum_x_lr2_file=None,
            output_path=None, export_vcf=None, debug_chrom=None, debug_pos=None):
        """ initialise the class object
        
        Args:
            population_tags: list of population ID tags, that could exist within
                the INFO field, or None.
            count: number of probands to analyse, helpful for tracking progress
                in output logs.
            known_genes: path to table of genes genes known to be associated
                with genetic disorders, or None.
            date: date of the known_genes file, or None if not using/unknown.
            regions: path to a table of regions for DECIPHER CNV syndromes.
            lof_sites: path to json file of [chrom, position] coordinates in
                genome, for modifying to a loss-of-function consequence if
                required. Can be None if unneeded.
            pp_filter: threshold from 0 to 1 for pp_dnm value to filter out
                candidiate DNMs which fall below this value
            sum_x_lr2_file: File containing sum of l2r values on x chromosome 
                for each person
            output_path: path to write output tab-separated file to
            export_vcf: path to file or folder to write VCFs to.
            debug_chrom: chromosome for debugging purposes.
            debug_pos: position for debugging variant filtering at.
        """
        
        self.pp_filter = pp_filter
        self.total = count
        self.count = 0
        
        self.populations = population_tags
        self.debug_chrom = debug_chrom
        self.debug_pos = debug_pos
        
        # open reference datasets, these return None if the paths are None
        self.known_genes = open_known_genes(known_genes)
        self.cnv_regions = open_cnv_regions(regions)
        self.last_base = open_last_base_sites(lof_sites)

        #open file containing sum of mean log 2 ratios on X, returns an empty dict if path is None
        self.sum_x_lr2 = open_x_lr2_file(sum_x_lr2_file)
        
        self.reporter = Report(output_path, export_vcf, date)
    def setUp(self):
        """ define a family and variant, and start the Allosomal class
        """

        # generate a test family
        child_gender = "F"
        mom_aff = "1"
        dad_aff = "1"

        self.trio = self.create_family(child_gender, mom_aff, dad_aff)

        # generate a test variant
        child_var = self.create_snv(child_gender, "0/1")
        mom_var = self.create_snv("F", "0/0")
        dad_var = self.create_snv("M", "0/0")

        var = TrioGenotypes(child_var)
        var.add_mother_variant(mom_var)
        var.add_father_variant(dad_var)
        self.variants = [var]

        self.report = Report(None, None, None, None)
        self.report.family = self.trio