コード例 #1
0
def load_model(data,
               chain_name='A',
               data_type='file',
               template=None,
               alignment=None):
    """*load_model(file_path, chain_name='A', data_type='file', template=None, alignment=None)*
    
Loads a structure model that has been built previously,
or any PDB struture that is then to be modified.
Produces a RnaModel object that can be saved in a variable.
Each model in ModeRNA contains only one chain.
Multi-chain structures can be modeled by using more than one
Template/Alignment/RNAModel at a time.

By default, RNAModels are created by reading files.
They can also be created from BioPython PDB objects
(precisely Bio.PDB.Structure.Structure and Bio.PDB.Chain.Chain objects)

:Arguments:
    * path+filename of a PDB structure file; or a Structure or Chain object from BioPython.
    * chain id (by default 'A')
    * data type ('file' by default; if set to 'structure' or 'chain', Bio.PDB objects are read)
    * Template object to be used for this model (optional)
    * Alignment object to be used for this model (optional)
    """
    if data_type == 'file': data = validate_filename(data)
    elif data_type == 'residues': data = validate_resi_list(data)
    if template: template = validate_template(template)
    if alignment: alignment = validate_alignment(alignment)
    return RnaModel(template=template,
                    alignment=alignment,
                    model_chain_name=chain_name,
                    data_type=data_type,
                    data=data)
コード例 #2
0
def copy_identical_residues(template,
                            alignment,
                            model,
                            strict=True,
                            modifications=True):
    """*copy_identical_residues(template, alignment, model, strict=True, modifications=True)*

Copies all bases identical identical in the alignment
from the template structure to a model. The residue numbers
do not change.

:Arguments:
    * Template object
    * Alignment object
    * RnaModel object
    * strict=1 complains and stops on any problem encountered (default); strict=0 goes on if single residues fail to be copied
    * modifications=0 does not copy modified bases; modifications=1 is default.
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)
    model = validate_model(model)

    if template: model.template = template
    if alignment:
        model.alignment = alignment
        model.recipe = RecipeMaker(alignment).recipe
    model.copy_all_residues(strict=strict, modifications=modifications)
コード例 #3
0
def match_template_with_alignment(template, alignment):
    """*match_template_with_alignment(template, alignment)*
    
Checks, if the sequence of the template structure is equal 
to the second sequence in the alignment. Writes an according message and returns True or False.
Small inconsistencies between both sequences, e.g. backbone breaks, or missing modification symbols
are corrected automatically in the alignment, and changes are reported in the logfile.

Both sequences also count as equal if one has modified nucleotides, and 
the other the corresponding unmodified nucleotides in the same position, 
or if one of the sequences contains the wildcard symbol '.'. 
Thus, the sequence "AGU" is equal to both "A7Y" and "A.U".

:Arguments:
    * Template object
    * Alignment object
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)

    log.write_message('Checking whether template matches with alignment.')
    am = AlignmentMatcher(alignment)
    seq = template.get_sequence()
    am.fix_template_seq(seq)
    result = am.is_template_identical(seq)
    if result:
        log.write_message("template and alignment match.\n")
    else:
        log.write_message("TEMPLATE AND ALIGNMENT DO NOT MATCH!\n")
    return result
コード例 #4
0
def add_all_modifications(template, alignment, model):
    """*add_all_modifications(template, alignment, model)*

Adds all modifications that occur in the target sequence, and are
not present in the template.
    
:Arguments:
    * Template object
    * Alignment object
    * RnaModel object
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)
    model = validate_model(model)

    if template: model.template = template
    if alignment:
        model.alignment = alignment
        model.recipe = RecipeMaker(alignment).recipe
    model.add_all_modifications_copy()
コード例 #5
0
def remove_mismatching_modifications(template, alignment, model):
    """*remove_mismatching_modifications(template, alignment, model)*

Removes all nucleotide modifications that occur in the template, 
and are not present in the target sequence. 
The nucleotides are transformed into standard bases from which the modifications originated.
   
:Arguments:
    * Template object
    * Alignment object
    * RnaModel object
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)
    model = validate_model(model)

    model.template = template
    model.alignment = alignment
    model.recipe = RecipeMaker(alignment).recipe
    model.remove_all_modifications_copy()
コード例 #6
0
def exchange_mismatches(template, alignment, model):
    """*exchange_mismatches(template, alignment, model)*
    
Exchanges the bases for all standard base mismatches in an alignment.
This applies all exchanges of one standard base by another.
Modified bases are not changed (use the apply_alignment command for that).
 
:Arguments:
    * Template object
    * Alignment object
    * RnaModel object
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)
    model = validate_model(model)

    if template: model.template = template
    if alignment:
        model.alignment = alignment
        model.recipe = RecipeMaker(alignment).recipe
    model.exchange_all_bases()
コード例 #7
0
def apply_alignment(template, alignment, model):
    """*apply_alignment(template, alignment, model)*

Applies all operations on single bases that are in an alignment:
Copying identical residues, exchanging mismatches, adding modifications,
and removing modifications. As a result, all these residues are copied
into a model (which may be empty).
For gaps in the alignment, nothing is done.

:Arguments:
    * Template object
    * Alignment object
    * RNAModel object
    """
    template = validate_template(template)
    alignment = validate_alignment(alignment)
    model = validate_model(model)

    model.alignment = alignment
    model.recipe = RecipeMaker(alignment).recipe
    model.template = template
    model.apply_alignment()
コード例 #8
0
def create_model(template=None, alignment=None, model_chain_name=None):
    """*create_model(template=None, alignment=None, model_chain_name=None)*
  
Creates a RNA structure model.
Produces a RnaModel object that can be saved
in a variable (see example).

If no arguments are given, an empty RNAModel is created.
If both a Template and an Alignment are given as arguments,
the complete model is built automatically.
The chain id that the model should have can be specified optionally.

:Arguments:
    * Template object (optional)
    * Alignment object (optional)
    * chain id of the model to be built
    """
    if template: template = validate_template(template)
    if alignment: alignment = validate_alignment(alignment)

    model = RnaModel(template=template,
                     alignment=alignment,
                     model_chain_name=model_chain_name,
                     data_type=None,
                     data=None)
    if template and alignment:
        if not match_template_with_alignment(template, alignment):
            raise ModernaError(
                """Template and alignment sequences do not match!
The model cannot be built automatically.
Template : %s
Alignment: %s
""" % (template.get_sequence(), alignment.template_seq))
        model.create_model()
        match_alignment_with_model(alignment, model)
    return model