예제 #1
0
    def run_single(self, input_fastq, tophat_options=[], out_dir=None):
        if out_dir == None:
            out_dir = self.out_dir

        if os.path.exists(out_dir):
            raise ValueError("Output directory %s already exists!" %
                             (out_dir, ))

        os.mkdir(out_dir)

        log_file = os.path.join(out_dir, "tophat.log")

        if len(input_fastq) > 2:
            raise ValueError("Maximum of two reads per sample!")

        phreds = []

        for fq in input_fastq:
            phreds.append(fastq.fastq_phred(fq))

        if len(set(phreds)) <> 1:
            raise ValueError("Multiple quality types in reads")
        else:
            phred_ver = phreds[0]

        if phred_ver == 64:
            phred_param = ["--phred64-quals"]
        elif phred_ver == 59:
            phred_param = ["--solexa-quals"]
        elif phred_ver == 33:
            phred_param = []
        else:
            raise ValueError("Unrecognized phred version")

        with open(log_file, "w") as log_fp:
            tophat_cmd = [_common.TOPHAT_PATH,
                          "-p", str(self.num_threads),
                          "-o", out_dir,
                          "-z", "none"] + \
                          phred_param + \
                          map(str, tophat_options) + \
                          [self.bowtie_index] + \
                          input_fastq

            log_fp.write(" ".join(tophat_cmd) + "\n\n")
            log_fp.flush()

            tophat_proc = subprocess.Popen(tophat_cmd, stderr=log_fp)

            while tophat_proc.poll() == None:
                time.sleep(1)

        if os.path.exists(os.path.join(out_dir, "junctions.bed")):
            return True
        else:
            return False
예제 #2
0
파일: tophat.py 프로젝트: polyatail/lincrna
    def run_single(self, input_fastq, tophat_options = [], out_dir = None):
        if out_dir == None:
            out_dir = self.out_dir

        if os.path.exists(out_dir):
            raise ValueError("Output directory %s already exists!" % (out_dir,))

        os.mkdir(out_dir)

        log_file = os.path.join(out_dir, "tophat.log")

        if len(input_fastq) > 2:
            raise ValueError("Maximum of two reads per sample!")
    
        phreds = []
        
        for fq in input_fastq:
            phreds.append(fastq.fastq_phred(fq))

        if len(set(phreds)) <> 1:
            raise ValueError("Multiple quality types in reads")
        else:
            phred_ver = phreds[0]
        
        if phred_ver == 64:
            phred_param = ["--phred64-quals"]
        elif phred_ver == 59:
            phred_param = ["--solexa-quals"]
        elif phred_ver == 33:
            phred_param = []
        else:
            raise ValueError("Unrecognized phred version")
        
        with open(log_file, "w") as log_fp:
            tophat_cmd = [_common.TOPHAT_PATH,
                          "-p", str(self.num_threads),
                          "-o", out_dir,
                          "-z", "none"] + \
                          phred_param + \
                          map(str, tophat_options) + \
                          [self.bowtie_index] + \
                          input_fastq
                                            
            log_fp.write(" ".join(tophat_cmd) + "\n\n")
            log_fp.flush()
            
            tophat_proc = subprocess.Popen(tophat_cmd, stderr=log_fp)
                                            
            while tophat_proc.poll() == None:
                time.sleep(1)
            
        if os.path.exists(os.path.join(out_dir, "junctions.bed")):
            return True
        else:
            return False
예제 #3
0
    def testPhredVersion(self):
        # version 1.4 tests
        result = fastq.fastq_phred("./pooled_tophat/v14_p_subset-left.fastq")
        self.assertEqual(result, 64)

        result = fastq.fastq_phred("./pooled_tophat/v14_p_subset-right.fastq")
        self.assertEqual(result, 64)

        result = fastq.fastq_phred("./pooled_tophat/v14_s_subset.fastq")
        self.assertEqual(result, 64)
            
        # version 1.8 tests
        result = fastq.fastq_phred("./pooled_tophat/v18_p_subset-left.fastq")
        self.assertEqual(result, 33)

        result = fastq.fastq_phred("./pooled_tophat/v18_p_subset-right.fastq")
        self.assertEqual(result, 33)

        result = fastq.fastq_phred("./pooled_tophat/v18_s_subset.fastq")
        self.assertEqual(result, 33)
예제 #4
0
    def testPhredVersion(self):
        # version 1.4 tests
        result = fastq.fastq_phred("./pooled_tophat/v14_p_subset-left.fastq")
        self.assertEqual(result, 64)

        result = fastq.fastq_phred("./pooled_tophat/v14_p_subset-right.fastq")
        self.assertEqual(result, 64)

        result = fastq.fastq_phred("./pooled_tophat/v14_s_subset.fastq")
        self.assertEqual(result, 64)

        # version 1.8 tests
        result = fastq.fastq_phred("./pooled_tophat/v18_p_subset-left.fastq")
        self.assertEqual(result, 33)

        result = fastq.fastq_phred("./pooled_tophat/v18_p_subset-right.fastq")
        self.assertEqual(result, 33)

        result = fastq.fastq_phred("./pooled_tophat/v18_s_subset.fastq")
        self.assertEqual(result, 33)