Skip to content

Commit

Permalink
Change the default extension behaviour to --noextend
Browse files Browse the repository at this point in the history
Following discussion in Issue #342.
  • Loading branch information
baileythegreen committed Oct 1, 2021
1 parent 073554a commit 2f69e77
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
22 changes: 11 additions & 11 deletions pyani/anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def generate_nucmer_jobs(
nucmer_exe: Path = pyani_config.NUCMER_DEFAULT,
filter_exe: Path = pyani_config.FILTER_DEFAULT,
maxmatch: bool = False,
extend: bool = False,
noextend: bool = False,
jobprefix: str = "ANINUCmer",
):
"""Return list of Jobs describing NUCmer command-lines for ANIm.
Expand All @@ -151,14 +151,14 @@ def generate_nucmer_jobs(
:param nucmer_exe: str, location of the nucmer binary
:param filter_exe:
:param maxmatch: Boolean flag indicating to use NUCmer's -maxmatch option
:param extend: Boolean flag indicating whether to use NUCmer's --(no)extend (False: --noextend; True: --extend)
:param noextend: Boolean flag indicating whether to use NUCmer's --(no)extend (True: --noextend; False: --extend)
:param jobprefix:
Loop over all FASTA files, generating Jobs describing NUCmer command lines
for each pairwise comparison.
"""
ncmds, fcmds = generate_nucmer_commands(
filenames, outdir, nucmer_exe, filter_exe, maxmatch, extend
filenames, outdir, nucmer_exe, filter_exe, maxmatch, noextend
)
joblist = []
for idx, ncmd in enumerate(ncmds):
Expand All @@ -177,15 +177,15 @@ def generate_nucmer_commands(
nucmer_exe: Path = pyani_config.NUCMER_DEFAULT,
filter_exe: Path = pyani_config.FILTER_DEFAULT,
maxmatch: bool = False,
extend: bool = False,
noextend: bool = False,
) -> Tuple[List, List]:
"""Return list of NUCmer command-lines for ANIm.
:param filenames: a list of paths to input FASTA files
:param outdir: path to output directory
:param nucmer_exe: location of the nucmer binary
:param maxmatch: Boolean flag indicating to use NUCmer's -maxmatch option
:param extend: Boolean flag indicating whether to use NUCmer's --(no)extend (False: --noextend; True: --extend)
:param noextend: Boolean flag indicating whether to use NUCmer's --(no)extend (True: --noextend; False: --extend)
The first element returned is a list of NUCmer commands, and the
second a corresponding list of delta_filter_wrapper.py commands.
Expand All @@ -202,7 +202,7 @@ def generate_nucmer_commands(
for idx, fname1 in enumerate(filenames[:-1]):
for fname2 in filenames[idx + 1 :]:
ncmd, dcmd = construct_nucmer_cmdline(
fname1, fname2, outdir, nucmer_exe, filter_exe, maxmatch, extend
fname1, fname2, outdir, nucmer_exe, filter_exe, maxmatch, noextend
)
nucmer_cmdlines.append(ncmd)
delta_filter_cmdlines.append(dcmd)
Expand All @@ -218,7 +218,7 @@ def construct_nucmer_cmdline(
nucmer_exe: Path = pyani_config.NUCMER_DEFAULT,
filter_exe: Path = pyani_config.FILTER_DEFAULT,
maxmatch: bool = False,
extend: bool = False,
noextend: bool = False,
) -> Tuple[str, str]:
"""Return a tuple of corresponding NUCmer and delta-filter commands.
Expand All @@ -229,7 +229,7 @@ def construct_nucmer_cmdline(
:param filter_exe:
:param maxmatch: Boolean flag indicating whether to use NUCmer's -maxmatch
option. If not, the -mum option is used instead
:param extend: Boolean flag indicating whether to use NUCmer's --(no)extend (False: --noextend; True: --extend)
:param noextend: Boolean flag indicating whether to use NUCmer's --(no)extend (True: --noextend; False: --extend)
The split into a tuple was made necessary by changes to SGE/OGE.
The delta-filter command must now be run as a dependency of the NUCmer
Expand All @@ -252,10 +252,10 @@ def construct_nucmer_cmdline(
mode = "--maxmatch"
else:
mode = "--mum"
if extend:
ext = " --extend"
else:
if noextend:
ext = " --noextend"
else:
ext = " --extend"
nucmercmd = f"{nucmer_exe} {mode} {ext} -p {outprefix} {fname2} {fname2}"
# There's a subtle pathlib.Path issue, here. We must use string concatenation to add suffixes
# to the outprefix files, as using path.with_suffix() instead can replace part of the filestem
Expand Down
14 changes: 7 additions & 7 deletions pyani/pyani_orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class Comparison(Base):
"version",
"fragsize",
"maxmatch",
"extend",
"noextend",
),
)

