Skip to content
Snippets Groups Projects
Commit 08f1a1dc authored by yakomaxa's avatar yakomaxa
Browse files

Added experimental within to rasmol

parent 11bf3522
No related branches found
No related tags found
No related merge requests found
Debugger entered--Lisp error: (void-variable *)
eval(* nil)
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)
command-execute(eval-last-sexp)
...@@ -46,7 +46,7 @@ export const operators: OperatorList = [ ...@@ -46,7 +46,7 @@ export const operators: OperatorList = [
'@examples': ['within 5 of name FE'], '@examples': ['within 5 of name FE'],
name: 'within', name: 'within',
type: h.prefix, type: h.prefix,
rule: h.prefixOp(/WITHIN\s+([-+]?[0-9]*\.?[0-9]+)\s+OF/i, 1).map((x: any) => parseFloat(x)), rule: h.prefixOp(/within\s+([-+]?[0-9]*\.?[0-9]+)\s+of/, 1).map((x: any) => parseFloat(x)),
map: (radius: number, selection: Expression) => { map: (radius: number, selection: Expression) => {
return B.struct.modifier.includeSurroundings({ 0: selection, radius }); return B.struct.modifier.includeSurroundings({ 0: selection, radius });
} }
......
...@@ -34,6 +34,8 @@ const colon = P.MonadicParser.string(':'); ...@@ -34,6 +34,8 @@ const colon = P.MonadicParser.string(':');
const star = P.MonadicParser.string('*'); const star = P.MonadicParser.string('*');
const bra = P.MonadicParser.string('('); const bra = P.MonadicParser.string('(');
const ket = P.MonadicParser.string(')'); const ket = P.MonadicParser.string(')');
const commu = P.MonadicParser.string('[');
const tator = P.MonadicParser.string(']');
/* is Parser -> MonadicParser substitution correct? */ /* is Parser -> MonadicParser substitution correct? */
...@@ -63,6 +65,33 @@ function atomSelectionQuery2(x: any) { ...@@ -63,6 +65,33 @@ function atomSelectionQuery2(x: any) {
return B.struct.generator.atomGroups(tests); return B.struct.generator.atomGroups(tests);
} }
function atomExpressionQuery(x: any[]) {
const resname = x[0];
// const tests: AtomGroupArgs = {};
/* if (chainname) {
// should be configurable, there is an option in Jmol to use auth or label
tests['chain-test'] = B.core.rel.eq([B.ammp('auth_asym_id'), chainname]);
}
const resProps = [];
if (resno) resProps.push(B.core.rel.eq([B.ammp('auth_seq_id'), resno]));
if (inscode) resProps.push(B.core.rel.eq([B.ammp('pdbx_PDB_ins_code'), inscode]));
if (resProps.length) tests['residue-test'] = h.andExpr(resProps);
const atomProps = [];
if (atomname) atomProps.push(B.core.rel.eq([B.ammp('auth_atom_id'), atomname]));
if (altloc) atomProps.push(B.core.rel.eq([B.ammp('label_alt_id'), altloc]));
if (atomProps.length) tests['atom-test'] = h.andExpr(atomProps);
return B.struct.generator.atomGroups(tests);
*/
if (resname){
return B.struct.generator.atomGroups({'residue-test': B.core.rel.eq([B.ammp('label_comp_id'), resname])})
}
}
const lang = P.MonadicParser.createLanguage({ const lang = P.MonadicParser.createLanguage({
...@@ -71,7 +100,7 @@ const lang = P.MonadicParser.createLanguage({ ...@@ -71,7 +100,7 @@ const lang = P.MonadicParser.createLanguage({
r.Parens, r.Parens,
r.Operator, r.Operator,
r.Expression r.Expression
).wrap(P.MonadicParser.string('['), P.MonadicParser.string(']')); ).wrap(P.MonadicParser.string('{'), P.MonadicParser.string('}'));
}, },
Expression: function (r: any) { Expression: function (r: any) {
...@@ -80,6 +109,7 @@ const lang = P.MonadicParser.createLanguage({ ...@@ -80,6 +109,7 @@ const lang = P.MonadicParser.createLanguage({
r.Keywords, r.Keywords,
r.NamedAtomProperties, r.NamedAtomProperties,
r.AtomSelectionMacro.map(atomSelectionQuery2), r.AtomSelectionMacro.map(atomSelectionQuery2),
// r.AtomExpression.map(atomExpressionQuery),
r.Object r.Object
); );
}, },
...@@ -133,38 +163,40 @@ const lang = P.MonadicParser.createLanguage({ ...@@ -133,38 +163,40 @@ const lang = P.MonadicParser.createLanguage({
) )
)), )),
// lys:a.ca lys:a lys lys.ca // lys:a.ca lys:a lys lys.ca
// [lys]:a.ca [lys]:a [lys] [lys].ca
commu.then(P.MonadicParser.alt(
P.MonadicParser.alt( P.MonadicParser.alt(
P.MonadicParser.alt( P.MonadicParser.alt(
P.MonadicParser.seq( P.MonadicParser.seq(
orNull(propertiesDict.resn).skip(colon), orNull(propertiesDict.resn).skip(tator).skip(colon),
orNull(propertiesDict.chain).skip(dot), orNull(propertiesDict.chain).skip(dot),
orNull(propertiesDict.name) orNull(propertiesDict.name)
).map(x => { return { resn: x[0], chain: x[1], name: x[2] }; }), ).map(x => { return { resn: x[0], chain: x[1], name: x[2] }; }),
P.MonadicParser.seq( P.MonadicParser.seq(
orNull(propertiesDict.resn).skip(star), orNull(propertiesDict.resn).skip(tator).skip(star),
orNull(propertiesDict.chain).skip(dot), orNull(propertiesDict.chain).skip(dot),
orNull(propertiesDict.name) orNull(propertiesDict.name)
).map(x => { return { resn: x[0], chain: x[1], name: x[2] }; }), ).map(x => { return { resn: x[0], chain: x[1], name: x[2] }; }),
P.MonadicParser.seq( P.MonadicParser.seq(
orNull(propertiesDict.resn).skip(colon), orNull(propertiesDict.resn).skip(tator).skip(colon),
orNull(propertiesDict.chain), orNull(propertiesDict.chain),
).map(x => { return { resn: x[0], chain: x[1] }; }), ).map(x => { return { resn: x[0], chain: x[1] }; }),
P.MonadicParser.seq( P.MonadicParser.seq(
orNull(propertiesDict.resn).skip(star), orNull(propertiesDict.resn).skip(tator).skip(star),
orNull(propertiesDict.chain), orNull(propertiesDict.chain),
).map(x => { return { resn: x[0], chain: x[1] }; }), ).map(x => { return { resn: x[0], chain: x[1] }; }),
P.MonadicParser.seq( P.MonadicParser.seq(
orNull(propertiesDict.resn).skip(dot), orNull(propertiesDict.resn).skip(tator).skip(dot),
orNull(propertiesDict.name), orNull(propertiesDict.name),
).map(x => { return { resn: x[0], name: x[1] }; }), ).map(x => { return { resn: x[0], name: x[1] }; }),
P.MonadicParser.seq( P.MonadicParser.seq(
orNull(propertiesDict.resn), orNull(propertiesDict.resn).skip(tator),
).map(x => { return { resn: x[0] }; }), ).map(x => { return { resn: x[0]}; })
)
)
)
) )
) )
);
}, },
ObjectProperty: () => { ObjectProperty: () => {
...@@ -184,6 +216,14 @@ const lang = P.MonadicParser.createLanguage({ ...@@ -184,6 +216,14 @@ const lang = P.MonadicParser.createLanguage({
.map((x: any) => { throw new Error(`property 'object' not supported, value '${x}'`); }); .map((x: any) => { throw new Error(`property 'object' not supported, value '${x}'`); });
}, },
AtomExpression: function (r: any) {
return P.MonadicParser.seq(r.Resname.or(P.MonadicParser.of(null)));
},
// Resname: () => P.MonadicParser.regexp(s/[a-zA-Z0-9]{1,4}/).desc('resname'),
Resname: () => P.MonadicParser.regexp(/\[[A-Z0-9]{1,4}\]/).desc('resname'),
NamedAtomProperties: function () { NamedAtomProperties: function () {
return P.MonadicParser.alt(...h.getNamedPropertyRules(properties)); return P.MonadicParser.alt(...h.getNamedPropertyRules(properties));
}, },
......
/** \[/**
* Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment