def get_sequence(structure): """*get_sequence(structure)* Retrieves the one-letter-sequence from the coordinates of a structure (template or model). In the sequence, standard RNA bases are denoted by upper case letters, DNA bases by lowercase. For many modifications, one-letter ASCII abbreviations exist (according to McCloskey). All nucleotides that do not have a one-letter abbreviation are represented by the x letter. Nucleotides that cannot be recognized (e.g. base missing) are represented by the '.' character. For determining the sequence, the residues are processed according to their numbers. If an unusually long bond is found anywhere in the backbone between two bases, an additional "_" symbol is inserted in the sequence to mark this discontinuity. Also see http://www.genesilico.pl/modomics :Arguments: * structure - a Template or RnaModel object """ # KR: sequence should be written to logfile. # KR: discontinuities should get an extra logfile message. # MM: is it good place for that or should be sone in get_sequence in ModernaStructure? structure = validate_structure(structure) seq = structure.get_sequence() log.write_message('Checking sequence: \n%s\n' % seq.seq_with_modifications) if '_' in seq.seq_with_modifications: log.write_message('SEQUENCE IS DISCONTINUOUS !!!\n') return seq
def change_sequence(struc, sequence): """*change_sequence(struc, sequence)* Changes the entire sequence of the given structure object, exchanging all nucleotides that differ. :Arguments: * Structure object (RnaModel or Template) * sequence """ struc = validate_structure(struc) sequence = validate_seq(sequence) struc.change_sequence(sequence)
def get_base_pairs(structure): """*get_base_pairs(structure)* Returns a dictionary where keys are residues numbers and values are tuples which each one contains: - residue number interacting with the key-residue - interaction type :Arguments: * ModernaStructure object (template or model). """ structure = validate_structure(structure) return structure.get_base_pairs()
def renumber_chain(struc, start_identifier='1'): """*renumber_chain(struc, start_id)* Changes numeration of residues in the chain. Starts with the given identifier. The new numeration is continuous. :Arguments: * RnaModel or ModernaStructure object * identifier for first residue """ struc = validate_structure(struc) start_identifier = validate_resnum(start_identifier) struc.renumber_chain(start_identifier)
def get_stacking(structure): """*get_stacking(structure)* Returns a list of stacking interactions found in the structure, using the types <<, >>, <>, >< as defined in MC-Annotate paper (JMB 2001, 308, p.919ff). :Arguments: * ModernaStructure object (template or model). """ structure = validate_structure(structure) scalc = StackingCalculator() return [(s.resi1.identifier, s.resi2.identifier, s.type) for s in scalc.get_stacking(structure)]
def find_modifications(structure): """*find_modifications(structure)* Reports all modified nucleotides that occur in a structure loaded or created with ModeRNA (models, templates). This command returns all modified residues as a Python dictionary. {'1':<res>, '6': <res>, '6a': <res>, ...} :Arguments: * RnaModel or Template object """ structure = validate_structure(structure) return structure.get_modified_residues()
def write_secstruc(struct, file_name='secstruc.vienna'): """*write_secstruc(model, file_name='secstruc.vienna')* Writes secondary struture to a vienna file. :Arguments: * Structure object (model or template) * name of the vienna file (optional; by default secstruc.vienna) """ struct = validate_structure(struct) file_name = validate_filename(file_name) struct.write_secstruc(file_name) log.write_message('Secondary structure written to %s' % file_name)
def write_model(model, pdb_file_name='moderna_model.pdb'): """*write_model(model, pdb_file_name='moderna_model.pdb')* Writes a model to a PDB file. The residues in the file are sorted. All residues keep their numbers as last assigned. :Arguments: * Structure object (model or template) * name of the PDB file (optional; by default moderna_model.pdb) """ model = validate_structure(model) pdb_file_name = validate_filename(pdb_file_name) if model.__class__ == RnaModel: model.refine_model() model.write_pdb_file(pdb_file_name) log.write_message('Model written to %s' % pdb_file_name)
def examine_structure(st, ex_log=None, verbose=True): """*examine_structure(structure)* Checks whether the given structure has any features that may cause any problems during the modeling process. The user needs to give a structure object, and optionally a name of the file the report is written to. :Arguments: * Stucture object * name of logfile (optional) """ struc = validate_structure(st) pc = PdbController(st) if ex_log: pc.write_log(ex_log) else: log.write_message(str(pc)) if verbose: print pc return pc
def analyze_geometry(struc, file_name=None): """*analyze_geometry(struc, file_name=None)* Analyses geometry of a structure. Checks whether all angles and bonds length values are close to reference values determined from the PDB. Writes the result of the analysis to log file or to an output file when specified. :Arguments: * RNAModel object * Name of an output file """ struc = validate_structure(struc) if file_name: file_name = validate_filename(file_name) analyzer = GeometryAnalyzer(struc) analyzer.analyze() raport = str(analyzer) if file_name: f = open(file_name, 'w') f.write(raport) log.write_message(raport) return analyzer
def clean_structure(st, write_structure=False): """*clean_structure(structure, write_structure=False)* Eliminates features that may cause problems during modeling from a template or model structure: * water molecules, ions, amino acids, and unidentified residues are deleted. * old atom names are replaced (C1* becomes C1', O1P becomes OP1). * missing phosphate groups are added (also adds the OP3 atom for these) * reports whether the chain is continuous. In case some feature cannot be fixed (e.g. chain discontinuity) this is written to the logfile. It is recommended to include such features in the alignment ('.' characters for strange residues, and '_' for backbone breaks). :Arguments: * Stucture object (RnaModel or Template) * True/False - whether structure should be written to a PDB file (optional) """ struc = validate_structure(st) pc = PdbController(st) pc.clean_structure() log.write_message(str(pc)) if write_structure: pc.write_structure('fixed_structure.pdb') return pc