Skip to content

Commit

Permalink
improved argument handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Dalton committed Apr 11, 2022
1 parent 52c4786 commit 0951d91
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions efxtools/io/precog2mtz.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ def parse_arguments():
)
parser.add_argument(
"--cell",
type=str,
type=float,
required=True,
help="The unit cell supplied as a comma separated list of floats. "
"For example, --spacegroup=34.,45.,98.,90.,90.,90.",
nargs=6,
help="The unit cell supplied as six floats. "
"For example, --spacegroup 34. 45. 98. 90. 90. 90.",
)
parser.add_argument(
"ii_in",
Expand All @@ -36,11 +37,16 @@ def parse_arguments():
help="Precognition `.ii` file(s)",
)
parser.add_argument(
"mtz_out", type=str, help="Name of the output mtz file."
"-o",
"--mtz-out",
type=str,
default="integrated.mtz",
help="Name of the output mtz file.",
)
parser = parser.parse_args()
return parser


def make_dataset(filenames, spacegroup, cell):
"""
Make an rs.DataSet from all *.ii the files in filenames.
Expand All @@ -66,31 +72,20 @@ def make_dataset(filenames, spacegroup, cell):
return rs.concat(datasets)



def main():
parser = parse_arguments()

# Parse the cell constants
try:
cell = [float(i) for i in parser.cell.split(",")]
assert len(cell) == 6
except:
raise ValueError(
f"Expected 6 comma separated values for `--cell` but received {parser.cell}"
)

# Parse the output filename(s)
if isinstance(parser.ii_in, str):
filenames = [parser.ii_in]
else:
filenames = parser.ii_in


# Parse simple arguments
cell = parser.cell
spacegroup = parser.spacegroup
outfile = parser.mtz_out


ds = make_dataset(filenames, spacegroup, cell)

if parser.remove_sys_absences:
Expand All @@ -103,6 +98,6 @@ def main():

ds.write_mtz(outfile)

if __name__=="__main__":
main()

if __name__ == "__main__":
main()

0 comments on commit 0951d91

Please sign in to comment.