4 from __future__
import print_function
13 parser = argparse.ArgumentParser(
14 description=
'Process output data file saved as rmfs. It has two modality: '
15 'print selected fields for all lines or print a particular line '
16 'where a filed has a given value.')
21 help=
"file name to process")
26 help=
"Specify all fields to be printed. Multiple flags will append a "
27 "list of fields to be printed")
33 help=
"print the fields contained in the file")
39 help=
"Print frame number n")
41 result = parser.parse_args()
45 if result.filename
is not None:
48 rh = RMF.open_rmf_file_read_only(result.filename)
49 cat = rh.get_category(
'stat')
50 rmf_klist = rh.get_keys(cat)
51 rmf_names_keys = dict([(rh.get_name(k), k)
for k
in rmf_klist])
52 klist = rmf_names_keys.keys()
55 raise IOError(
"Not an RMF file")
57 raise ValueError(
"No file name provided. Use -h for help")
61 if result.print_fields:
68 match_strictness = 1.0
71 if result.fields
is not None:
75 for field
in result.fields:
76 found_entries = difflib.get_close_matches(
81 if len(found_entries) == 0:
82 raise ValueError(
"field " + field +
" non found")
84 field_list.append(found_entries[0])
87 s0 =
' '.join([
"%20s" % (field)
for field
in field_list])
91 rh = RMF.open_rmf_file_read_only(result.filename)
93 for frame_number
in range(rh.get_number_of_frames()):
95 rn = rh.get_root_node()
97 s0 =
' '.join(
"%20s" % (str(rn.get_value(rmf_names_keys[name])))
98 for name
in field_list)
100 if not result.nframe:
103 print(str(frame_number) +
" > " + s0)
107 if result.nframe
is not None:
110 rh = RMF.open_rmf_file_read_only(result.filename)
113 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.