print ''

            if submit:
                fork_self(samplename, fragment, VERBOSE=VERBOSE, PCR=PCR,
                          block_len=block_len, n_reads_per_ali=n_reads_per_ali)
                continue

            sample = SamplePat(sample)
            pname = sample.patient
            refseq = SeqIO.read(get_initial_reference_filename(pname, fragment), 'fasta')
            refm = np.array(refseq)
            len_reference = len(refseq)

            # NOTE: we need consensi to decontaminate, so
            bamfilename = sample.get_mapped_filtered_filename(fragment,
                                            PCR=PCR,
                                            decontaminated=(not use_raw_reads))
            if not os.path.isfile(bamfilename):
                continue
            
            if VERBOSE >= 1:
                print 'PCR', PCR,
                if VERBOSE >= 2:
                    print ''

            cons = build_consensus(bamfilename, len_reference, VERBOSE=VERBOSE,
                                   block_len=block_len,
                                   reads_per_alignment=n_reads_per_ali,
                                   deltamax=deltamax)
            consm = np.fromstring(cons, 'S1')
    if not fragments:
        fragments = ['F' + str(i) for i in xrange(1, 7)]
    if VERBOSE >= 3:
        print 'fragments', fragments

    if submit:
        for fragment in fragments:
            for samplename, sample in samples_focal.iterrows():

                sample = SamplePat(sample)
                if PCR is None:
                    PCRs_sample = (1, 2)
                else:
                    PCRs_sample = [PCR]
                for PCR_sample in PCRs_sample:
                    bamfilename = sample.get_mapped_filtered_filename(
                        fragment, PCR=PCR_sample, decontaminated=False)
                    if not os.path.isfile(bamfilename):
                        continue

                    #if check_already_decontaminated(sample, fragment, PCR_sample):
                    #    continue

                    fork_self(samplename,
                              fragment,
                              VERBOSE=VERBOSE,
                              maxreads=maxreads,
                              summary=summary,
                              PCR=PCR_sample)

        sys.exit()
    if not fragments:
        fragments = ["F" + str(i) for i in xrange(1, 7)]
    if VERBOSE >= 3:
        print "fragments", fragments

    if submit:
        for fragment in fragments:
            for samplename, sample in samples_focal.iterrows():

                sample = SamplePat(sample)
                if PCR is None:
                    PCRs_sample = (1, 2)
                else:
                    PCRs_sample = [PCR]
                for PCR_sample in PCRs_sample:
                    bamfilename = sample.get_mapped_filtered_filename(fragment, PCR=PCR_sample, decontaminated=False)
                    if not os.path.isfile(bamfilename):
                        continue

                    # if check_already_decontaminated(sample, fragment, PCR_sample):
                    #    continue

                    fork_self(samplename, fragment, VERBOSE=VERBOSE, maxreads=maxreads, summary=summary, PCR=PCR_sample)

        sys.exit()

    for fragment in fragments:
        consensi = {refname: "".join(load_custom_reference(refname + "_" + fragment)) for refname in refnames}
        for samplename, sample in samples.iterrows():
            sample = SamplePat(sample)
            try:
Beispiel #4
0
                          fragment,
                          VERBOSE=VERBOSE,
                          PCR=PCR,
                          block_len=block_len,
                          n_reads_per_ali=n_reads_per_ali)
                continue

            sample = SamplePat(sample)
            pname = sample.patient
            refseq = SeqIO.read(
                get_initial_reference_filename(pname, fragment), 'fasta')
            refm = np.array(refseq)
            len_reference = len(refseq)

            # NOTE: we need consensi to decontaminate, so
            bamfilename = sample.get_mapped_filtered_filename(
                fragment, PCR=PCR, decontaminated=(not use_raw_reads))
            if not os.path.isfile(bamfilename):
                continue

            if VERBOSE >= 1:
                print 'PCR', PCR,
                if VERBOSE >= 2:
                    print ''

            cons = build_consensus(bamfilename,
                                   len_reference,
                                   VERBOSE=VERBOSE,
                                   block_len=block_len,
                                   reads_per_alignment=n_reads_per_ali,
                                   deltamax=deltamax)
            consm = np.fromstring(cons, 'S1')