Пример #1
0
 def R_trim(self, outfile_R_ori, outfile_R):
     cldict = self.cldict
     trim_script = cldict.trim_script
     trim_cmd = trim_script + " " + outfile_R_ori
     print("trim_cmd: " + trim_cmd + ", outfile_R: " + outfile_R)
     exe_command(trim_cmd, outfile_R)
     return
Пример #2
0
    def gen_sam_single_bwamem(self, sample_id, ref_acc, read_file, outdir):
        cldict = self.cldict
        ldelim = cldict.ldelim
        bwa_path = cldict.bwa_path
        patho_path = self.get_patho_ref_path(ref_acc)
        # bwa mem ref.fa reads.fq > aln-se.sam

        bwamem_cmd = bwa_path + " mem " + patho_path + " " + read_file
        print("Aligning with bwa mem: " + bwamem_cmd)
        outsamfile = outdir + ldelim + sample_id + "_" + ref_acc + ".sam"
        exe_command(bwamem_cmd, outsamfile)
        return outsamfile
Пример #3
0
    def sample_to_sai(self, outdir, sample_id, ref_acc, suf, read_file,
                      patho_path):

        cldict = self.cldict
        ldelim = cldict.ldelim
        bwa_path = cldict.bwa_path

        R_sai = outdir + ldelim + sample_id + "_" + ref_acc + "_" + suf + ".sai"
        read_cmd = bwa_path + " aln " + patho_path + " " + read_file
        print("bwa aln cmd: " + read_cmd)
        exe_command(read_cmd, R_sai)
        print("bwa aln cmd done.")
        return R_sai
Пример #4
0
    def gen_sam_single(self, sample_id, ref_acc, read_file, suf, outdir):
        cldict = self.cldict
        ldelim = cldict.ldelim
        bwa_path = cldict.bwa_path
        samtools_path = cldict.samtools
        patho_path = self.get_patho_ref_path(ref_acc)
        R_sai = self.sample_to_sai(outdir, sample_id, ref_acc, suf, read_file,
                                   patho_path)

        sampecmd = bwa_path + " samse " + patho_path + " " + R_sai + " " + read_file
        print("sampe cmd: " + sampecmd)
        outsamfile = outdir + ldelim + sample_id + "_" + ref_acc + ".sam"
        exe_command(sampecmd, outsamfile)
        print("sampe cmd done.")
        os.remove(R_sai)
        print("removed " + R_sai)
        return outsamfile
Пример #5
0
    def gen_sam_paired(self, sample_id, ref_acc, read1_file, read2_file, suf1,
                       suf2, outdir):
        cldict = self.cldict
        ldelim = cldict.ldelim
        bwa_path = cldict.bwa_path
        samtools_path = cldict.samtools
        patho_path = self.get_patho_ref_path(ref_acc)

        R1_sai = self.sample_to_sai(outdir, sample_id, ref_acc, suf1,
                                    read1_file, patho_path)
        R2_sai = self.sample_to_sai(outdir, sample_id, ref_acc, suf2,
                                    read2_file, patho_path)

        sampecmd = bwa_path + " sampe " + patho_path + " " + R1_sai + " " + R2_sai +\
            " " + read1_file + " " + read2_file
        outsamfile = outdir + ldelim + sample_id + "_" + ref_acc + ".sam"
        print("bwa sampe cmd: " + sampecmd)
        exe_command(sampecmd, outsamfile)
        print("bwa sampe cmd done.")
        os.remove(R1_sai)
        os.remove(R2_sai)
        return outsamfile
Пример #6
0
 def sam_to_bam(samtools_path, outsamfile, outbamfile):
     bamcmd = samtools_path + ' view -b -S ' + outsamfile
     print("sam to bam cmd: " + bamcmd)
     exe_command(bamcmd, outbamfile)
     print("sam to bam cmd done.")
Пример #7
0
def bam_to_sam(samtools_path, outbamfile, outsamfile):
    samcmd = samtools_path + ' view -h ' + outbamfile
    print("Converting bam to sam: " + outbamfile)
    print("samcmd: " + samcmd)
    exe_command(samcmd, outsamfile)
Пример #8
0
def sam_to_bam(samtools_path, outsamfile, outbamfile):
	bamcmd = samtools_path + ' view -b -S ' + outsamfile
	exe_command(bamcmd, outbamfile)