Expand All @@ -290,7 +290,7 @@ class Comparison(Base):
version = Column(String)
fragsize = Column(Integer)
maxmatch = Column(Boolean)
extend = Column(Boolean)
noextend = Column(Boolean)

query = relationship(
"Genome", foreign_keys=[query_id], back_populates="query_comparisons"
Expand Down Expand Up @@ -344,7 +344,7 @@ def get_comparison_dict(session: Any) -> Dict[Tuple, Any]:
:param session: live SQLAlchemy session of pyani database
Returns Comparison objects, keyed by (_.query_id, _.subject_id,
_.program, _.version, _.fragsize, _.maxmatch, _.extend) tuple
_.program, _.version, _.fragsize, _.maxmatch, _.noextend) tuple
"""
return {
(
Expand All @@ -354,7 +354,7 @@ def get_comparison_dict(session: Any) -> Dict[Tuple, Any]:
_.version,
_.fragsize,
_.maxmatch,
_.extend,
_.noextend,
): _
for _ in session.query(Comparison).all()
}
Expand Down Expand Up @@ -416,7 +416,7 @@ def filter_existing_comparisons(
version,
fragsize: Optional[int] = None,
maxmatch: Optional[bool] = False,
extend: Optional[bool] = False,
noextend: Optional[bool] = False,
) -> List:
"""Filter list of (Genome, Genome) comparisons for those not in the session db.
Expand All @@ -427,7 +427,7 @@ def filter_existing_comparisons(
:param version: version of program for comparison
:param fragsize: fragment size for BLAST databases
:param maxmatch: maxmatch used with nucmer comparison
:param extend: extend used with nucmer comparison
:param noextend: noextend used with nucmer comparison
When passed a list of (Genome, Genome) comparisons as comparisons, check whether
the comparison exists in the database and, if so, associate it with the passed run.
Expand All @@ -448,7 +448,7 @@ def filter_existing_comparisons(
version,
fragsize,
maxmatch,
extend,
noextend,
)
]
)
Expand Down
22 changes: 11 additions & 11 deletions pyani/scripts/parsers/anim_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ def build(
default=False,
help="override MUMmer to allow all NUCmer matches",
)
extend = parser.add_mutually_exclusive_group()
extend.add_argument(
"--extend",
dest="extend",
action="store_true",
default=False,
help="override default to allow overlapping NUCmer matches",
)
extend.add_argument(
# extend = parser.add_mutually_exclusive_group()
# extend.add_argument(
# "--extend",
# dest="extend",
# action="store_true",
# default=True,
# help="override default to allow overlapping NUCmer matches",
# )
parser.add_argument(
"--noextend",
dest="extend",
action="store_false",
dest="noextend",
action="store_true",
default=False,
help="disallow overlapping NUCmer matches",
)
Expand Down
8 changes: 4 additions & 4 deletions pyani/scripts/subcommands/subcmd_anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ProgParams(NamedTuple):

fragsize: str
maxmatch: bool
extend: bool
noextend: bool


def subcmd_anim(args: Namespace) -> None:
Expand Down Expand Up @@ -252,7 +252,7 @@ def subcmd_anim(args: Namespace) -> None:
nucmer_version,
None,
args.maxmatch,
args.extend,
args.noextend,
)
logger.info(
"\t...after check, still need to run %s comparisons", len(comparisons_to_run)
Expand Down Expand Up @@ -338,7 +338,7 @@ def generate_joblist(
args.nucmer_exe,
args.filter_exe,
args.maxmatch,
args.extend,
args.noextend,
)
logger.debug("Commands to run:\n\t%s\n\t%s", ncmd, dcmd)
outprefix = ncmd.split()[4] # prefix for NUCmer output
Expand Down Expand Up @@ -447,7 +447,7 @@ def update_comparison_results(
version=nucmer_version,
fragsize=None,
maxmatch=args.maxmatch,
extend=args.extend,
noextend=args.noextend,
)
)

Expand Down

0 comments on commit 2f69e77

Please sign in to comment.