deltamax=deltamax)
            consm = np.fromstring(cons, 'S1')

            if VERBOSE >= 2:
                print 'Reference length:', len_reference, 'consensus:', len(cons),
                if len_reference != len(cons):
                    from seqanpy import align_local
                    (score, ali1, ali2) = align_local(''.join(refseq), cons)
                    alim1 = np.fromstring(ali1, 'S1')
                    alim2 = np.fromstring(ali2, 'S1')
                    n_diff = (alim1 != alim2).sum()
                    print 'overlap', len(alim1), 'n diffs.', n_diff
                else:
                    n_diff = (refm != consm).sum()
                    print 'n diffs.', n_diff

            if save_to_file:
                if VERBOSE >= 2:
                    print 'Save to file'

                fn_out = sample.get_consensus_filename(fragment, PCR=PCR)
                consrec = SeqRecord(Seq(cons, ambiguous_dna),
                                    id=samplename+'_consensus',
                                    name=samplename+'_consensus',
                                    description=samplename+', consensus',
                                   )
                SeqIO.write(consrec, fn_out, 'fasta')

            if VERBOSE == 1:
                print ''
Beispiel #2
0
            if VERBOSE >= 2:
                print 'Reference length:', len_reference, 'consensus:', len(
                    cons),
                if len_reference != len(cons):
                    from seqanpy import align_local
                    (score, ali1, ali2) = align_local(''.join(refseq), cons)
                    alim1 = np.fromstring(ali1, 'S1')
                    alim2 = np.fromstring(ali2, 'S1')
                    n_diff = (alim1 != alim2).sum()
                    print 'overlap', len(alim1), 'n diffs.', n_diff
                else:
                    n_diff = (refm != consm).sum()
                    print 'n diffs.', n_diff

            if save_to_file:
                if VERBOSE >= 2:
                    print 'Save to file'

                fn_out = sample.get_consensus_filename(fragment, PCR=PCR)
                consrec = SeqRecord(
                    Seq(cons, ambiguous_dna),
                    id=samplename + '_consensus',
                    name=samplename + '_consensus',
                    description=samplename + ', consensus',
                )
                SeqIO.write(consrec, fn_out, 'fasta')

            if VERBOSE == 1:
                print ''
        try:
            for i in xrange(6):
                fragment = 'F'+str(i+1)
                consensi_pat[fragment] = sample_pat.get_consensus(fragment)

        except IOError:
            if VERBOSE >= 1:
                print 'warning: some consensus not found: skipping'
            continue

        except ValueError:
            if VERBOSE >= 1:
                print 'warning: some consensus is not clean (e.g. contamination): skipping'
            continue

        if VERBOSE >= 1:
            print 'ok: all 6 consensi found'

        consensus =  merge_fragments(consensi_pat, name=sample_pat.patient,
                                     VERBOSE=VERBOSE)

        if len(consensus) < 8800:
            print 'WARNING: the consensus looks too short!'

        if use_save:
            output_filename = sample_pat.get_consensus_filename('genomewide')
            SeqIO.write(consensus, output_filename, 'fasta')
            if VERBOSE >= 1:
                print 'Genomewide consensus written'

Beispiel #4
0
        try:
            for i in xrange(6):
                fragment = 'F' + str(i + 1)
                consensi_pat[fragment] = sample_pat.get_consensus(fragment)

        except IOError:
            if VERBOSE >= 1:
                print 'warning: some consensus not found: skipping'
            continue

        except ValueError:
            if VERBOSE >= 1:
                print 'warning: some consensus is not clean (e.g. contamination): skipping'
            continue

        if VERBOSE >= 1:
            print 'ok: all 6 consensi found'

        consensus = merge_fragments(consensi_pat,
                                    name=sample_pat.patient,
                                    VERBOSE=VERBOSE)

        if len(consensus) < 8800:
            print 'WARNING: the consensus looks too short!'

        if use_save:
            output_filename = sample_pat.get_consensus_filename('genomewide')
            SeqIO.write(consensus, output_filename, 'fasta')
            if VERBOSE >= 1:
                print 'Genomewide consensus written'