Beispiel #1
0
class BuildPopulationMEAMT(object):
    """
    Execute the MEAMT Build Population algorithm.
    """

    sequence = None
    path_execute = None
    os.environ["GMX_MAXBACKUP"] = "-1"

    def __init__(self, opts=None):
        """
        @type self: koala.BuildPopulationMEAMT.BuildPopulationMEAMT
        @type opts: OptionParser parameters
        """
        assert opts is not None
        self.opts = opts
        self.time_execution = TimeJobExecution()
        self.path_runs = PathRuns()
        self.framework = Params('MEAMT')

    def main(self):
        """
        Create the MEAMT Build Population configuration file and begin
        the execution to create a initial population.

        @type self: koala.BuildPopulationMEAMT.BuildPopulationMEAMT
        """
        try:
            self.path_runs.set_path_execute()
            self.path_runs.set_execution_directory()

            print 'create dirs'

            self.sequence = create_local_fasta_file(
                    self.path_runs.get_path_execution(),
                    self.opts.fromFasta,
                    self.opts.inputFasta,
                    self.opts.toolname,
                    self.framework)

            print 'create fasta'

            copy_necessary_files(
                self.path_runs.get_path_execute(),
                self.path_runs.get_path_execution(),
                self.framework.get_framework())

            print 'copy files'

            self.framework.set_command(
                self.path_runs.get_path_execution(),
                'aemt-pop-up2')

            print 'set command'

            size = int(self.opts.sizePopulation) / 15

            cl = [
                self.framework.get_command(),
                str(0),
                self.opts.sizePopulation,
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(size),
                str(0),
                str(0),
                self.opts.VanderWaalsWeight,
                self.opts.ChargeWeight,
                str(0),
                str(0),
                str(0),
                str(0),
                str(0),
                self.opts.SolvWeight,
                self.opts.HbondWeight,
                os.path.join(self.path_runs.get_path_execution(), "fasta.txt"),
                os.path.join(self.path_runs.get_path_execution(), "result.txt"),
                os.path.join(self.path_runs.get_path_execution(), "pop_meamt.txt"),
                os.path.join(self.path_runs.get_path_execution(), "protein.pdb"),
                os.path.join(self.path_runs.get_path_execution(), "saida1.txt"),
                os.path.join(self.path_runs.get_path_execution(), "angles.txt"),
                str(0),
                os.path.join(self.path_runs.get_path_execution(), "meat.txt"),
                '&']

            print cl

            retProcess = subprocess.Popen(cl, 0, None, None, None, False)
            retProcess.wait()

            path_output, file_output = os.path.split(self.opts.output)

            result, html = get_result_files(
                self.path_runs.get_path_execution(), self.opts.toolname)

            send_output_results(path_output, file_output, result)

        except Exception, e:
            show_error_message(str(e))
class BuildConformation2PG(object):
    """
    Execute the 2PG Build Conformation algorithm.
    """

    os.environ["GMX_MAXBACKUP"] = "-1"

    def __init__(self, opts=None):
        """
        @type self: koala.BuildConformation2PG.BuildConformation2PG
        @type opts: OptionParser parameters
        """
        assert opts is not None
        self.opts = opts
        self.path_runs = PathRuns()
        self.framework = Params("2PG")

    def run_Build_Conformation(self):
        """
        Create the 2PG Build Conformation configuration file and begin
        the execution to create a initial population.

        @type self: koala.BuildConformation2PG.BuildConformation2PG
        """
        try:
            self.path_runs.set_path_execute()
            self.path_runs.set_execution_directory()

            self.sequence = create_local_fasta_file(
                self.path_runs.get_path_execution(),
                self.opts.fromFasta,
                self.opts.inputFasta,
                self.opts.toolname,
                self.framework,
            )

            copy_necessary_files(
                self.path_runs.get_path_execute(), self.path_runs.get_path_execution(), self.framework.get_framework()
            )

            self.framework.set_parameter("gromacs_energy_min", self.opts.gromacsEnergyMin)
            self.framework.set_parameter("SizePopulation", self.opts.sizePopulation)
            self.framework.set_parameter("force_field", self.opts.forceField)
            self.framework.set_parameter("rotamer_library", self.opts.rotamerLibrary)

            if self.opts.forceField == "amber99sb-ildn":
                self.framework.set_parameter("c_terminal_charge", self.opts.cTerminal)
                self.framework.set_parameter("n_terminal_charge", self.opts.nTerminal)

            self.framework.set_parameter(
                "SequenceAminoAcidsPathFileName", self.path_runs.get_path_execution() + "fasta.txt"
            )
            self.framework.set_parameter("Local_Execute", self.path_runs.get_path_execution())
            self.framework.set_parameter("Path_Gromacs_Programs", get_path_gromacs())
            self.framework.set_parameter("NativeProtein", "%s1VII.pdb" % self.path_runs.get_path_execution())
            self.framework.set_parameter("Database", "%sDatabase/" % get_path_algorithms("2pg_build_conformation"))

            create_configuration_file(self.path_runs.get_path_execution(), self.framework)

            self.framework.set_command(self.path_runs.get_path_execution(), "protpred-Gromacs_pop_initial")

            config = "configuration.conf"

            cl = [self.framework.get_command(), config, "&"]

            retProcess = subprocess.Popen(cl, 0, stdout=None, stderr=subprocess.STDOUT, shell=False)
            retCode = retProcess.wait()
            if retCode != 0:
                show_error_message("The 2PG framework finished wrong.\nContact the system administrator.")

            path_output, file_output = os.path.split(self.opts.output)

            result, html = get_result_files(self.path_runs.get_path_execution(), self.opts.toolname)

            send_output_results(path_output, file_output, result)

        except Exception, e:
            show_error_message(str(e))