@datagrok/bio 1.7.9 → 1.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/detectors.js CHANGED
@@ -55,6 +55,20 @@ class BioPackageDetectors extends DG.Package {
55
55
  ['RNA', BioPackageDetectors.RnaFastaAlphabet],
56
56
  ];
57
57
 
58
+ // Check for url column, maybe it is too heavy check
59
+ const isUrlCheck = (s) => {
60
+ let res = true;
61
+ try {
62
+ const url = new URL(s);
63
+ res = true;
64
+ } catch {
65
+ res = false;
66
+ }
67
+ return res;
68
+ };
69
+ const isUrl = DG.Detector.sampleCategories(col, isUrlCheck, 1);
70
+ if (isUrl) return null;
71
+
58
72
  // TODO: Detect HELM sequence
59
73
  // TODO: Lazy calculations could be helpful for performance and convenient for expressing classification logic.
60
74
  const statsAsChars = BioPackageDetectors.getStats(col, 5, BioPackageDetectors.splitterAsChars);
@@ -199,7 +213,7 @@ class BioPackageDetectors extends DG.Package {
199
213
  const alphabetA = [];
200
214
  for (const m of keys) {
201
215
  freqA.push(m in freq ? freq[m] : 0);
202
- alphabetA.push(alphabet.has(m) ? 1 : 0);
216
+ alphabetA.push(alphabet.has(m) ? 10 : -10 /* penalty for character outside alphabet set*/);
203
217
  }
204
218
  /* There were a few ideas: chi-squared, pearson correlation (variance?), scalar product */
205
219
  const cos = BioPackageDetectors.vectorDotProduct(freqA, alphabetA) / (BioPackageDetectors.vectorLength(freqA) * BioPackageDetectors.vectorLength(alphabetA));