4 from __future__
import print_function
13 parser = argparse.ArgumentParser(
14 description=
'Process output data file saved as rmfs. It has two modality: print selected fields for all lines or print a particular line where a filed has a given value.')
19 help=
"file name to process")
24 help=
"Specify all fields to be printed. Multiple flags will append a list of fields to be printed")
30 help=
"print the fields contained in the file")
36 help=
"Print frame number n")
38 result = parser.parse_args()
42 if not result.filename
is None:
45 rh = RMF.open_rmf_file_read_only(result.filename)
46 cat=rh.get_category(
'stat')
47 rmf_klist=rh.get_keys(cat)
48 rmf_names_keys=dict([(rh.get_name(k),k)
for k
in rmf_klist])
49 klist=rmf_names_keys.keys()
52 raise IOError(
"Not an RMF file")
54 raise ValueError(
"No file name provided. Use -h for help")
58 if result.print_fields:
65 match_strictness = 1.0
68 if not result.fields
is None:
72 for field
in result.fields:
73 found_entries = difflib.get_close_matches(
78 if len(found_entries) == 0:
79 raise ValueError(
"field " + field +
" non found")
81 field_list.append(found_entries[0])
84 s0 =
' '.join([
"%20s" % (field)
for field
in field_list])
88 rh = RMF.open_rmf_file_read_only(result.filename)
90 for frame_number
in range(rh.get_number_of_frames()):
93 s0=
' '.join([
"%20s" % (str(rh.get_root_node().get_value(rmf_names_keys[name])))
94 for name
in field_list])
99 print(str(frame_number)+
" > " + s0)
103 if not result.nframe
is None:
106 rh = RMF.open_rmf_file_read_only(result.filename)
109 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.