Browse Source

wip query mode

JonStargaryen 4 years ago
parent
commit
52e011ade9
2 changed files with 11 additions and 2 deletions
  1. 9 0
      src/servers/model/server/api.ts
  2. 2 2
      src/servers/model/server/query.ts

+ 9 - 0
src/servers/model/server/api.ts

@@ -129,6 +129,15 @@ function Q<Params = any>(definition: Partial<QueryDefinition<Params>>) {
 
 const QueryMap = {
     'full': Q<{} | undefined>({ niceName: 'Full Structure', query: () => Queries.generators.all, description: 'The full structure.' }),
+    'ligand': Q<{ atom_site: AtomSiteSchema }>({
+        niceName: 'Ligand',
+        description: 'Coordinates of the first group satisfying the given criteria.',
+        query: p => {
+            return Queries.combinators.merge(getAtomsTests(p.atom_site).map(test => Queries.generators.atoms(test)));
+        },
+        jsonParams: [ AtomSiteTestJsonParam ],
+        restParams: AtomSiteTestRestParams
+    }),
     'atoms': Q<{ atom_site: AtomSiteSchema }>({
         niceName: 'Atoms',
         description: 'Atoms satisfying the given criteria.',

+ 2 - 2
src/servers/model/server/query.ts

@@ -81,8 +81,8 @@ function createEncoder(job: Job): Encoder {
 
 function ensureCompatibleQueryType(job: Job) {
     job.entries.forEach(e => {
-        if (e.queryDefinition.niceName !== 'Atoms') {
-            throw Error("sdf and mol2 encoding are only available for queries of type 'Atoms'");
+        if (e.queryDefinition.niceName !== 'Ligand') {
+            throw Error("sdf and mol2 encoding are only available for queries of type 'Ligand'");
         }
     });
 }