Skip to content

Commit

Permalink
Merge pull request #13 from richard-burhans/update-segalign
Browse files Browse the repository at this point in the history
Fixed regex, added debug timing for package_output.py
  • Loading branch information
richard-burhans authored Aug 1, 2024
2 parents 6930a27 + 9d4968f commit 2840545
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions tools/segalign/package_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import configparser
import json
import os
import resource
import sys
import tarfile
import time
import typing

import bashlex

RUSAGE_ATTRS: typing.Final = ["ru_utime", "ru_stime", "ru_maxrss", "ru_minflt", "ru_majflt", "ru_inblock", "ru_oublock", "ru_nvcsw", "ru_nivcsw"]


class PackageFile:
def __init__(
Expand Down Expand Up @@ -303,8 +307,13 @@ def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--tool_directory", type=str, required=True, help="tool directory")
parser.add_argument("--format_selector", type=str, required=True, help="format selector")
parser.add_argument("--debug", action="store_true", help="enable debug messages")
args = parser.parse_args()

if args.debug:
r_beg = resource.getrusage(resource.RUSAGE_SELF)
beg: int = time.monotonic_ns()

lastz_command_config_file: str = os.path.join(args.tool_directory, "lastz-cmd.ini")

config: configparser.ConfigParser = configparser.ConfigParser()
Expand All @@ -315,6 +324,14 @@ def main() -> None:
bashCommandLineFile(lastz_command_file, config, args, package_file)
package_file.close()

if args.debug:
ns: int = time.monotonic_ns() - beg
r_end = resource.getrusage(resource.RUSAGE_SELF)
print(f"package output clock time: {ns} ns", file=sys.stderr, flush=True)
for rusage_attr in RUSAGE_ATTRS:
value = getattr(r_end, rusage_attr) - getattr(r_beg, rusage_attr)
print(f" package output {rusage_attr}: {value}", file=sys.stderr, flush=True)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion tools/segalign/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def segments(self) -> typing.Iterator["SegAlignSegment"]:


class LastzCommand:
lastz_command_regex = re.compile(r"lastz (.+?)?ref\.2bit\[nameparse=darkspace\]\[multiple\]\[subset=ref_block(\d+)\.name\] (.+?)?query\.2bit\[nameparse=darkspace\]\[subset=query_block(\d+)\.name] --format=(\S+) --ydrop=(\d+) --gappedthresh=(\d+) --strand=(minus|plus)(?: --ambiguous=(\S+))?(?: --(notrivial))?(?: --scoring=(\S+))? --segments=tmp(\d+)\.block(\d+)\.r(\d+)\.(minus|plus)(?:\.split(\d+))?\.segments --output=tmp(\d+)\.block(\d+)\.r(\d+)\.(minus|plus)(?:\.split(\d+))?\.(\S+) 2> tmp(\d+)\.block(\d+)\.r(\d+)\.(minus|plus)(?:\.split(\d+))?\.err")
lastz_command_regex = re.compile(r"lastz (.+?)?ref\.2bit\[nameparse=darkspace\]\[multiple\]\[subset=ref_block(\d+)\.name\] (.+?)?query\.2bit\[nameparse=darkspace\]\[subset=query_block(\d+)\.name] --format=(\S+) --ydrop=(\d+) --gappedthresh=(\d+) --strand=(minus|plus)(?: --ambiguous=(\S+))?(?: --(notrivial))?(?: --scores=(\S+))? --segments=tmp(\d+)\.block(\d+)\.r(\d+)\.(minus|plus)(?:\.split(\d+))?\.segments --output=tmp(\d+)\.block(\d+)\.r(\d+)\.(minus|plus)(?:\.split(\d+))?\.(\S+) 2> tmp(\d+)\.block(\d+)\.r(\d+)\.(minus|plus)(?:\.split(\d+))?\.err")

def __init__(self, line: str) -> None:
self.line = line
Expand Down
3 changes: 3 additions & 0 deletions tools/segalign/segalign.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ python '$__tool_directory__/runner.py'
python '$__tool_directory__/package_output.py'
--tool_directory '$__tool_directory__'
--format_selector '$output_options.format.format_selector'
#if str($system_options.debug) == "true"
--debug
#end if
]]></command>
<inputs>
Expand Down

0 comments on commit 2840545

Please sign in to comment.