Exemplo n.º 1
0
 def test_calculate_desc_feat_multiple(self):
     self.defineConfig()
     tempFilePath=curDir+"/output/tmp/ecfp_feat_multiple.npy"
     with open(self.referenceFilePath,"r") as h:
         smiles=[line.strip() for line in h.readlines()]
         ecfps=chem_utils.run_fingerprint(smiles,1)
         desc=chem_utils.make_desc_dict(ecfps)
         #np.save("unit_test/output/test_calculate_desc.npy",desc)   #write reference fingperprints
         np.save(tempFilePath,desc)   #write reference fingperprints
         result=filecmp.cmp("unit_test/output/test_calculate_desc.npy",tempFilePath, shallow=False)
         self.assertEqual(result, True)
Exemplo n.º 2
0
    def test_run_fingerprint(self):
        """Test to build fingerprints from prepared smiles"""

        self.defineConfig()
        tempFilePath = curDir + "/output/tmp/fp_out.npy"
        fpReferenceFilePath = curDir + "/output/test_run_fingerprint_ref.npy"
        with open(self.referenceFilePath, "r") as h:
            smiles = [line.strip() for line in h.readlines()]
            fps2 = chem_utils.run_fingerprint(smiles, 2)
            fps4 = chem_utils.run_fingerprint(smiles, 4)
            #np.save("unit_test/output/test_run_fingerprint_ref.npy",fps2)   #write reference fingperprints
            np.save(tempFilePath, fps2)  #write reference fingperprints
            result = filecmp.cmp(fpReferenceFilePath,
                                 tempFilePath,
                                 shallow=False)
            np.save(tempFilePath, fps4)  #write reference fingperprints
            result2 = filecmp.cmp(fpReferenceFilePath,
                                  tempFilePath,
                                  shallow=False)
            os.remove(tempFilePath)
            self.assertEqual(result and result2, True)
Exemplo n.º 3
0
    def test_calculate_desc_val_single(self):
        self.defineConfig()
        tempFilePath=curDir+"/output/tmp/ecfp_val.npy"

        ecfp=chem_utils.run_fingerprint(["Cc1ccc(S(=O)(=O)Nc2ccc(-c3nc4cc(NS(=O)(=O)c5ccc(C)cc5)ccc4[nH]3)cc2)cc1"],1)
        ecfp_feat, ecfp_val=chem_utils.make_desc_dict(ecfp)
        #np.save("unit_test/output/test_calculate_desc_val.npy",ecfp_val)   #write reference fingperprints
        np.save(tempFilePath,ecfp_val)   #write reference fingperprints

        result=filecmp.cmp("unit_test/output/test_calculate_desc_val.npy",tempFilePath, shallow=False)

        self.assertEqual(result, True)
Exemplo n.º 4
0
    def test_scramble_desc_multiple_key(self):
        """test if scrambling is depending on the input key"""
        self.defineConfigNewSecret()
        tempFilePathFeat=curDir+"/output/tmp/ecfp_feat_scrambled.npy"
        tempFilePathVal=curDir+"/output/tmp/ecfp_val_scrambled.npy"

        with open(self.referenceFilePath,"r") as h:
            smiles=[line.strip() for line in h.readlines()]
            ecfps=chem_utils.run_fingerprint(smiles,1)
            ecfp_feat, ecfp_val = chem_utils.make_desc_dict(ecfps)
            ecfp_feat_scrambled,ecfp_val_scrambled=chem_utils.make_fp_lists(ecfp_feat,ecfp_val)
            np.save(tempFilePathFeat,ecfp_feat_scrambled)   
            np.save(tempFilePathVal,ecfp_val_scrambled)
            resultFeat=filecmp.cmp("unit_test/output/test_calculate_desc_feat_scr.npy",tempFilePathFeat, shallow=False)
            resultVal=filecmp.cmp("unit_test/output/test_calculate_desc_val_scr.npy",tempFilePathVal, shallow=False)
            self.assertEqual(resultFeat & resultVal, False)
Exemplo n.º 5
0
    def test_scramble_desc_multiple(self):
        """test if scrambling input fp's is working compared to a reference"""
        self.defineConfig()
        tempFilePathFeat=curDir+"/output/tmp/ecfp_feat_scrambled.npy"
        tempFilePathVal=curDir+"/output/tmp/ecfp_val_scrambled.npy"

        with open(self.referenceFilePath,"r") as h:
            smiles=[line.strip() for line in h.readlines()]
            ecfps=chem_utils.run_fingerprint(smiles,1)
            ecfp_feat, ecfp_val = chem_utils.make_desc_dict(ecfps)
            ecfp_feat_scrambled,ecfp_val_scrambled=chem_utils.make_fp_lists(ecfp_feat,ecfp_val)
            #np.save("unit_test/output/test_calculate_desc_feat_scr.npy",ecfp_feat_scrambled)   #write reference fingperprints
            #np.save("unit_test/output/test_calculate_desc_val_scr.npy",ecfp_val_scrambled)   #write reference fingperprints
            np.save(tempFilePathFeat,ecfp_feat_scrambled)   
            np.save(tempFilePathVal,ecfp_val_scrambled)
            resultFeat=filecmp.cmp("unit_test/output/test_calculate_desc_feat_scr.npy",tempFilePathFeat, shallow=False)
            resultVal=filecmp.cmp("unit_test/output/test_calculate_desc_val_scr.npy",tempFilePathVal, shallow=False)
            self.assertEqual(resultFeat & resultVal, True)