def test_combine(self): cft.Gff3Parser = Mock_Gff_parser output_file = os.path.join(self.test_folder, "test.out") frag_file = os.path.join(self.test_folder, "frag.gff") tex_file = os.path.join(self.test_folder, "tex.gff") with open(frag_file, "w") as fh: fh.write("frag") with open(tex_file, "w") as th: th.write("tex") cft.combine(frag_file, tex_file, 5, output_file) trans = [] outs, attributes_out = extract_info(output_file, "file") refs, attributes_ref = extract_info(self.example.out_tran, "string") self.assertEqual(set(outs), set(refs[1:]))
def _for_two_wigs(self, strains, args_tran, log): '''merge the results of fragemented and tex treated libs''' if (args_tran.frag_wigs is not None) and ( args_tran.tex_wigs is not None): log.write("Running combine_frag_tex.py to merge the results from " "fragmented libs and dRNA-Seq libs.\n") print("Merging fragmented and tex treated ones") for strain in strains: frag_gff = os.path.join(self.gff_outfolder, "_".join([strain, self.frag])) tex_gff = os.path.join(self.gff_outfolder, "_".join([strain, self.tex])) final_gff = os.path.join(self.gff_outfolder, "_".join([strain, self.endfix_tran])) for gff in os.listdir(self.gff_outfolder): if "_transcript_" in gff: filename = gff.split("_transcript_") if (strain == filename[0]) and ( "tex_notex.gff" == filename[1]): tex_file = gff elif (strain == filename[0]) and ( "fragment.gff" == filename[1]): frag_file = gff combine(os.path.join(self.gff_outfolder, frag_file), os.path.join(self.gff_outfolder, tex_file), args_tran.tolerance, os.path.join(self.gff_outfolder, "_".join([strain, self.endfix_tran]))) os.remove(frag_gff) os.remove(tex_gff) log.write("\t" + final_gff + " is generated.\n") else: if args_tran.frag_wigs is not None: for strain in strains: frag_gff = os.path.join( self.gff_outfolder, "_".join([strain, self.frag])) final_gff = os.path.join( self.gff_outfolder, "_".join([strain, self.endfix_tran])) shutil.move(frag_gff, final_gff) log.write("\t" + final_gff + " is generated.\n") elif args_tran.tex_wigs is not None: for strain in strains: tex_gff = os.path.join( self.gff_outfolder, "_".join([strain, self.tex])) final_gff = os.path.join( self.gff_outfolder, "_".join([strain, self.endfix_tran])) shutil.move(tex_gff, final_gff) log.write("\t" + final_gff + " is generated.\n")
def _for_two_wigs(self, strains, args_tran): '''merge the results of fragemented and tex treated libs''' if (args_tran.frag_wigs is not None) and (args_tran.tex_wigs is not None): print("Merging fragment and tex treat one") for strain in strains: frag_gff = os.path.join(self.gff_outfolder, "_".join([strain, self.frag])) tex_gff = os.path.join(self.gff_outfolder, "_".join([strain, self.tex])) final_gff = os.path.join(self.gff_outfolder, "_".join([strain, self.endfix_tran])) for gff in os.listdir(self.gff_outfolder): if "_transcript_" in gff: filename = gff.split("_transcript_") if (strain == filename[0]) and ("tex_notex.gff" == filename[1]): tex_file = gff elif (strain == filename[0]) and ("fragment.gff" == filename[1]): frag_file = gff combine( os.path.join(self.gff_outfolder, frag_file), os.path.join(self.gff_outfolder, tex_file), args_tran.tolerance, os.path.join(self.gff_outfolder, "_".join([strain, self.endfix_tran]))) os.remove(frag_gff) os.remove(tex_gff) else: if args_tran.frag_wigs is not None: for strain in strains: frag_gff = os.path.join(self.gff_outfolder, "_".join([strain, self.frag])) final_gff = os.path.join( self.gff_outfolder, "_".join([strain, self.endfix_tran])) shutil.move(frag_gff, final_gff) elif args_tran.tex_wigs is not None: for strain in strains: tex_gff = os.path.join(self.gff_outfolder, "_".join([strain, self.tex])) final_gff = os.path.join( self.gff_outfolder, "_".join([strain, self.endfix_tran])) shutil.move(tex_gff, final_gff)
def _for_two_wigs(self, strains, args_tran): if (args_tran.frag_wigs is not None) and ( args_tran.tex_wigs is not None): print("merge fragment and tex treat one ....") for strain in strains: frag_gff = os.path.join(self.gff_outfolder, "_".join([strain, self.frag])) tex_gff = os.path.join(self.gff_outfolder, "_".join([strain, self.tex])) final_gff = os.path.join(self.gff_outfolder, "_".join([strain, self.endfix_tran])) for gff in os.listdir(self.gff_outfolder): if "transcript_assembly" in gff: filename = gff.split("_transcript_assembly_") if (strain == filename[0]) and ( "tex_notex.gff" == filename[1]): tex_file = gff elif (strain == filename[0]) and ( "fragment.gff" == filename[1]): frag_file = gff combine(os.path.join(self.gff_outfolder, frag_file), os.path.join(self.gff_outfolder, tex_file), args_tran.tolerance, os.path.join(self.gff_outfolder, "_".join([strain, self.endfix_tran]))) os.remove(frag_gff) os.remove(tex_gff) else: if args_tran.frag_wigs is not None: for strain in strains: frag_gff = os.path.join( self.gff_outfolder, "_".join([strain, self.frag])) final_gff = os.path.join( self.gff_outfolder, "_".join([strain, self.endfix_tran])) shutil.move(frag_gff, final_gff) elif args_tran.tex_wigs is not None: for strain in strains: tex_gff = os.path.join( self.gff_outfolder, "_".join([strain, self.tex])) final_gff = os.path.join( self.gff_outfolder, "_".join([strain, self.endfix_tran])) shutil.move(tex_gff, final_gff)