Beispiel #1
0
 def _get_mh_obj(genotype_row):
     ret_mh_obj = Microhaplotype()
     ret_mh_obj.name = str(genotype_row['Locus'])
     ret_mh_obj.number_of_alleles = int(genotype_row['Allele Count'])
     ret_mh_obj.number_of_contributors = int(
         genotype_row['Min Contributors'])
     return ret_mh_obj
Beispiel #2
0
 def _get_mh_obj(self, single_microhap_dict):
     ret_mh_obj = Microhaplotype()
     ret_mh_obj.name = single_microhap_dict['locus']
     ret_mh_obj.ae = float(single_microhap_dict['avgAe'])
     ret_mh_obj.prob_det_mix = float(single_microhap_dict['probOfDetMix'])
     ret_mh_obj.number_of_alleles = int(
         single_microhap_dict['numOfAlleles'])
     ret_mh_obj.number_of_contributors = int(
         single_microhap_dict['numOfCont'])
     ret_mh_obj.analytical_threshold = int(
         single_microhap_dict['minCoverage'])
     ret_mh_obj.snps_rsid_list = '/'.join(single_microhap_dict['snps'])
     ret_mh_obj.alleles = self._get_alleles(single_microhap_dict['profile'])
     return ret_mh_obj
Beispiel #3
0
 def _get_mh_obj(self, mh_single_line_dict):
     """ Get an object of class Microhaplotype populated with its attributes.
     :param mh_single_line_dict: A csv.DictReader dict of a single mh txt file line
     :return: An object of class Microhaplotype
     """
     ret_mh_obj = Microhaplotype()
     ret_mh_obj.name = mh_single_line_dict['MarkerId']
     ret_mh_obj.ae = float(mh_single_line_dict['AvgAe'])
     ret_mh_obj.prob_det_mix = float(mh_single_line_dict['ProbOfDetMix'])
     ret_mh_obj.number_of_alleles = int(mh_single_line_dict['NumOfAlleles'])
     ret_mh_obj.number_of_contributors = int(
         mh_single_line_dict['NumOfContributors'])
     ret_mh_obj.analytical_threshold = int(
         mh_single_line_dict['MinimumCoverage'])
     ret_mh_obj.snps_rsid_list = mh_single_line_dict['SNPs']
     ret_mh_obj.alleles = self._get_alleles(
         mh_single_line_dict['AlleleCoverageDetail(-strand:+strand:avgMQ)'])
     return ret_mh_obj
Beispiel #4
0
    def _get_mh_count(self):
        bam_file_obj = pysam.AlignmentFile(self.bam, 'rb')
        for mh_name in self.bed_obj.bed_dict.keys():

            self.mh_dict.setdefault(mh_name, Microhaplotype(name=mh_name))
            mh_number_of_bases_targeted = len(self.bed_obj.bed_dict[mh_name])

            for chromosome, start_position in self.bed_obj.bed_dict[mh_name]:
                self.mh_dict[mh_name].process_overlapping_reads(chromosome, start_position, bam_file_obj)

            reads_processed, short_reads = self.mh_dict[mh_name].get_alleles(mh_number_of_bases_targeted)
            self.total_reads_count += reads_processed
            self.short_reads_count += short_reads
            self.mh_dict[mh_name].calculate_avg_mapping_quality()
            self.mh_dict[mh_name].calculate_total_coverage()
            self.mh_dict[mh_name].filter_alleles(self.filters_obj)
            if self.info:
                self.info_obj.add_info(self.mh_dict[mh_name])
Beispiel #5
0
def microhap_obj():
    from microhaplotype import Microhaplotype
    return Microhaplotype(name='mitotrial-001')