Removes reads/contigs that contain plasmids, and masks phage sequences.

def clean_sequences(self):
        """Removes reads/contigs that contain plasmids, and masks phage sequences."""
        logging.info('Removing plasmids and masking phages')
        plasmid_db = os.path.join(self.reffilepath, 'plasmidfinder', 'plasmid_database.fa')
        phage_db = os.path.join(self.reffilepath, 'prophages', 'combinedtargets.tfa')
        with progressbar(self.runmetadata.samples) as bar:
            for sample in bar:
                plasmid_removal = 'bbduk.sh ref={} in={} out={} overwrite'\
                    .format(plasmid_db, sample.general.combined, sample.general.combined.replace('.f', '_noplasmid.f'))
                subprocess.call(plasmid_removal, shell=True, stdout=self.devnull, stderr=self.devnull)
                phage_masking = 'bbduk.sh ref={} in={} out={} kmask=N overwrite'\
                    .format(phage_db, sample.general.combined.replace('.f', '_noplasmid.f'),
                            sample.general.combined.replace('.f', '_clean.f'))
                subprocess.call(phage_masking, shell=True, stdout=self.devnull, stderr=self.devnull)
                os.remove(sample.general.combined)
                os.rename(sample.general.combined.replace('.f', '_clean.f'), sample.general.combined)
                os.remove(sample.general.combined.replace('.f', '_noplasmid.f'))