Exemplo n.º 1
0
def simple_model(alignment,
                 instances,
                 output=None,
                 optimize=False,
                 verbose=False):

    contents = identify_pir(alignment)

    # We redirect STDOUT and STDERR to output files
    if output is None: output = contents['seq']
    warnings.warn('STDOUT & STDERR will be redirected to log files.')
    sys.stdout = open(output + '.log', 'w')
    sys.stderr = open(output + '.err', 'w')

    if verbose: log.verbose()  # Commands MODELLER to display all log output

    env = environ()  # Initializes the 'environment' for this modeling run

    env.io.hetatm = True  # Allow the presence of hetatoms

    a = automodel(
        env,  # Loading the environment
        alnfile=alignment,  # Assigning the PIR alignment
        knowns=contents['str'],  # Listing the known structures
        sequence=contents['seq'],  # Identify the Query Sequence
        assess_methods=(assess.DOPE, assess.GA341,
                        assess.DOPEHR))  # Energy evaluation methods

    # Setting Starting and Ending Model number
    a.starting_model, a.ending_model = 1, instances

    if optimize:
        # Very thorough VTFM optimization:
        a.library_schedule = autosched.slow
        a.max_var_iterations = 300

        # Thorough MD optimization:
        a.md_level = refine.slow

        # Repeat the whole cycle 2 times and do not stop unless obj.func. > 1E6
        a.repeat_optimization = 2
        a.max_molpdf = 1e6

    a.initial_malign3d = True

    a.make()  # Create the Model

    sys.stdout = sys.__stdout__  # restore stdout back to normal
    sys.stderr = sys.__stderr__  # restore stdout back to normal
    warnings.warn('STDOUT & STDERR have been restored.')

    # We delete the error file if no error has occurred
    ERRsize = os.path.getsize(output + '.err')
    if int(ERRsize) is 0:
        os.remove(output + '.err')
Exemplo n.º 2
0
def simple_model(alignment, instances,
                 output=None, optimize=False, verbose=False):

    contents = identify_pir(alignment)

    # We redirect STDOUT and STDERR to output files
    if output is None: output = contents['seq']
    warnings.warn('STDOUT & STDERR will be redirected to log files.')
    sys.stdout = open(output + '.log', 'w')
    sys.stderr = open(output + '.err', 'w')

    if verbose: log.verbose()  # Commands MODELLER to display all log output

    env = environ()  # Initializes the 'environment' for this modeling run

    env.io.hetatm = True  # Allow the presence of hetatoms

    a = automodel(env,  # Loading the environment
                  alnfile=alignment,         # Assigning the PIR alignment
                  knowns=contents['str'],    # Listing the known structures
                  sequence=contents['seq'],  # Identify the Query Sequence
                  assess_methods=(assess.DOPE,
                                  assess.GA341,
                                  assess.DOPEHR))  # Energy evaluation methods

    # Setting Starting and Ending Model number
    a.starting_model, a.ending_model = 1, instances

    if optimize:
        # Very thorough VTFM optimization:
        a.library_schedule   = autosched.slow
        a.max_var_iterations = 300

        # Thorough MD optimization:
        a.md_level = refine.slow

        # Repeat the whole cycle 2 times and do not stop unless obj.func. > 1E6
        a.repeat_optimization = 2
        a.max_molpdf          = 1e6

    a.initial_malign3d = True

    a.make()  # Create the Model

    sys.stdout = sys.__stdout__  # restore stdout back to normal
    sys.stderr = sys.__stderr__  # restore stdout back to normal
    warnings.warn('STDOUT & STDERR have been restored.')

    # We delete the error file if no error has occurred
    ERRsize = os.path.getsize(output + '.err')
    if int(ERRsize) is 0:
        os.remove(output + '.err')
