Prep

def recon(self):
        """
        Prep
        """
        logging.info('Running MOB-recon on Assemblies')
        with progressbar(self.metadata) as bar:
            commands = list()
            for sample in bar:
                # Create and populate the mob_recon genobject
                setattr(sample, self.analysistype, GenObject())
                sample[self.analysistype].outputdir = os.path.join(sample.general.outputdirectory, self.analysistype)
                sample[self.analysistype].contig_report = os.path.join(sample[self.analysistype].outputdir,
                                                                       'contig_report.txt')
                sample[self.analysistype].report_dict = dict()
                sample[self.analysistype].logout = os.path.join(sample[self.analysistype].outputdir, 'out')
                sample[self.analysistype].logerr = os.path.join(sample[self.analysistype].outputdir, 'err')
                make_path(sample[self.analysistype].outputdir)
                if sample.general.bestassemblyfile != 'NA':
                    sample.commands.mobrecon = 'mob_recon -i {fasta} -o {outdir} --run_typer -n {threads} -d {db}'\
                        .format(fasta=sample.general.bestassemblyfile,
                                outdir=sample[self.analysistype].outputdir,
                                threads=self.threads,
                                db=os.path.join(self.databasepath, 'mob_suite'))
                    # Ensure that the report doesn't already exist
                    if not os.path.isfile(sample[self.analysistype].contig_report):
                        # Run the analyses
                        commands.append(sample.commands.mobrecon)
            p = multiprocessing.Pool(processes=self.threads)
            out_err = p.map(MobRecon.run_cmd, commands)
            p.close()
            p.join()
            # At this point, out_err has a list of tuples with out as index 0 in each tuple and
            # err at index 1 in each tuple. These will be in the same order as the samples, so retrieve them by index.
            index = 0
            for sample in bar:
                # Write the outputs to the log file
                out = out_err[index][0]
                err = out_err[index][1]
                write_to_logfile(out=sample.commands.mobrecon,
                                 err=sample.commands.mobrecon,
                                 logfile=self.logfile,
                                 samplelog=sample.general.logout,
                                 sampleerr=sample.general.logerr,
                                 analysislog=sample[self.analysistype].logout,
                                 analysiserr=sample[self.analysistype].logerr)
                write_to_logfile(out=out,
                                 err=err,
                                 logfile=self.logfile,
                                 samplelog=sample.general.logout,
                                 sampleerr=sample.general.logerr,
                                 analysislog=sample[self.analysistype].logout,
                                 analysiserr=sample[self.analysistype].logerr)
                index += 1