code: def bowtie(self):
          for i in range(self.cpus):
              threads = Thread(target=self.align, args=())
              threads.setDaemon(True)
              threads.start()
          with progressbar(self.metadata) as bar:
              for sample in bar:
                  sample.mapping = GenObject()
                  sagen = sample.general
                  if sagen.bestassemblyfile != "NA":
                      sagen.QualimapResults = os.path.join(sagen.outputdirectory, 'qualimap_results')
                      make_path(sagen.QualimapResults)
                      sagen.sortedbam = os.path.join(sagen.QualimapResults, '{}_sorted.bam'.format(sample.name))
                      filenoext = os.path.splitext(sagen.filteredfile)[0]
                      sagen.filenoext = filenoext
                      sagen.bowtie2results = os.path.join(sagen.QualimapResults, sample.name)
                      bowtie2build = Bowtie2BuildCommandLine(reference=sagen.bestassemblyfile,
                                                             bt2=sagen.bowtie2results)
                      sample.mapping.BamFile = sagen.bowtie2results + "_sorted.bam"
                      samsort = SamtoolsSortCommandline(input=sample.mapping.BamFile,
                                                        o=True,
                                                        out_prefix="-")
                      samtools = [SamtoolsViewCommandline(b=True, S=True, input_file="-"), samsort]
                      indict = {'D': 5, 'R': 1, 'num_mismatches': 0, 'seed_length': 22, 'i_func': "S,0,2.50"}
                      try:
                          _ = sample.general.mergedreads
                          if len(sample.general.trimmedcorrectedfastqfiles) == 2:
                              indict.update({'m1': sample.general.trimmedcorrectedfastqfiles[0],
                                             'm2': sample.general.trimmedcorrectedfastqfiles[1]})
                          else:
                              indict.update({'U': sample.general.trimmedcorrectedfastqfiles[0]})
                      except AttributeError:
                          if len(sample.general.assemblyfastq) == 2:
                              indict.update({'m1': sample.general.assemblyfastq[0],
                                             'm2': sample.general.assemblyfastq[1]})
                          else:
                              indict.update({'U': sample.general.assemblyfastq[0]})
                      bowtie2align = Bowtie2CommandLine(bt2=sagen.bowtie2results,
                                                        threads=self.threads,
                                                        samtools=samtools,
                                                        **indict)
                      sample.commands.bowtie2align = str(bowtie2align)
                      sample.commands.bowtie2build = str(bowtie2build)
                      self.bowqueue.put((sample, sample.commands.bowtie2build, sample.commands.bowtie2align))
                  else:
                      sample.commands.samtools = "NA"
                      sample.mapping.MeanInsertSize = 'NA'
                      sample.mapping.MeanCoveragedata = 'NA'
          self.bowqueue.join()