def create_fragment(pdb_path, anchor5=None, anchor3=None, chain_name='A', sequence=None): """*create_fragment(pdb_path, anchor5=None, anchor3=None, chain_name='A', sequence=None)* To insert small pieces of custom PDB structures into models, fragments can be used. This command loads a fragment, and defines one or two connection points, to which the fragment will be inserted by superposition. It returns a ModernaFragment object. To add a ModernaFragment object to a model, the insert_fragment command should be used. The scenarios for adding either involve superposition of a single residue with the model on the 5' end of the fragment, or on the 3' end, or both. :Arguments: * path to pdb file with the fragment * residue to which the 5' end of the fragment will be superimposed * residue to which the 3' end of the fragment will be superimposed * chain name of the fragment in the file (optional; A by default) * sequence that should be modeled onto the fragment upon insertion (optional; the sequence should not include the 1-2 anchor residues, it therefore has to be shorter than the fragment) """ pdb_path = validate_path(pdb_path) if anchor5: anchor5 = validate_resi(anchor5) if anchor3: anchor3 = validate_resi(anchor3) if sequence: sequence = validate_seq(sequence) struc = ModernaStructure(data_type='file', data=pdb_path, chain_name=chain_name) if anchor5 and anchor3: fr = ModernaFragment53(struc, anchor5=anchor5, anchor3=anchor3, new_sequence=sequence, strict=False) elif anchor5: fr = ModernaFragment5(struc, anchor5=anchor5, new_sequence=sequence, strict=False) elif anchor3: fr = ModernaFragment3(struc, anchor3=anchor3, new_sequence=sequence, strict=False) else: raise ModernaError("Anchor residues need to be specified.") return fr
def add_modification(residue, modification_name, model=None, residue_number=None): """*add_modification(residue, modification_name, model=None, residue_number=None)* Adds a modification to a single residue. An RNAModel can be given optionally. If this is given, the modified residue is subsequently copied to it. Note that deoxynucleotides count as modified bases as well. :Arguments: * residue from a Template or RNAModel object * modification name (abbreviated as e.g. 'm6Am', 'm1G', 'm3U', 'mnm5s2U') * model (optional; if this is given, the residue is copied) * residue position in model (optional; by default the residue number is kept) """ residue = validate_resi(residue) modification_name = validate_alphabet(modification_name) if model: model = validate_model(model) if residue_number: validate_resnum(residue_number) if model != None: model.add_one_modification_copy(residue, modification_name, residue_number) else: modifications.add_modification(residue, modification_name)
def exchange_single_base(residue, new_name, model=None, new_number=None): """*exchange_single_base(residue, new_name, model=None, new_number=None)* Exchanges standard RNA bases in a residue. This can be used to modify residues already in a model, or to exchange and copy them in one step, if an RnaModel is given. It is also possible to modify the template this way! The residue number does not change by default, but a new one can be given. :Arguments: * Residues from a Template or RnaModel * Abbreviation of the new base ('A', 'G', 'C' or 'U') * RnaModel object (optional) * New residue number in the model (optional) """ residue = validate_resi(residue) new_name = validate_alphabet(new_name) if model: model = validate_model(model) if new_number: new_number = validate_resnum(new_number) if model: model.copy_residue(residue, new_number) number = new_number or residue.identifier modifications.exchange_base(model[number], new_name) else: modifications.exchange_base(residue, new_name)
def rotate_chi(residue, angle=90): """*rotate_chi(residue, angle=90)* Rotates a base in a given nucleotide around the glycosidic bond (the chi torsion angle, between C1' and N1/N9 atoms). :Arguments: * residue (from a template or model) * angle in degrees """ residue = validate_resi(residue) rc(residue, angle)
def copy_single_residue(residue, model, new_number=None, strict=True): """*copy_single_residue(residue, model, new_number=None, strict=True)* Copies a single residue into the model. The residue can be taken from a Template, or another RnaModel. Residues are specified by their PDB residue number in quotes and square brackets, e.g. template['5']. eventually accompanied by the insertion letter (abbreviated as number). By default, the number of the residue is kept, but it can be given optionally. :Arguments: * Residue from a Template or RnaModel * RnaModel object * new residue number in the model (optional) * strict=1 complains when a residue with the given number exists already (default); strict=0 copies anyway """ residue = validate_resi(residue) model = validate_model(model) if new_number: new_number = validate_resnum(new_number) model.copy_residue(residue, new_number, strict=strict)
def remove_modification(residue, model=None, new_number=None): """*remove_modification(residue, model=None, new_number=None)* Removes base modifications from a single residue. The nucleotide is transformed into the standard base from which the modification originated. A RnaModel can be given optionally. If this is given, the modified residue is subsequently copied to it. Note that desoxynucleotides count as modified bases as well. :Arguments: * residue from a Template or RnaModel object * RnaModel object (optional) * new residue number after copying (optional) """ residue = validate_resi(residue) if model: model = validate_model(model) if new_number: new_number = validate_resnum(new_number) if model: model.remove_one_modification_copy(residue, new_number) else: modifications.remove_modification(residue)