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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
75cc5769
Commit
75cc5769
authored
Mar 2, 2018
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added on-demand file loading to structure perf-test
parent
9f2cb62c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/perf-tests/structure.ts
+33
-4
33 additions, 4 deletions
src/perf-tests/structure.ts
with
33 additions
and
4 deletions
src/perf-tests/structure.ts
+
33
−
4
View file @
75cc5769
...
@@ -8,6 +8,7 @@ import * as B from 'benchmark'
...
@@ -8,6 +8,7 @@ import * as B from 'benchmark'
import
*
as
util
from
'
util
'
import
*
as
util
from
'
util
'
import
*
as
fs
from
'
fs
'
import
*
as
fs
from
'
fs
'
import
fetch
from
'
node-fetch
'
import
CIF
from
'
mol-io/reader/cif
'
import
CIF
from
'
mol-io/reader/cif
'
import
{
Structure
,
Model
,
Queries
as
Q
,
Atom
,
AtomGroup
,
AtomSet
,
Selection
,
Symmetry
}
from
'
mol-model/structure
'
import
{
Structure
,
Model
,
Queries
as
Q
,
Atom
,
AtomGroup
,
AtomSet
,
Selection
,
Symmetry
}
from
'
mol-model/structure
'
...
@@ -17,6 +18,7 @@ import to_mmCIF from 'mol-model/structure/export/mmcif'
...
@@ -17,6 +18,7 @@ import to_mmCIF from 'mol-model/structure/export/mmcif'
require
(
'
util.promisify
'
).
shim
();
require
(
'
util.promisify
'
).
shim
();
const
readFileAsync
=
util
.
promisify
(
fs
.
readFile
);
const
readFileAsync
=
util
.
promisify
(
fs
.
readFile
);
const
writeFileAsync
=
util
.
promisify
(
fs
.
writeFile
);
async
function
readData
(
path
:
string
)
{
async
function
readData
(
path
:
string
)
{
if
(
path
.
match
(
/
\.
bcif$/
))
{
if
(
path
.
match
(
/
\.
bcif$/
))
{
...
@@ -76,8 +78,35 @@ export async function readCIF(path: string) {
...
@@ -76,8 +78,35 @@ export async function readCIF(path: string) {
return
{
mmcif
,
models
,
structures
};
return
{
mmcif
,
models
,
structures
};
}
}
const
DATA_DIR
=
'
./build/data
'
;
if
(
!
fs
.
existsSync
(
DATA_DIR
))
fs
.
mkdirSync
(
DATA_DIR
);
function
getBcifUrl
(
pdbId
:
string
)
{
return
`http://www.ebi.ac.uk/pdbe/coordinates/
${
pdbId
.
toLowerCase
()}
/full?encoding=bcif`
}
function
getBcifPath
(
pdbId
:
string
)
{
return
`
${
DATA_DIR
}
/
${
pdbId
.
toLowerCase
()}
_full.bcif`
}
async
function
ensureBcifAvailable
(
pdbId
:
string
)
{
const
bcifPath
=
getBcifPath
(
pdbId
);
if
(
!
fs
.
existsSync
(
bcifPath
))
{
console
.
log
(
`downloading
${
pdbId
}
bcif...`
)
const
data
=
await
fetch
(
getBcifUrl
(
pdbId
))
await
writeFileAsync
(
bcifPath
,
await
data
.
buffer
())
console
.
log
(
`done downloading
${
pdbId
}
bcif`
)
}
}
async
function
getBcif
(
pdbId
:
string
)
{
await
ensureBcifAvailable
(
pdbId
);
return
await
readCIF
(
getBcifPath
(
pdbId
));
}
export
namespace
PropertyAccess
{
export
namespace
PropertyAccess
{
function
baseline
(
model
:
Model
)
{
function
baseline
(
model
:
Model
)
{
if
(
model
.
sourceData
.
kind
!==
'
mmCIF
'
)
throw
new
Error
(
'
Model must be mmCIF
'
);
const
atom_site
=
model
.
sourceData
.
data
.
atom_site
;
const
atom_site
=
model
.
sourceData
.
data
.
atom_site
;
const
id
=
atom_site
.
id
.
value
;
const
id
=
atom_site
.
id
.
value
;
let
s
=
0
;
let
s
=
0
;
...
@@ -267,14 +296,14 @@ export namespace PropertyAccess {
...
@@ -267,14 +296,14 @@ export namespace PropertyAccess {
console
.
time
(
'
assembly
'
)
console
.
time
(
'
assembly
'
)
const
a
=
Symmetry
.
buildAssembly
(
s
,
'
1
'
);
const
a
=
Symmetry
.
buildAssembly
(
s
,
'
1
'
);
console
.
timeEnd
(
'
assembly
'
)
console
.
timeEnd
(
'
assembly
'
)
fs
.
writeFileSync
(
`
e:/test/molstar
/
${
id
}
_assembly.bcif`
,
to_mmCIF
(
id
,
a
,
true
));
fs
.
writeFileSync
(
`
${
DATA_DIR
}
/
${
id
}
_assembly.bcif`
,
to_mmCIF
(
id
,
a
,
true
));
console
.
log
(
'
exported
'
);
console
.
log
(
'
exported
'
);
//write(a);
}
}
export
async
function
run
()
{
export
async
function
run
()
{
//const { structures, models, mmcif } = await readCIF('./examples/1cbs_full.bcif');
const
{
structures
,
models
/*, mmcif*/
}
=
await
getBcif
(
'
1cbs
'
);
const
{
structures
,
models
}
=
await
readCIF
(
'
e:/test/quick/3j3q_full.bcif
'
);
// const { structures, models } = await getBcif('3j3q');
//const { structures, models, mmcif } = await readCIF('e:/test/quick/1cbs_updated.cif');
//const { structures, models, mmcif } = await readCIF('e:/test/quick/1cbs_updated.cif');
//const { structures, models/*, mmcif*/ } = await readCIF('e:/test/quick/5j7v_updated.cif');
//const { structures, models/*, mmcif*/ } = await readCIF('e:/test/quick/5j7v_updated.cif');
...
...
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
sign in
to comment