class Event(object): _attributes = ['estimated_pseudo_occupancy', 'estimated_bdc', 'global_correlation', 'local_correlation'] def __init__(self, id, cluster, info=None): """Class to hold information about an event in a dataset""" # Process cluster object (points and values for Event) assert isinstance(cluster, PointCluster), 'cluster must be of type PointCluster' self.cluster = cluster self.cluster.parent = self # Give it a name if id: self.id = id else: self.id = cluster.id # Allow a parent self.parent = None # Add Meta to the object if info: assert isinstance(info, Info) for a in self._attributes: assert hasattr(info, a) self.info = info else: self.info = Info(self._attributes) def summary(self): out = [] out.append('Event {!s} Summary'.format(self.id)) out.append(self.cluster.summary()) out.append(self.info.summary()) return '\n'.join(out)
def __init__(self, id, cluster, info=None): """Class to hold information about an event in a dataset""" # Process cluster object (points and values for Event) assert isinstance(cluster, PointCluster), 'cluster must be of type PointCluster' self.cluster = cluster self.cluster.parent = self # Give it a name if id: self.id = id else: self.id = cluster.id # Allow a parent self.parent = None # Add Meta to the object if info: assert isinstance(info, Info) for a in self._attributes: assert hasattr(info, a) self.info = info else: self.info = Info(self._attributes)
def __init__(self, events=None, id=None, info=None): """Class to hold information about an identified site (collection of events)""" # List of Events self.children = [] self.parent = None self.id = id # Add Meta to the object if info: assert isinstance(info, Info) for a in self._attributes: assert hasattr(info, a) self.info = info else: self.info = Info(self._attributes) # Add Events if events: self.add_events(events=events, update=True)
def __init__(self, hierarchy_inputs=None, hierarchies=None, inputs=None, labels=None): # Object to stores all of the structure objects self.structures = Info(['hierarchies', 'inputs', 'labels']) # Unpack and store structure objects if hierarchy_inputs: self.structures.hierarchies = [ i.hierarchy for i in hierarchy_inputs ] self.structures.inputs = [i.input for i in hierarchy_inputs] else: self.structures.hierarchies = hierarchies self.structures.inputs = inputs # Unpack and store labels if not labels: labels = range(len(self.structures.hierarchies)) self.structures.labels = labels #Initialise output tables self.initialise_tables()
def initialise_tables(self): """Populate the index of the tables""" # Object to contain all of the output data tables self.tables = Info(['structures', 'residues', 'atoms']) self._initialise_structure_table() self._initialise_residue_table()
def sort_column_labels(mtz_object, return_labels=True): """Sort columns by type (F, I, etc). If return_labels=True, return labels, else return column data""" col_labels = mtz_object.column_labels() col_types = mtz_object.column_types() lab_hash = {} # H: Miller Indices, F: Amplitudes, I: Integers, P: Phases, Q: Standard Deviations, J: Intensities mill = [col_labels[i] for i, t in enumerate(col_types) if t == 'H'] sfac = [col_labels[i] for i, t in enumerate(col_types) if t == 'F'] inty = [col_labels[i] for i, t in enumerate(col_types) if t == 'J'] sdev = [col_labels[i] for i, t in enumerate(col_types) if t == 'Q'] phas = [col_labels[i] for i, t in enumerate(col_types) if t == 'P'] ints = [col_labels[i] for i, t in enumerate(col_types) if t == 'I'] lab_hash['miller'] = mill # Find the main F col lab_hash['f'] = [s for s in sfac if (s in ['F','FP','FCTR','FOSC','FOBS'] \ or s.startswith('F_') or s.startswith('FP_') \ or s.upper().startswith('F-OBS') or s.upper().startswith('FOUT_'))] # Use these if no others if not lab_hash['f']: lab_hash['f'] = [s for s in sfac if s.startswith('FP')] # Find the main SIGF col lab_hash['sigf'] = [s for s in sdev if (s in ['SIGF','SIGFP','SIGFOBS'] \ or s.startswith('SIGF_') or s.startswith('SIGFP_') \ or s.upper().startswith('SIGF-OBS') or s.upper().startswith('SIGFOUT_'))] # Use these if no others if not lab_hash['sigf']: lab_hash['sigf'] = [s for s in sdev if s.startswith('SIGFP')] # Find the I cols lab_hash['i'] = [s for s in inty if s.startswith('I')] # Find the SIGI cols lab_hash['sigi'] = [s for s in sdev if s.startswith('SIGI')] # Find the F_calc lab_hash['calc_f'] = [ s for s in sfac if (s == 'FC' or s == 'FMODEL' or s.startswith('FC_') or s.upper().startswith('F-MODEL')) ] # Find the PHI_calcs lab_hash['calc_p'] = [ p for p in phas if (p == 'PHIC' or p == 'PHIFMODEL' or p.startswith('PHIC_') or p.upper().startswith('PHIF-MODEL')) ] # Find the main phase col lab_hash['phi'] = lab_hash['p_calc'] # Find the RFree Flag lab_hash['r_flags'] = [ r for r in ints if ('RFREE' in r.upper() or 'FREER' in r.upper() or r == 'FREE' or r.upper().startswith('R-FREE')) ] # 2FOFC cols wt_f_map_opts = ['2FOFCWT', 'FWT'] wt_p_map_opts = ['PH2FOFCWT', 'PHWT', 'PHFWT'] # FOFC cols wt_f_dif_opts = ['FOFCWT', 'DELFWT'] wt_p_dif_opts = ['PHFOFCWT', 'DELPHWT', 'PHDELWT'] # Record 2FOFC pair (composite map) lab_hash['2fofc_f'] = [s for s in sfac if s in wt_f_map_opts] lab_hash['2fofc_p'] = [p for p in phas if p in wt_p_map_opts] # Record FOFC pair (different map) lab_hash['fofc_f'] = [s for s in sfac if s in wt_f_dif_opts] lab_hash['fofc_p'] = [p for p in phas if p in wt_p_dif_opts] # XXX Will probably delete this later for k in lab_hash: for v in lab_hash[k]: col_labels.remove(v) lab_hash['unknown'] = col_labels return Info(lab_hash)