code: def contamination_finder(self, input_path=None, report_path=None):
          logging.info('Calculating contamination in reads')
          if input_path is not None:
              input_dir = input_path
          else:
              input_dir = self.path
          if report_path is not None:
              reportpath = report_path
          else:
              reportpath = os.path.join(input_dir, 'confindr')
          confindr_report = os.path.join(input_dir, 'confindr', 'confindr_report.csv')
          pipeline_report = os.path.join(reportpath, 'confindr_report.csv')
          if not os.path.isfile(confindr_report):
              try:
                  shutil.rmtree(reportpath)
              except IOError:
                  pass
              make_path(reportpath)
              systemcall = 'confindr.py -i {input_dir} -o {output_dir} -d {database_dir} -bf 0.05'\
                  .format(input_dir=input_dir,
                          output_dir=os.path.join(input_dir, 'confindr'),
                          database_dir=os.path.join(self.reffilepath, 'ConFindr', 'databases'))
              out, err = run_subprocess(systemcall)
              write_to_logfile(systemcall, systemcall, self.logfile, None, None, None, None)
              write_to_logfile(out, err, self.logfile, None, None, None, None)
              logging.info('Contamination detection complete!')
          confindr_results = pandas.read_csv(confindr_report, index_col=0).T.to_dict()
          for sample in self.metadata:
              sample.confindr = GenObject()
              for line in confindr_results:
                  if sample.name in line:
                      sample.confindr.genus = confindr_results[line]['Genus'] if type(confindr_results[line]['Genus']) \
                                                                                 is not float else 'ND'
                      sample.confindr.num_contaminated_snvs = confindr_results[line]['NumContamSNVs']
                      sample.confindr.contam_status = confindr_results[line]['ContamStatus']
                      try:
                          sample.confindr.percent_contam = confindr_results[line]['PercentContam'] if \
                              str(confindr_results[line]['PercentContam']) != 'nan' else 0
                      except KeyError:
                          sample.confindr.percent_contam = 'ND'
                      try:
                          sample.confindr.percent_contam_std = \
                              confindr_results[line]['PercentContamStandardDeviation'] if \
                              str(confindr_results[line]['PercentContamStandardDeviation']) != 'nan' else 0
                      except KeyError:
                          sample.confindr.percent_contam_std = 'ND'
                      if sample.confindr.contam_status is True:
                          sample.confindr.contam_status = 'Contaminated'
                      elif sample.confindr.contam_status is False:
                          sample.confindr.contam_status = 'Clean'
          with open(pipeline_report, 'w') as csv:
              data = 'Strain,Genus,NumContamSNVs,ContamStatus,PercentContam,PercentContamSTD\n'
              for sample in self.metadata:
                  data += '{str},{genus},{numcontamsnv},{status},{pc},{pcs}\n'.format(
                      str=sample.name,
                      genus=sample.confindr.genus,
                      numcontamsnv=sample.confindr.num_contaminated_snvs,
                      status=sample.confindr.contam_status,
                      pc=sample.confindr.percent_contam,
                      pcs=sample.confindr.percent_contam_std
                  )
              csv.write(data)