Skip to content

Commit 0ff25df

Browse files
committed
Better outfile handling in CLI
1 parent 1d1e204 commit 0ff25df

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

microhapulator/cli/diff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# -------------------------------------------------------------------------------------------------
1212

1313

14-
from microhapulator import open
14+
from microhapulator import open as mhopen
1515
import microhapulator.api as mhapi
1616
from microhapulator.profile import Profile
1717

@@ -32,7 +32,7 @@ def subparser(subparsers):
3232

3333
def main(args):
3434
differ = mhapi.diff(Profile(fromfile=args.profile1), Profile(fromfile=args.profile2))
35-
with open(args.out, "w") as fh:
35+
with mhopen(args.out, "w") as fh:
3636
for marker, diff1, diff2 in differ:
3737
print(marker, file=fh)
3838
if len(diff1) > 0:

microhapulator/cli/dist.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
import json
15+
from microhapulator import open as mhopen
1516
import microhapulator.api as mhapi
1617
from microhapulator.profile import Profile
1718

@@ -35,5 +36,5 @@ def main(args):
3536
data = {
3637
"hamming_distance": d,
3738
}
38-
with open(args.out, "w") as fh:
39+
with mhopen(args.out, "w") as fh:
3940
json.dump(data, fh, indent=4)

microhapulator/cli/getrefr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def download_is_needed(url, filepath, checksum):
5454

5555
def subparser(subparsers):
5656
desc = "Download and index a GRCh38 assembly file suitable as a whole-genome mapping reference"
57-
cli = subparsers.add_parser("getrefr", description=desc)
57+
subparsers.add_parser("getrefr", description=desc)
5858

5959

6060
def main(args):

microhapulator/cli/sim.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Development Center.
1111
# -------------------------------------------------------------------------------------------------
1212

13-
13+
from microhapulator import open as mhopen
1414
from microhapulator import load_marker_frequencies
1515
import microhapulator.api as mhapi
1616
from microhapulator.marker import MicrohapIndex
@@ -57,7 +57,7 @@ def subparser(subparsers):
5757
def main(args):
5858
frequencies = load_marker_frequencies(args.freq)
5959
profile = mhapi.sim(frequencies, seed=args.seed)
60-
with open(args.out, "w") as fh:
60+
with mhopen(args.out, "w") as fh:
6161
profile.dump(fh)
6262
message = "profile JSON written to {:s}".format(fh.name)
6363
print("[MicroHapulator::sim]", message, file=sys.stderr)

microhapulator/cli/unite.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
import numpy.random
15+
from microhapulator import open as mhopen
1516
from microhapulator.profile import Profile
1617

1718

@@ -44,5 +45,5 @@ def main(args):
4445
Profile(fromfile=args.mom),
4546
Profile(fromfile=args.dad),
4647
)
47-
with open(args.out, "w") as fh:
48+
with mhopen(args.out, "w") as fh:
4849
profile.dump(fh)

0 commit comments

Comments
 (0)