Skip to content

Commit 9ce7702

Browse files
committed
added featurestein quantity score
1 parent 83a7133 commit 9ce7702

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/python/pipelines/xchem/featurestein_score.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
### start function definitions #########################################
3434

35-
field_FeatureSteinScore = "FeatureStein_Score"
35+
field_FeatureSteinQualityScore = "FeatureStein_Qual"
36+
field_FeatureSteinQuantityScore = "FeatureStein_Quant"
3637

3738
# Setting up the features to use in FeatureMap
3839
ffact = AllChem.BuildFeatureFactory(os.path.join(RDConfig.RDDataDir, 'BaseFeatures.fdef'))
@@ -54,18 +55,18 @@ def create_feature_map(mol):
5455
return FeatMaps.FeatMap(feats=feats, weights=[1]*len(feats),params=fmaps.params)
5556

5657
def score_featmaps(fm1):
57-
"Generate the score for 2 feature maps"
58+
"""Generate the score for 2 feature maps"""
5859
if fm1.GetNumFeatures() == 0:
59-
return 0
60+
return 0, 0
6061
else:
6162
score = fm1.ScoreFeats(fmaps.GetFeatures())
6263
#utils.log(score, fm1.GetNumFeatures())
63-
return score / fm1.GetNumFeatures()
64+
return score, score / fm1.GetNumFeatures()
6465

65-
def get_fmap_score(mol):
66+
def get_fmap_scores(mol):
6667
featMap = create_feature_map(mol)
67-
score = score_featmaps(featMap)
68-
return score
68+
quantScore, qualScore = score_featmaps(featMap)
69+
return quantScore, qualScore
6970

7071
def process(inputs, writer):
7172
total = 0
@@ -77,11 +78,12 @@ def process(inputs, writer):
7778
errors += 1
7879
continue
7980
try:
80-
score = get_fmap_score(mol)
81+
quantScore, qualScore = get_fmap_scores(mol)
8182
# utils.log('Score:', score)
8283
if total % 1000 == 0:
8384
utils.log('Processed molecule', total, '...')
84-
mol.SetDoubleProp(field_FeatureSteinScore, score)
85+
mol.SetDoubleProp(field_FeatureSteinQualityScore, qualScore)
86+
mol.SetDoubleProp(field_FeatureSteinQuantityScore, quantScore)
8587
writer.write(mol)
8688
success += 1
8789
except:
@@ -115,8 +117,10 @@ def main():
115117

116118
clsMappings = {}
117119
fieldMetaProps = []
118-
clsMappings[field_FeatureSteinScore] = "java.lang.Float"
119-
fieldMetaProps.append({"fieldName":field_FeatureSteinScore, "values": {"source":source, "description":"FeatureStein score"}})
120+
clsMappings[field_FeatureSteinQualityScore] = "java.lang.Float"
121+
clsMappings[field_FeatureSteinQuantityScore] = "java.lang.Float"
122+
fieldMetaProps.append({"fieldName":field_FeatureSteinQualityScore, "values": {"source":source, "description":"FeatureStein quality score"},
123+
"fieldName":field_FeatureSteinQuantityScore, "values": {"source":source, "description":"FeatureStein quantity score"}})
120124

121125
pkl_file = open(args.feat_map, 'rb')
122126
fmaps = pickle.load(pkl_file)

0 commit comments

Comments
 (0)