示例#1
0
  def test_run_snp_sites(self):
    builder = SNPFeatureBuilder()

    fasta_filename = os.path.join(test_data(), 'file_with_SNPs.aln')

    with context_aware_tempdir() as output_directory:
      stdout, stderr = builder._run_snp_sites('snp-sites', {},
                                             fasta_filename,
                                             output_directory)

      expected_output_filename = os.path.join(output_directory, 'all_snps.vcf')
      self.assertTrue(os.path.isfile(expected_output_filename))
示例#2
0
    def create_vcf_from_sequences(self):
        with context_aware_tempfile('w', delete=False) as temp_fasta_file:
            try:
                self.vcf_input_file.remove()
            except AttributeError:
                # The file might have already been deleted or might not have been created
                # by us so we shouldn't delete it.
                pass
            self.vcf_input_file = DeletableFile(
                tempfile.NamedTemporaryFile('w', delete=False))
            self.logger.info("Writing sequences to %s" % temp_fasta_file.name)
            self._write_sequences(self.sequences.values(), temp_fasta_file)
            temp_fasta_file.close()
            self.vcf_input_file.close()

            with context_aware_tempdir() as output_directory:
                self.logger.info("Writing snps to %s" %
                                 self.vcf_input_file.name)
                self._run_snp_sites(self.snp_sites_exec,
                                    {'-o': self.vcf_input_file.name},
                                    temp_fasta_file.name, output_directory)

            self.vcf_input_file = DeletableFile(
                open(self.vcf_input_file.name, 'r'))
示例#3
0
 def context_aware_tempdir_mock(*args, **kwargs):
   with context_aware_tempdir(*args, **kwargs) as tempdir:
     folder_names.append(tempdir)
     yield tempdir