for fragment in fragments:
        inses = []
        for samplename, sample in samples.iterrows():
            if submit:
                fork_self(samplename, fragment, VERBOSE=VERBOSE, qual_min=qual_min)
                continue

            if VERBOSE >= 1:
                print fragment, samplename

            sample = SamplePat(sample)
            pname = sample.patient
            refseq = SeqIO.read(get_initial_reference_filename(pname, fragment), 'fasta')

            fn = sample.get_mapped_filtered_filename(fragment, PCR=PCR)
            if not os.path.isfile(fn):
                warn('No BAM file found', NoDataWarning)
                continue

            _, inse = gac(fn, len(refseq), qual_min=qual_min, VERBOSE=VERBOSE)
            inses.append(inse)

            if save_to_file:
                fn_out = sample.get_insertions_filename(fragment, PCR=PCR,
                                                        qual_min=qual_min)
                save_insertions(fn_out, inse)

                if VERBOSE >= 2:
                    print 'Insertions saved:', samplename, fragment
Beispiel #2
0
                fork_self(samplename,
                          fragment,
                          VERBOSE=VERBOSE,
                          qual_min=qual_min)
                continue

            if VERBOSE >= 1:
                print fragment, samplename

            sample = SamplePat(sample)
            pname = sample.patient
            refseq = SeqIO.read(
                get_initial_reference_filename(pname, fragment), 'fasta')

            fn = sample.get_mapped_filtered_filename(fragment, PCR=PCR)
            if not os.path.isfile(fn):
                warn('No BAM file found', NoDataWarning)
                continue

            _, inse = gac(fn, len(refseq), qual_min=qual_min, VERBOSE=VERBOSE)
            inses.append(inse)

            if save_to_file:
                fn_out = sample.get_insertions_filename(fragment,
                                                        PCR=PCR,
                                                        qual_min=qual_min)
                save_insertions(fn_out, inse)

                if VERBOSE >= 2:
                    print 'Insertions saved:', samplename, fragment
Beispiel #3
0
                    end -= rf

                fn = sample.get_mapped_filtered_filename(fragment,
                                                         PCR=PCR,
                                                         decontaminated=True)

                if not os.path.isfile(fn):
                    if VERBOSE >= 2:
                        print 'SKIP'
                    continue

                if VERBOSE >= 2:
                    print 'Get allele counts for amino acids'
                cou = gac(fn,
                          start_fr,
                          end_fr,
                          qual_min=qual_min,
                          VERBOSE=VERBOSE)
                # We do not care about fwd/reverse
                count[:, start // 3:end // 3] = cou.sum(axis=0)

            counts.append(count)

            if save_to_file:
                if VERBOSE >= 2:
                    print 'Save allele counts:', samplename, protein
                count.dump(fn_out)

            if use_plot:
                if VERBOSE >= 2:
                    print 'Plot'
    for fragment in fragments:
        counts = []
        for samplename, sample in samples.iterrows():
            if submit:
                fork_self(samplename, fragment, VERBOSE=VERBOSE, qual_min=qual_min)
                continue

            if VERBOSE >= 1:
                print fragment, samplename

            sample = SamplePat(sample)
            pname = sample.patient
            refseq = SeqIO.read(get_initial_reference_filename(pname, fragment), 'fasta')

            fn = sample.get_mapped_filtered_filename(fragment, PCR=PCR)
            if not os.path.isfile(fn):
                warn('No BAM file found', NoDataWarning)
                continue

            count, _ = gac(fn, len(refseq), qual_min=qual_min, VERBOSE=VERBOSE)
            counts.append(count)

            if save_to_file:
                fn_out = sample.get_allele_counts_filename(fragment, PCR=PCR,
                                                           qual_min=qual_min)
                count.dump(fn_out)

                if VERBOSE >= 2:
                    print 'Allele counts saved:', samplename, fragment
                fork_self(samplename,
                          fragment,
                          VERBOSE=VERBOSE,
                          qual_min=qual_min)
                continue

            if VERBOSE >= 1:
                print fragment, samplename

            sample = SamplePat(sample)
            pname = sample.patient
            refseq = SeqIO.read(
                get_initial_reference_filename(pname, fragment), 'fasta')

            fn = sample.get_mapped_filtered_filename(fragment, PCR=PCR)
            if not os.path.isfile(fn):
                warn('No BAM file found', NoDataWarning)
                continue

            count, _ = gac(fn, len(refseq), qual_min=qual_min, VERBOSE=VERBOSE)
            counts.append(count)

            if save_to_file:
                fn_out = sample.get_allele_counts_filename(fragment,
                                                           PCR=PCR,
                                                           qual_min=qual_min)
                count.dump(fn_out)

                if VERBOSE >= 2:
                    print 'Allele counts saved:', samplename, fragment
                rf = end % 3
                if rf:
                    end_fr -= rf
                    end -= rf
                               
                fn = sample.get_mapped_filtered_filename(fragment, PCR=PCR,
                                                         decontaminated=True)
                
                if not os.path.isfile(fn):
                    if VERBOSE >= 2:
                        print 'SKIP'
                    continue
                
                if VERBOSE >= 2:
                    print 'Get allele counts for amino acids'
                cou = gac(fn, start_fr, end_fr, qual_min=qual_min,
                          VERBOSE=VERBOSE)
                # We do not care about fwd/reverse
                count[:, start // 3: end // 3] = cou.sum(axis=0)

            counts.append(count)

            if save_to_file:
                if VERBOSE >= 2:
                    print 'Save allele counts:', samplename, protein
                count.dump(fn_out)

            if use_plot:
                if VERBOSE >= 2:
                    print 'Plot'
                cou = count.sum(axis=0)
                x = np.tile(np.arange(cou.shape[1]), (cou.shape[0], 1))