ptosco
February 2, 2023, 3:23pm
1
Hello, I was wondering if it would not be preferable to replace endsWith
with includes
class ChemPackageDetectors extends DG.Package {
static likelyNames = [
'structure', 'mol', 'molecule', 'smiles', 'rdkit',
'canonical_smiles', 'core', 'scaffold'];
// typical r-group names, such as "R1" or "R100-family"
static likelyRegexps = [/[r|R][0-9]+(\W|$)/];
static likelyChemicalName(s) {
return ChemPackageDetectors.likelyNames.some((likelyName) => s.endsWith(likelyName)) ||
ChemPackageDetectors.likelyRegexps.some((regexp) => regexp.test(s));
}
static validSmilesChars = new Uint32Array([0, 671083320, 1073741823, 134217726, 0, 0, 0, 0]);
static validFirstSmilesChars = new Uint32Array([0, 256, 134857308, 573448, 0, 0, 0, 0]);
static numberOfMolsToCheck = 100;
static numberOfMolsToCheckRdKit = 10;
static validChar(pos) {
return (ChemPackageDetectors.validSmilesChars[Math.floor(pos / 0x20)] & (1 << (pos & 0x1f))) !== 0;
Currently certain SMILES strings fail to be perceived as such because the header contains
(SMILES)
between parentheses rather than ending with
SMILES
. I figured that out by looking at the code.
What do you think?
Thanks, cheers
p.
Paolo, thanks a lot, sure it will work better.
1 Like