def mafft_wrapper(work_msa):
    app = Applications.MafftCommandline(
        input=work_msa.input_fasta,
        clustalout=True,
    )
    stdout, stderr = app()
    work_msa.output_aln.write_text(stdout)
Exemplo n.º 2
0
    def __call__(self):
        """Calls the underlying alignment method.

        First, validate method, command, and outpath arguments as valid.
        Next, call the underlying method using BioPython commandline
        wrapper or internal method and handle stdout/stderr.
        """
        # Either delegate call to BioPython or run internal method
        if self.method == 'Mafft':
            cmdline = Applications.MafftCommandline(self.cmd,
                                                    input=self.inpath,
                                                    **self.kwargs)
            try:
                stdout, stderr = cmdline()  # Need to log stderr eventually
            except ApplicationError:  # Raised if subprocess return code != 0
                print(
                    "Failed to run MAFFT")  # Should process better eventually
            with open(self.outpath, 'w') as o:
                o.write(stdout)
        elif self.method == 'Generic':
            pass  # To be implemented