Exemplo n.º 1
0
class Contig:
    def __init__(self, name):
        self.name = name
        self.sequence = None
        self.parent = None
        self.splits = []
        self.length = 0
        self.abundance = 0.0
        self.coverage = Coverage()

        self.min_coverage_for_variability = 10
        self.skip_SNV_profiling = False
        self.report_variability_full = False
        self.ignore_orphans = False
        self.max_coverage_depth = constants.max_depth_for_coverage
        self.codon_frequencies_dict = {}


    def get_atomic_data_dict(self):
        d = {'std_coverage': self.coverage.std,
             'mean_coverage': self.coverage.mean,
             'mean_coverage_Q2Q3': self.coverage.mean_Q2Q3,
             'max_normalized_ratio': 1.0,
             'relative_abundance': 1.0,
             'detection': self.coverage.detection,
             'abundance': self.abundance,
             'variability': sum(s.auxiliary.variation_density for s in self.splits) if not self.skip_SNV_profiling else None,
             '__parent__': None}

        return d


    def analyze_coverage(self, bam):
        contig_coverage = []

        counter = 1
        for split in self.splits:
            split.coverage = Coverage()
            split.coverage.run(bam, split, 
                            ignore_orphans=self.ignore_orphans, 
                            max_coverage_depth=self.max_coverage_depth)
            contig_coverage.extend(split.coverage.c)

            counter += 1

        self.coverage.process_c(contig_coverage)


    def analyze_auxiliary(self, bam):
        counter = 1
        for split in self.splits:
            split.auxiliary = Auxiliary(split,
                                        bam,
                                        parent_outlier_positions=self.coverage.outlier_positions,
                                        min_coverage=self.min_coverage_for_variability,
                                        report_variability_full=self.report_variability_full,
                                        ignore_orphans=self.ignore_orphans,
                                        max_coverage_depth=self.max_coverage_depth)

            counter += 1
Exemplo n.º 2
0
class Contig:
    def __init__(self, name):
        self.name = name
        self.sequence = None
        self.parent = None
        self.splits = []
        self.length = 0
        self.abundance = 0.0
        self.coverage = Coverage()

        self.min_coverage_for_variability = 10
        self.report_variability_full = False


    def get_atomic_data_dict(self):
        d = {'std_coverage': self.coverage.std,
             'mean_coverage': self.coverage.mean,
             'normalized_coverage': self.coverage.normalized,
             'max_normalized_ratio': 1.0,
             'relative_abundance': 1.0,
             'portion_covered': self.coverage.portion_covered,
             'abundance': self.abundance,
             'variability': sum(s.auxiliary.variation_density for s in self.splits),
             '__parent__': None}

        return d


    def analyze_coverage(self, bam, progress):
        contig_coverage = []
        num_splits = len(self.splits)
        counter = 1

        for split in self.splits:
            progress.update('Coverage (split: %d of %d)' % (counter, num_splits))

            split.coverage = Coverage()
            split.coverage.run(bam, split)
            contig_coverage.extend(split.coverage.c)

            counter += 1

        self.coverage.process_c(contig_coverage)


    def analyze_auxiliary(self, bam, progress):
        num_splits = len(self.splits)
        counter = 1

        for split in self.splits:
            progress.update('Auxiliary stats (split: %d of %d) CMC: %.1f :: SMC: %.1f'\
                                 % (counter, num_splits, self.coverage.mean, split.coverage.mean))

            split.auxiliary = Auxiliary(split, bam, min_coverage = self.min_coverage_for_variability,
                                        report_variability_full = self.report_variability_full)

            counter += 1
Exemplo n.º 3
0
class Contig:
    def __init__(self, name):
        self.name = name
        self.sequence = None
        self.parent = None
        self.splits = []
        self.length = 0
        self.abundance = 0.0
        self.coverage = Coverage()

        self.min_coverage_for_variability = 10
        self.skip_SNV_profiling = False
        self.report_variability_full = False


    def get_atomic_data_dict(self):
        d = {'std_coverage': self.coverage.std,
             'mean_coverage': self.coverage.mean,
             'mean_coverage_Q2Q3': self.coverage.mean_Q2Q3,
             'max_normalized_ratio': 1.0,
             'relative_abundance': 1.0,
             'detection': self.coverage.detection,
             'abundance': self.abundance,
             'variability': sum(s.auxiliary.variation_density for s in self.splits) if not self.skip_SNV_profiling else None,
             '__parent__': None}

        return d


    def analyze_coverage(self, bam):
        contig_coverage = []

        counter = 1
        for split in self.splits:
            split.coverage = Coverage()
            split.coverage.run(bam, split)
            contig_coverage.extend(split.coverage.c)

            counter += 1

        self.coverage.process_c(contig_coverage)


    def analyze_auxiliary(self, bam):
        counter = 1
        for split in self.splits:
            split.auxiliary = Auxiliary(split,
                                        bam,
                                        parent_outlier_positions=self.coverage.outlier_positions,
                                        min_coverage=self.min_coverage_for_variability,
                                        report_variability_full=self.report_variability_full)

            counter += 1
