Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes mcneilco/acas#728 empty mol files should be considered the same… #201

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,16 @@ public String toSmiles(String molStructure) {
}
}

@Override
public boolean isEmpty(String molStructure) throws CmpdRegMolFormatException {
// Return empty if no atoms bonds or SGroups
CmpdRegMoleculeIndigoImpl mol = new CmpdRegMoleculeIndigoImpl(molStructure);
Boolean hasAtoms = mol.countAtoms() == 0.0;
Boolean hasBonds = mol.countBonds() == 0.0;
Boolean hasSGroups = mol.countGenericSGroups() == 0.0 && mol.countDataSGroups() == 0.0;
return !hasAtoms && !hasBonds && !hasSGroups;
}

@Override
public double getMolWeight(String molStructure) throws CmpdRegMolFormatException {
CmpdRegMoleculeIndigoImpl mol = new CmpdRegMoleculeIndigoImpl(molStructure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1717,10 +1717,30 @@ public boolean deleteStructure(String structureTable, int cdId){
return deleteSuccessful;
}

@Override
public boolean isEmpty(String molStructure) {
MolHandler mh = null;
boolean badStructureFlag = false;
Molecule mol = null;
try {
mh = new MolHandler(molStructure);
mol = mh.getMolecule();
} catch (MolFormatException e) {
badStructureFlag = true;
}

if (!badStructureFlag){
return mol.isEmpty();
} else {
return true;
}
}

@Override
public boolean standardizedMolCompare(String queryMol, String targetMol) throws CmpdRegMolFormatException{
try{
// If both mols are empty then they are equal
if(isEmpty(queryMol) && isEmpty(targetMol)) return true;
CmpdRegMoleculeJChemImpl queryMolWrapper = new CmpdRegMoleculeJChemImpl(queryMol);
CmpdRegMoleculeJChemImpl targetMolWrapper = new CmpdRegMoleculeJChemImpl(queryMol);
StandardizedMolSearch molSearch = new StandardizedMolSearch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,9 @@ public Parent validateParent(Parent parent, Collection<BulkLoadPropertyMappingDT
throw new MissingPropertyException("Stereo category is See Comments, but no stereo comment provided");
}
int[] dupeParentList = {};
if(mainConfig.getServerSettings().getRegisterNoStructureCompoundsAsUniqueParents() && chemStructureService.getMolWeight(parent.getMolStructure()) == 0.0) {
if(mainConfig.getServerSettings().getRegisterNoStructureCompoundsAsUniqueParents() && chemStructureService.isEmpty(parent.getMolStructure()) ) {
//if true then we are no checking this one for hits
logger.warn("mol weight is 0 and registerNoStructureCompoundsAsUniqueParents so not checking for dupe parents by structure but other dupe checking will be done");
logger.warn("mol is empty and registerNoStructureCompoundsAsUniqueParents so not checking for dupe parents by structure but other dupe checking will be done");
} else {
dupeParentList = chemStructureService.checkDupeMol(parent.getMolStructure(), "Parent_Structure", "Parent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,7 @@ public int[] searchMolStructures(String molfile, String structureTable,
public boolean compareStructures(String preMolStruct, String postMolStruct, String string);

public boolean standardizedMolCompare(String queryMol, String targetMol) throws CmpdRegMolFormatException;

public boolean isEmpty(String molFile) throws CmpdRegMolFormatException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public ParentValidationDTO validateUniqueParent(Parent queryParent) throws CmpdR
}
Collection<ParentDTO> dupeParents = new HashSet<ParentDTO>();
int[] dupeParentList = {};
if (mainConfig.getServerSettings().getRegisterNoStructureCompoundsAsUniqueParents() && chemStructureService.getMolWeight(queryParent.getMolStructure()) == 0) {
logger.warn("mol weight is 0 and registerNoStructureCompoundsAsUniqueParents so not checking for dupe parents by structure but other dupe checking will be done");
if (mainConfig.getServerSettings().getRegisterNoStructureCompoundsAsUniqueParents() && chemStructureService.isEmpty(queryParent.getMolStructure()) ) {
logger.warn("mol is empty and registerNoStructureCompoundsAsUniqueParents so not checking for dupe parents by structure but other dupe checking will be done");
} {
dupeParentList = chemStructureService.checkDupeMol(queryParent.getMolStructure(), "Parent_Structure", "Parent");
}
Expand Down Expand Up @@ -237,9 +237,9 @@ public int findPotentialDupeParentStructures(String dupeCheckFile){
CmpdRegSDFWriter dupeMolExporter = cmpdRegSDFWriterFactory.getCmpdRegSDFWriter(dupeCheckFile);
for (Long parentId : parentIds){
parent = Parent.findParent(parentId);
if(registerNoStructureCompoundsAsUniqueParents && chemStructureService.getMolWeight(parent.getMolStructure()) == 0) {
if(registerNoStructureCompoundsAsUniqueParents && chemStructureService.isEmpty(parent.getMolStructure())) {
//if true then we are no checking this one for hits
logger.warn("mol weight is 0 and registerNoStructureCompoundsAsUniqueParents is true so not checking for dupe parent");
logger.warn("mol is empty and registerNoStructureCompoundsAsUniqueParents is true so not checking for dupe parent");
hits = new int[0];
} else {
hits = chemStructureService.searchMolStructures(parent.getMolStructure(), "Parent_Structure", "DUPLICATE_TAUTOMER");
Expand Down