Exemplo n.º 3
0
def restrained_model(alignment,
                     instances,
                     helices=None,
                     betas=None,
                     distances=None,
                     output=None,
                     optimize=False,
                     verbose=False):

    contents = identify_pir(alignment)

    # We redirect STDOUT and STDERR to output files
    if output is None: output = contents['seq']
    warnings.warn('STDOUT & STDERR will be redirected to log files.')
    sys.stdout = open(output + '.log', 'w')
    sys.stderr = open(output + '.err', 'w')

    if verbose: log.verbose()  # Commands MODELLER to display all log output

    env = environ()  # Initializes the 'environment' for this modeling run

    env.io.hetatm = True  # Allow the presence of hetatoms

    class MyModel(automodel):
        def special_restraints(self, aln):
            rsr = self.restraints
            at = self.atoms
            # Setting forced alpha helices
            try:
                for helix in helices:
                    rsr.add(
                        secondary_structure.alpha(
                            self.residue_range(
                                str(helix[0]) + ':',
                                str(helix[1]) + ':')))
            except TypeError:
                pass

            # Setting forced beta strands
            try:
                for strand in betas:
                    rsr.add(
                        secondary_structure.strand(
                            self.residue_range(
                                str(strand[0]) + ':',
                                str(strand[1]) + ':')))
            except TypeError:
                pass

            # Setting distance restraints
            try:
                for restraint in distances:
                    rsr.add(
                        forms.gaussian(group=physical.xy_distance,
                                       feature=features.distance(
                                           at['CA:' + str(restraint[0])],
                                           at['CA:' + str(restraint[1])]),
                                       mean=float(restraint[2]),
                                       stdev=0.1))
            except TypeError:
                pass

    a = automodel(
        env,  # Loading the environment
        alnfile=alignment,  # Assigning the PIR alignment
        knowns=contents['str'],  # Listing the known structures
        sequence=contents['seq'],  # Identify the Query Sequence
        assess_methods=(assess.DOPE, assess.GA341,
                        assess.DOPEHR))  # Energy evaluation methods

    # Setting Starting and Ending Model number
    a.starting_model, a.ending_model = 1, instances

    if optimize:
        # Very thorough VTFM optimization:
        a.library_schedule = autosched.slow
        a.max_var_iterations = 300

        # Thorough MD optimization:
        a.md_level = refine.slow

        # Repeat the whole cycle 2 times and do not stop unless obj.func. > 1E6
        a.repeat_optimization = 2
        a.max_molpdf = 1e6

    a.initial_malign3d = True

    a.make()  # Create the Model

    sys.stdout = sys.__stdout__  # restore stdout back to normal
    sys.stderr = sys.__stderr__  # restore stdout back to normal
    warnings.warn('STDOUT & STDERR have been restored.')

    # We delete the error file if no error has occurred
    ERRsize = os.path.getsize(output + '.err')
    if int(ERRsize) is 0:
        os.remove(output + '.err')
Exemplo n.º 4
0
def restrained_model(alignment, instances, helices=None, betas=None, distances=None,
                     output=None, optimize=False, verbose=False):

    contents = identify_pir(alignment)

    # We redirect STDOUT and STDERR to output files
    if output is None: output = contents['seq']
    warnings.warn('STDOUT & STDERR will be redirected to log files.')
    sys.stdout = open(output + '.log', 'w')
    sys.stderr = open(output + '.err', 'w')

    if verbose: log.verbose()  # Commands MODELLER to display all log output

    env = environ()  # Initializes the 'environment' for this modeling run

    env.io.hetatm = True  # Allow the presence of hetatoms

    class MyModel(automodel):
        def special_restraints(self, aln):
            rsr = self.restraints
            at = self.atoms
            # Setting forced alpha helices
            try:
                for helix in helices:
                    rsr.add(secondary_structure.alpha(self.residue_range(str(helix[0])+':',
                                                                         str(helix[1])+':')))
            except TypeError: pass

            # Setting forced beta strands
            try:
                for strand in betas:
                    rsr.add(secondary_structure.strand(self.residue_range(str(strand[0])+':',
                                                                          str(strand[1])+':')))
            except TypeError: pass

            # Setting distance restraints
            try:
                for restraint in distances:
                    rsr.add(forms.gaussian(group=physical.xy_distance,
                                           feature=features.distance(at['CA:' + str(restraint[0])],
                                                                     at['CA:' + str(restraint[1])]),
                                           mean=float(restraint[2]),
                                           stdev=0.1)
                            )
            except TypeError: pass

    a = automodel(env,  # Loading the environment
                  alnfile=alignment,         # Assigning the PIR alignment
                  knowns=contents['str'],    # Listing the known structures
                  sequence=contents['seq'],  # Identify the Query Sequence
                  assess_methods=(assess.DOPE,
                                  assess.GA341,
                                  assess.DOPEHR))  # Energy evaluation methods

    # Setting Starting and Ending Model number
    a.starting_model, a.ending_model = 1, instances

    if optimize:
        # Very thorough VTFM optimization:
        a.library_schedule   = autosched.slow
        a.max_var_iterations = 300

        # Thorough MD optimization:
        a.md_level = refine.slow

        # Repeat the whole cycle 2 times and do not stop unless obj.func. > 1E6
        a.repeat_optimization = 2
        a.max_molpdf          = 1e6

    a.initial_malign3d = True

    a.make()  # Create the Model

    sys.stdout = sys.__stdout__  # restore stdout back to normal
    sys.stderr = sys.__stderr__  # restore stdout back to normal
    warnings.warn('STDOUT & STDERR have been restored.')

    # We delete the error file if no error has occurred
    ERRsize = os.path.getsize(output + '.err')
    if int(ERRsize) is 0:
        os.remove(output + '.err')