Exemplo n.º 4
0
class Contig:
    def __init__(self, name):
        self.name = name
        self.parent = None
        self.splits = []
        self.length = 0
        self.abundance = 0.0
        self.coverage = Coverage()

        self.min_coverage_for_variability = 10
        self.report_variability_full = False

    def get_metadata_dict(self):
        d = {
            "std_coverage": self.coverage.std,
            "mean_coverage": self.coverage.mean,
            "normalized_coverage": self.coverage.normalized,
            "max_normalized_ratio": 1.0,
            "relative_abundance": 1.0,
            "portion_covered": self.coverage.portion_covered,
            "abundance": self.abundance,
            "variability": sum(s.auxiliary.variability_score for s in self.splits),
            "__parent__": None,
        }

        return d

    def analyze_coverage(self, bam, progress):
        contig_coverage = []
        for split in self.splits:
            progress.update("Coverage (split: %d of %d)" % (split.order, len(self.splits)))
            split.coverage = Coverage()
            split.coverage.run(bam, split)
            contig_coverage.extend(split.coverage.c)

        self.coverage.process_c(contig_coverage)

    def analyze_auxiliary(self, bam, progress):
        for split in self.splits:
            progress.update(
                "Auxiliary stats (split: %d of %d) CMC: %.1f :: SMC: %.1f"
                % (split.order, len(self.splits), self.coverage.mean, split.coverage.mean)
            )

            split.auxiliary = Auxiliary(
                split,
                bam,
                min_coverage=self.min_coverage_for_variability,
                report_variability_full=self.report_variability_full,
            )
Exemplo n.º 5
0
class Contig:
    def __init__(self, name):
        self.name = name
        self.parent = None
        self.splits = []
        self.length = 0
        self.abundance = 0.0
        self.coverage = Coverage()

        self.min_coverage_for_variability = 10
        self.report_variability_full = False

    def get_atomic_data_dict(self):
        d = {
            'std_coverage': self.coverage.std,
            'mean_coverage': self.coverage.mean,
            'normalized_coverage': self.coverage.normalized,
            'max_normalized_ratio': 1.0,
            'relative_abundance': 1.0,
            'portion_covered': self.coverage.portion_covered,
            'abundance': self.abundance,
            'variability':
            sum(s.auxiliary.variation_density for s in self.splits),
            '__parent__': None
        }

        return d

    def analyze_coverage(self, bam, progress):
        contig_coverage = []
        for split in self.splits:
            progress.update('Coverage (split: %d of %d)' %
                            (split.order, len(self.splits)))
            split.coverage = Coverage()
            split.coverage.run(bam, split)
            contig_coverage.extend(split.coverage.c)

        self.coverage.process_c(contig_coverage)

    def analyze_auxiliary(self, bam, progress):
        for split in self.splits:
            progress.update('Auxiliary stats (split: %d of %d) CMC: %.1f :: SMC: %.1f'\
                                 % (split.order, len(self.splits), self.coverage.mean, split.coverage.mean))

            split.auxiliary = Auxiliary(
                split,
                bam,
                min_coverage=self.min_coverage_for_variability,
                report_variability_full=self.report_variability_full)
Exemplo n.º 6
0
class Contig:
    def __init__(self, name):
        self.name = name
        self.sequence = None
        self.parent = None
        self.splits = []
        self.length = 0
        self.abundance = 0.0
        self.coverage = Coverage()

        self.min_coverage_for_variability = 10
        self.skip_SNV_profiling = False
        self.report_variability_full = False

    def get_atomic_data_dict(self):
        d = {
            'std_coverage':
            self.coverage.std,
            'mean_coverage':
            self.coverage.mean,
            'mean_coverage_Q1Q3':
            self.coverage.mean_Q1Q3,
            'max_normalized_ratio':
            1.0,
            'relative_abundance':
            1.0,
            'portion_covered':
            self.coverage.portion_covered,
            'abundance':
            self.abundance,
            'variability':
            sum(s.auxiliary.variation_density
                for s in self.splits) if not self.skip_SNV_profiling else None,
            '__parent__':
            None
        }

        return d

    def analyze_coverage(self, bam, progress):
        contig_coverage = []
        num_splits = len(self.splits)
        counter = 1

        for split in self.splits:
            progress.update('Coverage (split: %d of %d)' %
                            (counter, num_splits))

            split.coverage = Coverage()
            split.coverage.run(bam, split)
            contig_coverage.extend(split.coverage.c)

            counter += 1

        self.coverage.process_c(contig_coverage)

    def analyze_auxiliary(self, bam, progress):
        num_splits = len(self.splits)
        counter = 1

        for split in self.splits:
            progress.update('Auxiliary stats (split: %d of %d) CMC: %.1f :: SMC: %.1f'\
                                 % (counter, num_splits, self.coverage.mean, split.coverage.mean))

            split.auxiliary = Auxiliary(
                split,
                bam,
                parent_outlier_positions=self.coverage.outlier_positions,
                min_coverage=self.min_coverage_for_variability,
                report_variability_full=self.report_variability_full)

            counter += 1