def test1_encrypt(self): cmn.sam2bam(self.RESOURCE_PATH + 'encrypt/input.sam', self.RESOURCE_PATH + 'encrypt/input.bam') pysam.index(self.RESOURCE_PATH + 'encrypt/input.bam') Vac.text2vac(self.RESOURCE_PATH + 'encrypt/input.vac.txt', self.RESOURCE_PATH + 'encrypt/input.vac') with open(self.RESOURCE_PATH + 'admin', 'r') as key_file, \ open(self.RESOURCE_PATH + 'admin.pub', 'r') as pub_key_file: rsa_key = RSA.importKey(key_file.read(), passphrase=self.KEY_PASS) rsa_pub_key = RSA.importKey(pub_key_file.read()) # creates DIFF with secret self.locker.encrypt( rsa_sign_key=rsa_key, rsa_enc_key=rsa_pub_key, bam_filename=self.RESOURCE_PATH + 'encrypt/input.bam', vac_filename=self.RESOURCE_PATH + 'encrypt/input.vac', out_bam_filename=self.RESOURCE_PATH + 'encrypt/output.mut.bam', out_enc_diff_filename=self.RESOURCE_PATH + 'encrypt/output.diff.enc', mut_p=0) pysam.index(self.RESOURCE_PATH + 'encrypt/output.mut.bam') cmn.bam2sam(self.RESOURCE_PATH + 'encrypt/output.mut.bam', self.RESOURCE_PATH + 'encrypt/output.mut.sam')
def test_mutate_02(self): # EOF VAC case Vac.text2vac(self.RESOURCE_PATH + 'input_02.vac.txt', self.RESOURCE_PATH + 'input_02.vac') bdiff_file = self._mut.mutate( vac_filename=self.RESOURCE_PATH + 'input_02.vac', mut_bam_filename=self.RESOURCE_PATH + 'output_02.bam', secret=self.SECRET, mut_p=0, rng=self._rnd ) self.assertEqual(21, self._mut.stat(BamMutator.STAT_ALIGNMENT_COUNT)) self.assertEqual(13, self._mut.stat(BamMutator.STAT_COVERING_COUNT)) self.assertEqual(7, self._mut.stat(BamMutator.STAT_VAC_COUNT)) self.assertEqual(6, self._mut.stat(BamMutator.STAT_MUT_COUNT)) self.assertEqual(4, self._mut.stat(BamMutator.STAT_DIFF_COUNT)) self.assertEqual(6, self._mut.stat(BamMutator.STAT_ALIGNMENT_MUT_COUNT)) cmn.bam2sam(self.RESOURCE_PATH + 'output_02.bam', self.RESOURCE_PATH + 'output_02.sam') self.assertTrue(filecmp.cmp( self.RESOURCE_PATH + 'desired_02.sam', self.RESOURCE_PATH + 'output_02.sam' )) BdiffIO.to_text_file(bdiff_file, self.RESOURCE_PATH + 'output_02.diff.txt') is_equal = filecmp.cmp(self.RESOURCE_PATH + 'desired_02.diff.txt', self.RESOURCE_PATH + 'output_02.diff.txt') self.assertTrue(is_equal)
def test_mask(self): # EOF BAM case Vac.text2vac(self.RESOURCE_PATH + 'input.vac.txt', self.RESOURCE_PATH + 'input.vac') bdiff_file = self._mut.mutate( vac_filename=self.RESOURCE_PATH + 'input.vac', mut_bam_filename=self.RESOURCE_PATH + 'output.bam', secret=self.SECRET, mut_p=0, rng=self._rng) cmn.bam2sam(self.RESOURCE_PATH + 'output.bam', self.RESOURCE_PATH + 'output.sam') BdiffIO.to_text_file(bdiff_file, self.RESOURCE_PATH + 'output.diff.txt') self.assertTrue( filecmp.cmp(self.RESOURCE_PATH + 'desired.sam', self.RESOURCE_PATH + 'output.sam')) self.assertTrue( filecmp.cmp(self.RESOURCE_PATH + 'desired.diff.txt', self.RESOURCE_PATH + 'output.diff.txt'))