Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
ba78a855
Commit
ba78a855
authored
2 years ago
by
yakomaxa
Browse files
Options
Downloads
Patches
Plain Diff
Finally enabled selection by negative-valued residue index
parent
513be043
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-script/transpilers/rasmol/operators.ts
+16
-16
16 additions, 16 deletions
src/mol-script/transpilers/rasmol/operators.ts
src/mol-script/transpilers/rasmol/parser.ts
+39
-55
39 additions, 55 deletions
src/mol-script/transpilers/rasmol/parser.ts
with
55 additions
and
71 deletions
src/mol-script/transpilers/rasmol/operators.ts
+
16
−
16
View file @
ba78a855
...
...
@@ -13,6 +13,22 @@ import { OperatorList } from '../types';
import
{
Expression
}
from
'
../../language/expression
'
;
export
const
operators
:
OperatorList
=
[
{
'
@desc
'
:
'
Selects atoms in s1 that are within X Angstroms of any atom in s2.
'
,
'
@examples
'
:
[
'
within(5.0, [HEM])
'
],
name
:
'
within
'
,
type
:
h
.
prefixRemoveKet
,
rule
:
h
.
prefixOpNoWhiteSpace
(
/within
\s
*
\(\s
*
([
-+
]?[
0-9
]
*
\.?[
0-9
]
+
)\s
*,/
,
1
).
map
((
x
:
any
)
=>
{
return
parseFloat
(
x
);
}),
map
:
(
radius
:
number
,
target
:
Expression
)
=>
{
return
B
.
struct
.
filter
.
within
({
0
:
B
.
struct
.
generator
.
all
(),
target
,
'
max-radius
'
:
radius
,
});
},
},
{
'
@desc
'
:
'
Selects atoms that are not included in s1.
'
,
'
@examples
'
:
[
'
not [ARG]
'
],
...
...
@@ -38,21 +54,5 @@ export const operators: OperatorList = [
rule
:
P
.
MonadicParser
.
alt
(
h
.
infixOp
(
/OR|
\|
|
\|\|
|,/i
)),
map
:
(
op
,
s1
,
s2
)
=>
B
.
struct
.
combinator
.
merge
([
s1
,
s2
])
},
{
'
@desc
'
:
'
Selects atoms in s1 that are within X Angstroms of any atom in s2.
'
,
'
@examples
'
:
[
'
within(5.0, [HEM])
'
],
name
:
'
within
'
,
type
:
h
.
prefixRemoveKet
,
rule
:
h
.
prefixOpNoWhiteSpace
(
/within
\s
*
\(\s
*
([
-+
]?[
0-9
]
*
\.?[
0-9
]
+
)\s
*,/i
,
1
).
map
((
x
:
any
)
=>
{
return
parseFloat
(
x
);
}),
map
:
(
radius
:
number
,
target
:
Expression
)
=>
{
return
B
.
struct
.
filter
.
within
({
0
:
B
.
struct
.
generator
.
all
(),
target
,
'
max-radius
'
:
radius
,
});
},
},
];
This diff is collapsed.
Click to expand it.
src/mol-script/transpilers/rasmol/parser.ts
+
39
−
55
View file @
ba78a855
...
...
@@ -20,63 +20,61 @@ import { Transpiler } from '../transpiler';
function
listMap
(
x
:
string
)
{
return
x
.
split
(
'
,
'
).
map
(
x
=>
x
.
replace
(
/^
[
"'
]
|
[
"'
]
$/g
,
''
));
}
function
listOrRangeMap
(
x
:
string
)
{
// cases
// cases
// case1: 1-100,200
console
.
log
(
x
)
if
(
x
.
includes
(
'
-
'
)
&&
x
.
includes
(
'
,
'
))
{
const
pSplit
=
x
.
split
(
'
,
'
).
map
(
x
=>
x
.
replace
(
/^
[
"'
]
|
[
"'
]
$/g
,
''
));
const
res
:
number
[]
=
[];
pSplit
.
forEach
(
x
=>
{
if
(
x
.
includes
(
'
-
'
)
&&
!
x
.
startsWith
(
"
-
"
))
{
if
(
x
.
includes
(
'
-
'
)
&&
!
x
.
startsWith
(
'
-
'
))
{
const
[
min
,
max
]
=
x
.
split
(
'
-
'
).
map
(
x
=>
parseInt
(
x
));
for
(
let
i
=
min
;
i
<=
max
;
i
++
)
{
res
.
push
(
i
);
}
}
else
if
(
x
.
includes
(
'
-
'
)
&&
x
.
startsWith
(
"
-
"
)
&&
x
.
match
(
/
[
0-9
]
+-
[
-0-9
]
+/
))
{
const
min
=
-
parseInt
(
x
.
split
(
'
-
'
)[
1
]);
var
max
;
if
(
x
.
includes
(
'
--
'
))
{
max
=
-
parseInt
(
x
.
split
(
'
-
'
)[
3
])
}
else
{
max
=
parseInt
(
x
.
split
(
'
-
'
)[
2
])
}
for
(
let
i
=
min
;
i
<=
max
;
i
++
)
{
}
else
if
(
x
.
includes
(
'
-
'
)
&&
x
.
startsWith
(
'
-
'
)
&&
x
.
match
(
/
[
0-9
]
+-
[
-0-9
]
+/
))
{
const
min
=
-
parseInt
(
x
.
split
(
'
-
'
)[
1
]);
let
max
;
if
(
x
.
includes
(
'
--
'
))
{
max
=
-
parseInt
(
x
.
split
(
'
-
'
)[
3
])
;
}
else
{
max
=
parseInt
(
x
.
split
(
'
-
'
)[
2
])
;
}
for
(
let
i
=
min
;
i
<=
max
;
i
++
)
{
res
.
push
(
i
);
}
}
else
if
(
x
.
includes
(
'
-
'
)
&&
x
.
startsWith
(
"
-
"
)
&&
!
x
.
match
(
/
[
0-9
]
+-
[
-0-9
]
+/
))
{
res
.
push
(
parseInt
(
x
));
}
else
{
}
}
else
if
(
x
.
includes
(
'
-
'
)
&&
x
.
startsWith
(
'
-
'
)
&&
!
x
.
match
(
/
[
0-9
]
+-
[
-0-9
]
+/
))
{
res
.
push
(
parseInt
(
x
));
}
else
{
res
.
push
(
parseInt
(
x
));
}
});
return
res
;
}
else
if
(
x
.
includes
(
'
-
'
)
&&
!
x
.
includes
(
'
,
'
))
{
const
res
:
number
[]
=
[];
if
(
!
x
.
startsWith
(
"
-
"
))
{
const
res
:
number
[]
=
[];
if
(
!
x
.
startsWith
(
'
-
'
))
{
const
[
min
,
max
]
=
x
.
split
(
'
-
'
).
map
(
x
=>
parseInt
(
x
));
for
(
let
i
=
min
;
i
<=
max
;
i
++
)
{
res
.
push
(
i
);
res
.
push
(
i
);
}
}
else
if
(
x
.
startsWith
(
"
-
"
)
&&
x
.
match
(
/
[
0-9
]
+-
[
-0-9
]
+/
))
{
}
else
if
(
x
.
startsWith
(
'
-
'
)
&&
x
.
match
(
/
[
0-9
]
+-
[
-0-9
]
+/
))
{
const
min
=
-
parseInt
(
x
.
split
(
'
-
'
)[
1
]);
console
.
log
(
min
)
var
max
;
let
max
;
if
(
x
.
includes
(
'
--
'
))
{
max
=
-
parseInt
(
x
.
split
(
'
-
'
)[
3
])
}
else
{
max
=
parseInt
(
x
.
split
(
'
-
'
)[
2
])
max
=
-
parseInt
(
x
.
split
(
'
-
'
)[
3
])
;
}
else
{
max
=
parseInt
(
x
.
split
(
'
-
'
)[
2
])
;
}
for
(
let
i
=
min
;
i
<=
max
;
i
++
)
{
res
.
push
(
i
);
}
}
else
if
(
x
.
startsWith
(
"
-
"
)
&&
!
x
.
match
(
/
[
0-9
]
+-
[
-0-9
]
+/
))
{
res
.
push
(
i
);
}
}
else
if
(
x
.
startsWith
(
'
-
'
)
&&
!
x
.
match
(
/
[
0-9
]
+-
[
-0-9
]
+/
))
{
res
.
push
(
parseInt
(
x
));
}
else
{
}
else
{
res
.
push
(
parseInt
(
x
));
}
return
res
;
}
return
res
;
}
else
if
(
!
x
.
includes
(
'
-
'
)
&&
x
.
includes
(
'
,
'
))
{
return
listMap
(
x
).
map
(
x
=>
parseInt
(
x
));
return
listMap
(
x
).
map
(
x
=>
parseInt
(
x
));
}
else
{
return
[
parseInt
(
x
)];
}
...
...
@@ -118,7 +116,7 @@ function atomSelectionQuery2(x: any) {
function
atomExpressionQuery
(
x
:
any
[])
{
const
[
resnorange
,
resno
,
inscode
,
chainname
,
atomname
,
altloc
]
=
x
[
1
];
//const [resnorange, inscode, chainname, atomname, altloc] = x[1];
//
const [resnorange, inscode, chainname, atomname, altloc] = x[1];
const
tests
:
AtomGroupArgs
=
{};
if
(
chainname
)
{
...
...
@@ -136,7 +134,6 @@ function atomExpressionQuery(x: any[]) {
const
resProps
:
any
=
[];
if
(
resno
)
{
console
.
log
(
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
]));
...
...
@@ -152,14 +149,13 @@ function atomExpressionQuery(x: any[]) {
function
resnorangeExpressionQuery
(
x
:
any
[])
{
const
[
resnorange
,
chainname
]
=
x
;
//const [resnorange, inscode, chainname, atomname, altloc] = x[1];
//
const [resnorange, inscode, chainname, atomname, altloc] = x[1];
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
resnoRangeProps
:
any
=
[];
if
(
resnorange
)
{
...
...
@@ -168,7 +164,7 @@ function resnorangeExpressionQuery(x: any[]) {
});
};
if
(
resnoRangeProps
.
length
)
tests
[
'
residue-test
'
]
=
h
.
orExpr
(
resnoRangeProps
);
return
B
.
struct
.
generator
.
atomGroups
(
tests
);
}
...
...
@@ -191,27 +187,14 @@ const lang = P.MonadicParser.createLanguage({
r
.
Keywords
,
r
.
NamedAtomProperties
,
r
.
AtomSelectionMacro
.
map
(
atomSelectionQuery2
),
/* r.ResnoRange.map((x:string) => {
const resnorange=listOrRangeMap(x);
const resnoRangeProps: any = [];
const tests: AtomGroupArgs = {};
console.log(resnorange)
resnorange.forEach((a: number) =>{
resnoRangeProps.push(B.core.rel.eq([B.ammp('auth_seq_id'), a]));
});
console.log(resnoRangeProps)
tests['residue-test'] = h.orExpr(resnoRangeProps);
return B.struct.generator.atomGroups(tests);
}),
*/
r
.
AtomExpression
.
map
(
atomExpressionQuery
),
r
.
ResnoRangeExpression
.
map
(
resnorangeExpressionQuery
),
r
.
Element
.
map
((
x
:
string
)
=>
B
.
struct
.
generator
.
atomGroups
({
'
atom-test
'
:
B
.
core
.
rel
.
eq
([
B
.
acp
(
'
elementSymbol
'
),
B
.
struct
.
type
.
elementSymbol
(
x
)])
})),
r
.
Resname
.
map
((
x
:
string
)
=>
B
.
struct
.
generator
.
atomGroups
({
'
residue-test
'
:
B
.
core
.
rel
.
eq
([
B
.
ammp
(
'
label_comp_id
'
),
x
])
})),
r
.
ResnoRangeExpression
.
map
(
resnorangeExpressionQuery
),
r
.
Object
,
r
.
Object2
,
);
...
...
@@ -343,7 +326,8 @@ const lang = P.MonadicParser.createLanguage({
},
Operator
:
function
(
r
:
any
)
{
return
h
.
combineOperators
(
operators
,
P
.
MonadicParser
.
alt
(
r
.
Parens
,
r
.
Expression
,
r
.
Operator
));
return
h
.
combineOperators
(
operators
,
P
.
MonadicParser
.
alt
(
r
.
Parens
,
r
.
Expression
,
r
.
Operator
));
//return h.combineOperators(operators, P.MonadicParser.alt(r.Parens, r.Expression));
},
AtomExpression
:
function
(
r
:
any
)
{
...
...
@@ -351,7 +335,7 @@ const lang = P.MonadicParser.createLanguage({
P
.
MonadicParser
.
lookahead
(
r
.
AtomPrefix
),
P
.
MonadicParser
.
seq
(
r
.
ResnoRange
.
or
(
P
.
MonadicParser
.
of
(
null
)),
r
.
Resno
.
or
(
P
.
MonadicParser
.
of
(
null
)),
r
.
Resno
.
or
(
P
.
MonadicParser
.
of
(
null
)),
r
.
Inscode
.
or
(
P
.
MonadicParser
.
of
(
null
)),
r
.
Chainname
.
or
(
P
.
MonadicParser
.
of
(
null
)),
r
.
Atomname
.
or
(
P
.
MonadicParser
.
of
(
null
)),
...
...
@@ -365,11 +349,11 @@ const lang = P.MonadicParser.createLanguage({
return
P
.
MonadicParser
.
seq
(
r
.
ResnoRange
.
or
(
P
.
MonadicParser
.
of
(
null
)),
r
.
Chainname
.
or
(
P
.
MonadicParser
.
of
(
null
)),
)
)
;
},
AtomPrefix
:
()
=>
P
.
MonadicParser
.
regexp
(
/
[
0-9:^%
/
.
]
/
).
desc
(
'
atom-prefix
'
),
Chainname
:
()
=>
P
.
MonadicParser
.
regexp
(
/:
([
A-Z
a-z
]{1,3})
/
,
1
).
desc
(
'
chainname
'
),
Chainname
:
()
=>
P
.
MonadicParser
.
regexp
(
/:
([
A-Z
]{1,3})
/
,
1
).
desc
(
'
chainname
'
),
Model
:
()
=>
P
.
MonadicParser
.
regexp
(
/
\/([
0-9
]
+
)
/
,
1
).
map
(
Number
).
desc
(
'
model
'
),
Element
:
()
=>
P
.
MonadicParser
.
regexp
(
/_
([
A-Za-z
]{1,3})
/
,
1
).
desc
(
'
element
'
),
Atomname
:
()
=>
P
.
MonadicParser
.
regexp
(
/
\.([
a-zA-Z0-9
]{1,4})
/
,
1
).
map
(
B
.
atomName
).
desc
(
'
atomname
'
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment