12 parser = argparse.ArgumentParser(
13 description=
'Process output data file saved as rmfs. It has two modality: '
14 'print selected fields for all lines or print a particular line '
15 'where a filed has a given value.')
20 help=
"file name to process")
25 help=
"Specify all fields to be printed. Multiple flags will append a "
26 "list of fields to be printed")
32 help=
"print the fields contained in the file")
38 help=
"Print frame number n")
40 result = parser.parse_args()
44 if result.filename
is not None:
47 rh = RMF.open_rmf_file_read_only(result.filename)
48 cat = rh.get_category(
'stat')
49 rmf_klist = rh.get_keys(cat)
50 rmf_names_keys = dict([(rh.get_name(k), k)
for k
in rmf_klist])
51 klist = rmf_names_keys.keys()
54 raise IOError(
"Not an RMF file")
56 raise ValueError(
"No file name provided. Use -h for help")
60 if result.print_fields:
67 match_strictness = 1.0
70 if result.fields
is not None:
74 for field
in result.fields:
75 found_entries = difflib.get_close_matches(
80 if len(found_entries) == 0:
81 raise ValueError(
"field " + field +
" non found")
83 field_list.append(found_entries[0])
86 s0 =
' '.join([
"%20s" % (field)
for field
in field_list])
90 rh = RMF.open_rmf_file_read_only(result.filename)
92 for frame_number
in range(rh.get_number_of_frames()):
94 rn = rh.get_root_node()
96 s0 =
' '.join(
"%20s" % (str(rn.get_value(rmf_names_keys[name])))
97 for name
in field_list)
102 print(str(frame_number) +
" > " + s0)
106 if result.nframe
is not None:
109 rh = RMF.open_rmf_file_read_only(result.filename)
112 s0 = str(k)+
" "+str(rh.get_root_node().get_value(rmf_names_keys[k]))
void load_frame(RMF::FileConstHandle file, RMF::FrameID frame)
Load the given RMF frame into the state of the linked objects.
Support for the RMF file format for storing hierarchical molecular data and markup.