def test_maxmatch_cmd_generation(self): """Generate NUCmer command line with maxmatch.""" ncmd, _ = anim.construct_nucmer_cmdline(Path("file1.fna"), Path("file2.fna"), outdir=self.outdir, maxmatch=True) self.assertEqual(ncmd, self.ntgtmax)
def test_maxmatch_cmd_generation(self): """generate NUCmer command line with maxmatch.""" ncmd, fcmd = anim.construct_nucmer_cmdline("file1.fna", "file2.fna", outdir=self.outdir, maxmatch=True) assert_equal(ncmd, self.ntgtmax)
def test_anim_pairwise_basic(self): """Test generation of basic NUCmer pairwise comparison command.""" cmd_nucmer, cmd_filter = anim.construct_nucmer_cmdline( Path("file1.fna"), Path("file2.fna")) tgt_nucmer = "nucmer --mum -p nucmer_output/file1_vs_file2 file1.fna file2.fna" tgt_filter = "delta_filter_wrapper.py delta-filter -1 nucmer_output/file1_vs_file2.delta nucmer_output/file1_vs_file2.filter" self.assertEqual(cmd_nucmer, tgt_nucmer) self.assertEqual(cmd_filter, tgt_filter)
def test_anim_pairwise_basic(): """Test generation of basic NUCmer pairwise comparison command. """ cmd = anim.construct_nucmer_cmdline("file1.fna", "file2.fna") assert_equal( cmd, "nucmer -mum -p ./nucmer_output/file1_vs_file2 " + "file1.fna file2.fna") print(cmd)
def test_single_cmd_generation(self): """generate single abstract NUCmer/delta-filter command-line. Tests that a single NUCmer/delta-filter command-line pair is produced correctly """ cmds = anim.construct_nucmer_cmdline("file1.fna", "file2.fna", outdir=self.outdir) assert_equal(cmds, (self.ntgt, self.ftgt))
def test_anim_pairwise_maxmatch(self): """Test generation of NUCmer pairwise comparison command with maxmatch.""" cmd_nucmer, cmd_filter = anim.construct_nucmer_cmdline( Path("file1.fna"), Path("file2.fna"), maxmatch=True) tgt_nucmer = ( "nucmer --maxmatch -p nucmer_output/file1_vs_file2 file1.fna file2.fna" ) tgt_filter = "delta_filter_wrapper.py delta-filter -1 nucmer_output/file1_vs_file2.delta nucmer_output/file1_vs_file2.filter" self.assertEqual(cmd_nucmer, tgt_nucmer) self.assertEqual(cmd_filter, tgt_filter)
def test_anim_pairwise_maxmatch(): """Test generation of NUCmer pairwise comparison command with maxmatch. """ cmd = anim.construct_nucmer_cmdline("file1.fna", "file2.fna", maxmatch=True) assert_equal( cmd, "nucmer -maxmatch -p ./nucmer_output/file1_vs_file2 " + "file1.fna file2.fna") print(cmd)
def test_maxmatch_single(tmp_path, path_file_two): """Generate NUCmer command line with maxmatch.""" ncmd, _ = anim.construct_nucmer_cmdline(path_file_two[0], path_file_two[1], outdir=tmp_path, maxmatch=True) dir_nucmer = tmp_path / "nucmer_output" expected = ( "nucmer --maxmatch -p " f"{dir_nucmer / str(path_file_two[0].stem + '_vs_' + path_file_two[1].stem)} " f"{path_file_two[0]} {path_file_two[1]}") assert ncmd == expected
def generate_joblist( comparisons: List[Tuple], existingfiles: List[Path], args: Namespace, ) -> List[ComparisonJob]: """Return list of ComparisonJobs. :param comparisons: list of (Genome, Genome) tuples :param existingfiles: list of pre-existing nucmer output files :param args: Namespace of command-line arguments for the run """ logger = logging.getLogger(__name__) joblist = [] # will hold ComparisonJob structs for idx, (query, subject) in enumerate( tqdm(comparisons, disable=args.disable_tqdm)): ncmd, dcmd = anim.construct_nucmer_cmdline( query.path, subject.path, args.outdir, args.nucmer_exe, args.filter_exe, args.maxmatch, ) logger.debug("Commands to run:\n\t%s\n\t%s", ncmd, dcmd) outprefix = ncmd.split()[3] # prefix for NUCmer output if args.nofilter: outfname = Path(outprefix + ".delta") else: outfname = Path(outprefix + ".filter") logger.debug("Expected output file for db: %s", outfname) # If we're in recovery mode, we don't want to repeat a computational # comparison that already exists, so we check whether the ultimate # output is in the set of existing files and, if not, we add the jobs # TODO: something faster than a list search (dict or set?) # The comparisons collections always gets updated, so that results are # added to the database whether they come from recovery mode or are run # in this call of the script. if args.recovery and outfname.name in existingfiles: logger.debug("Recovering output from %s, not building job", outfname) else: logger.debug("Building job") # Build jobs njob = pyani_jobs.Job("%s_%06d-n" % (args.jobprefix, idx), ncmd) fjob = pyani_jobs.Job("%s_%06d-f" % (args.jobprefix, idx), dcmd) fjob.add_dependency(njob) joblist.append( ComparisonJob(query, subject, dcmd, ncmd, outfname, fjob)) return joblist
def test_mummer_single(tmp_path, path_file_two): """Generate single NUCmer/delta-filter command-line.""" cmds = anim.construct_nucmer_cmdline(path_file_two[0], path_file_two[1], outdir=tmp_path) dir_nucmer = tmp_path / "nucmer_output" expected = ( ("nucmer --mum -p " f"{dir_nucmer / str(path_file_two[0].stem + '_vs_' + path_file_two[1].stem)} " f"{path_file_two[0]} {path_file_two[1]}"), ("delta_filter_wrapper.py delta-filter -1 " f"{dir_nucmer / str(path_file_two[0].stem + '_vs_' + path_file_two[1].stem + '.delta')} " f"{dir_nucmer / str(path_file_two[0].stem + '_vs_' + path_file_two[1].stem + '.filter')}" ), ) assert cmds == expected
def test_anim_pairwise(): """Test generation of NUCmer pairwise comparison command. """ cmd = anim.construct_nucmer_cmdline("file1.fna", "file2.fna") assert_equal(cmd, "nucmer -mum -p ./file1_vs_file2 file1.fna file2.fna") print(cmd)