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
501f5a22
Commit
501f5a22
authored
7 years ago
by
arose
Browse files
Options
Downloads
Patches
Plain Diff
example of how to loop over bonds and create atom label
parent
1e92c789
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/apps/structure-info/index.ts
+29
-14
29 additions, 14 deletions
src/apps/structure-info/index.ts
src/mol-model/structure/structure/unit.ts
+1
-0
1 addition, 0 deletions
src/mol-model/structure/structure/unit.ts
with
30 additions
and
14 deletions
src/apps/structure-info/index.ts
+
29
−
14
View file @
501f5a22
...
...
@@ -8,9 +8,10 @@ import * as argparse from 'argparse'
import
fetch
from
'
node-fetch
'
require
(
'
util.promisify
'
).
shim
();
// import { Table } from 'mol-data/db'
import
CIF
from
'
mol-io/reader/cif
'
import
Computation
from
'
mol-util/computation
'
import
{
Model
,
Structure
}
from
'
mol-model/structure
'
import
{
Model
}
from
'
mol-model/structure
'
function
showProgress
(
tag
:
string
,
p
:
Computation
.
Progress
)
{
console
.
log
(
`[
${
tag
}
]
${
p
.
message
}
${
p
.
isIndeterminate
?
''
:
(
p
.
current
/
p
.
max
*
100
).
toFixed
(
2
)
+
'
%
'
}
(
${
p
.
elapsedMs
|
0
}
ms)`
)
...
...
@@ -22,35 +23,49 @@ async function parseCif(data: string|Uint8Array) {
updateRateMs
:
250
,
observer
:
p
=>
showProgress
(
`cif parser
${
typeof
data
===
'
string
'
?
'
string
'
:
'
binary
'
}
`
,
p
)
});
console
.
time
(
'
parse cif
'
)
const
parsed
=
await
comp
(
ctx
);
console
.
timeEnd
(
'
parse cif
'
)
if
(
parsed
.
isError
)
throw
parsed
;
return
parsed
}
export
async
function
getPdb
(
pdb
:
string
)
{
console
.
log
(
`downloading
${
pdb
}
...`
)
async
function
getPdb
(
pdb
:
string
)
{
const
data
=
await
fetch
(
`https://files.rcsb.org/download/
${
pdb
}
.cif`
)
console
.
log
(
`done downloading
${
pdb
}
`
)
const
parsed
=
await
parseCif
(
await
data
.
text
())
return
CIF
.
schema
.
mmCIF
(
parsed
.
result
.
blocks
[
0
])
}
async
function
run
(
pdb
:
string
,
out
?:
string
)
{
const
mmcif
=
await
getPdb
(
pdb
)
function
atomLabel
(
model
:
Model
,
aI
:
number
)
{
const
{
atoms
,
residues
,
chains
,
residueSegments
,
chainSegments
}
=
model
.
hierarchy
const
{
label_atom_id
}
=
atoms
const
{
label_comp_id
,
label_seq_id
}
=
residues
const
{
label_asym_id
}
=
chains
const
rI
=
residueSegments
.
segmentMap
[
aI
]
const
cI
=
chainSegments
.
segmentMap
[
aI
]
return
`
${
label_asym_id
.
value
(
cI
)}
${
label_comp_id
.
value
(
rI
)}
${
label_seq_id
.
value
(
rI
)}
${
label_atom_id
.
value
(
aI
)}
`
}
const
models
=
Model
.
create
({
kind
:
'
mmCIF
'
,
data
:
mmcif
});
const
structure
=
Structure
.
ofModel
(
models
[
0
])
function
printBonds
(
model
:
Model
)
{
const
{
count
,
offset
,
neighbor
}
=
Model
.
bonds
(
model
)
for
(
let
i
=
0
;
i
<
count
;
++
i
)
{
const
start
=
offset
[
i
];
const
end
=
offset
[
i
+
1
];
for
(
let
bI
=
start
;
bI
<
end
;
bI
++
)
{
console
.
log
(
`
${
atomLabel
(
model
,
i
)}
--
${
atomLabel
(
model
,
neighbor
[
bI
])}
`
)
}
}
}
console
.
log
(
structure
)
console
.
log
(
Model
.
bonds
(
models
[
0
]))
async
function
run
(
pdb
:
string
)
{
const
mmcif
=
await
getPdb
(
pdb
)
const
models
=
Model
.
create
({
kind
:
'
mmCIF
'
,
data
:
mmcif
});
// const structure = Structure.ofModel(models[0])
// console.log(structure)
printBonds
(
models
[
0
])
}
const
parser
=
new
argparse
.
ArgumentParser
({
addHelp
:
true
,
description
:
'
Print info about a structure
'
description
:
'
Print info about a structure
, mainly to test and showcase the mol-model module
'
});
parser
.
addArgument
([
'
--pdb
'
,
'
-p
'
],
{
help
:
'
Pdb entry id
'
...
...
This diff is collapsed.
Click to expand it.
src/mol-model/structure/structure/unit.ts
+
1
−
0
View file @
501f5a22
...
...
@@ -33,6 +33,7 @@ interface Unit extends SymmetryOperator.ArrayMapping {
readonly
conformation
:
Model
[
'
conformation
'
]
// TODO: add velocity?
// AR: would fit into conformation, right?
}
namespace
Unit
{
...
...
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