forked from enviPath/enviPy
Functional Group Calculation (#44)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#44
This commit is contained in:
@ -1438,6 +1438,8 @@ class ApplicabilityDomain(EnviPathModel):
|
||||
reliability_threshold = models.FloatField(blank=False, null=False, default=0.5)
|
||||
local_compatibilty_threshold = models.FloatField(blank=False, null=False, default=0.5)
|
||||
|
||||
functional_groups = models.JSONField(blank=True, null=True, default=dict)
|
||||
|
||||
@staticmethod
|
||||
@transaction.atomic
|
||||
def create(mlrr: MLRelativeReasoning, num_neighbours: int = 5, reliability_threshold: float = 0.5,
|
||||
@ -1474,6 +1476,15 @@ class ApplicabilityDomain(EnviPathModel):
|
||||
ad = ApplicabilityDomainPCA(num_neighbours=self.num_neighbours)
|
||||
ad.build(ds)
|
||||
|
||||
# Collect functional Groups together with their counts for reactivity center highlighting
|
||||
functional_groups_counts = defaultdict(int)
|
||||
for cs in CompoundStructure.objects.filter(compound__package__in=self.model.data_packages.all()):
|
||||
for fg in FormatConverter.get_functional_groups(cs.smiles):
|
||||
functional_groups_counts[fg] += 1
|
||||
|
||||
self.functional_groups = dict(functional_groups_counts)
|
||||
self.save()
|
||||
|
||||
end = datetime.now()
|
||||
logger.debug(f"fitting app domain pca took {(end - start).total_seconds()} seconds")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user