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
cf6f5026
Commit
cf6f5026
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
pdb parse MTRIX
parent
09d8be90
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-model-formats/structure/pdb/assembly.ts
+59
-1
59 additions, 1 deletion
src/mol-model-formats/structure/pdb/assembly.ts
src/mol-model-formats/structure/pdb/to-cif.ts
+25
-7
25 additions, 7 deletions
src/mol-model-formats/structure/pdb/to-cif.ts
with
84 additions
and
8 deletions
src/mol-model-formats/structure/pdb/assembly.ts
+
59
−
1
View file @
cf6f5026
...
@@ -137,7 +137,7 @@ export function parseRemark350(lines: Tokens, lineStart: number, lineEnd: number
...
@@ -137,7 +137,7 @@ export function parseRemark350(lines: Tokens, lineStart: number, lineEnd: number
type
:
'
?
'
,
type
:
'
?
'
,
name
:
'
?
'
,
name
:
'
?
'
,
symmetry_operation
:
'
?
'
symmetry_operation
:
'
?
'
}
as
any
;
}
as
(
typeof
pdbx_struct_oper_list_rows
)[
0
]
as
any
;
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
for
(
let
j
=
0
;
j
<
3
;
j
++
)
{
for
(
let
j
=
0
;
j
<
3
;
j
++
)
{
row
[
`matrix[
${
i
+
1
}
][
${
j
+
1
}
]`
]
=
''
+
Mat4
.
getValue
(
oper
.
matrix
,
i
,
j
);
row
[
`matrix[
${
i
+
1
}
][
${
j
+
1
}
]`
]
=
''
+
Mat4
.
getValue
(
oper
.
matrix
,
i
,
j
);
...
@@ -169,4 +169,62 @@ export function parseRemark350(lines: Tokens, lineStart: number, lineEnd: number
...
@@ -169,4 +169,62 @@ export function parseRemark350(lines: Tokens, lineStart: number, lineEnd: number
CifCategory
.
ofFields
(
'
pdbx_struct_assembly_gen
'
,
pdbx_struct_assembly_gen
),
CifCategory
.
ofFields
(
'
pdbx_struct_assembly_gen
'
,
pdbx_struct_assembly_gen
),
CifCategory
.
ofFields
(
'
pdbx_struct_oper_list
'
,
pdbx_struct_oper_list
)
CifCategory
.
ofFields
(
'
pdbx_struct_oper_list
'
,
pdbx_struct_oper_list
)
];
];
}
export
function
parseMtrix
(
lines
:
Tokens
,
lineStart
:
number
,
lineEnd
:
number
):
CifCategory
[]
{
const
matrices
:
Mat4
[]
=
[];
let
matrix
:
Mat4
;
const
getLine
=
(
n
:
number
)
=>
lines
.
data
.
substring
(
lines
.
indices
[
2
*
n
],
lines
.
indices
[
2
*
n
+
1
]);
for
(
let
i
=
lineStart
;
i
<
lineEnd
;
i
++
)
{
let
line
=
getLine
(
i
);
const
ncs
=
line
.
split
(
/
\s
+/
);
const
row
=
parseInt
(
line
[
5
])
-
1
;
if
(
row
===
0
)
{
matrix
=
Mat4
.
identity
();
matrices
.
push
(
matrix
);
}
Mat4
.
setValue
(
matrix
!
,
row
,
0
,
parseFloat
(
ncs
[
2
]));
Mat4
.
setValue
(
matrix
!
,
row
,
1
,
parseFloat
(
ncs
[
3
]));
Mat4
.
setValue
(
matrix
!
,
row
,
2
,
parseFloat
(
ncs
[
4
]));
Mat4
.
setValue
(
matrix
!
,
row
,
3
,
parseFloat
(
ncs
[
5
]));
}
if
(
matrices
.
length
===
0
)
return
[];
const
struct_ncs_oper_rows
:
{
[
P
in
keyof
CifCategory
.
Fields
<
mmCIF_Schema
[
'
struct_ncs_oper
'
]
>
]?:
string
}[]
=
[];
let
id
=
1
;
for
(
const
oper
of
matrices
)
{
const
row
=
{
id
:
'
ncsop
'
+
(
id
++
),
code
:
'
.
'
,
details
:
'
.
'
}
as
(
typeof
struct_ncs_oper_rows
)[
0
]
as
any
;
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
for
(
let
j
=
0
;
j
<
3
;
j
++
)
{
row
[
`matrix[
${
i
+
1
}
][
${
j
+
1
}
]`
]
=
''
+
Mat4
.
getValue
(
oper
,
i
,
j
);
}
row
[
`vector[
${
i
+
1
}
]`
]
=
''
+
Mat4
.
getValue
(
oper
,
i
,
3
);
}
struct_ncs_oper_rows
.
push
(
row
);
}
const
struct_ncs_oper
:
CifCategory
.
SomeFields
<
mmCIF_Schema
[
'
struct_ncs_oper
'
]
>
=
{
id
:
CifField
.
ofStrings
(
struct_ncs_oper_rows
.
map
(
r
=>
r
.
id
!
)),
code
:
CifField
.
ofStrings
(
struct_ncs_oper_rows
.
map
(
r
=>
r
.
code
!
)),
details
:
CifField
.
ofStrings
(
struct_ncs_oper_rows
.
map
(
r
=>
r
.
details
!
)),
};
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
for
(
let
j
=
0
;
j
<
3
;
j
++
)
{
const
k
=
`matrix[
${
i
+
1
}
][
${
j
+
1
}
]`
;
(
struct_ncs_oper
as
any
)[
k
]
=
CifField
.
ofStrings
(
struct_ncs_oper_rows
.
map
(
r
=>
(
r
as
any
)[
k
]
!
));
}
const
k
=
`vector[
${
i
+
1
}
]`
;
(
struct_ncs_oper
as
any
)[
k
]
=
CifField
.
ofStrings
(
struct_ncs_oper_rows
.
map
(
r
=>
(
r
as
any
)[
k
]
!
));
}
return
[
CifCategory
.
ofFields
(
'
struct_ncs_oper
'
,
struct_ncs_oper
)];
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-model-formats/structure/pdb/to-cif.ts
+
25
−
7
View file @
cf6f5026
...
@@ -9,7 +9,7 @@ import { CifField, CifCategory, CifFrame } from 'mol-io/reader/cif';
...
@@ -9,7 +9,7 @@ import { CifField, CifCategory, CifFrame } from 'mol-io/reader/cif';
import
{
mmCIF_Schema
}
from
'
mol-io/reader/cif/schema/mmcif
'
;
import
{
mmCIF_Schema
}
from
'
mol-io/reader/cif/schema/mmcif
'
;
import
{
TokenBuilder
,
Tokenizer
}
from
'
mol-io/reader/common/text/tokenizer
'
;
import
{
TokenBuilder
,
Tokenizer
}
from
'
mol-io/reader/common/text/tokenizer
'
;
import
{
PdbFile
}
from
'
mol-io/reader/pdb/schema
'
;
import
{
PdbFile
}
from
'
mol-io/reader/pdb/schema
'
;
import
{
parseCryst1
,
parseRemark350
}
from
'
./assembly
'
;
import
{
parseCryst1
,
parseRemark350
,
parseMtrix
}
from
'
./assembly
'
;
function
_entity
():
{
[
K
in
keyof
mmCIF_Schema
[
'
entity
'
]]?:
CifField
}
{
function
_entity
():
{
[
K
in
keyof
mmCIF_Schema
[
'
entity
'
]]?:
CifField
}
{
return
{
return
{
...
@@ -213,17 +213,33 @@ export async function pdbToMmCif(pdb: PdbFile): Promise<CifFrame> {
...
@@ -213,17 +213,33 @@ export async function pdbToMmCif(pdb: PdbFile): Promise<CifFrame> {
}
}
break
;
break
;
case
'
H
'
:
case
'
H
'
:
if
(
!
substringStartsWith
(
data
,
s
,
e
,
'
HETATM
'
))
continue
;
if
(
substringStartsWith
(
data
,
s
,
e
,
'
HETATM
'
))
{
if
(
!
modelNum
)
{
modelNum
++
;
modelStr
=
''
+
modelNum
;
}
if
(
!
modelNum
)
{
modelNum
++
;
modelStr
=
''
+
modelNum
;
}
addAtom
(
atom_site
,
modelStr
,
tokenizer
,
s
,
e
,
true
);
addAtom
(
atom_site
,
modelStr
,
tokenizer
,
s
,
e
,
true
);
}
// TODO: HELIX
break
;
break
;
case
'
M
'
:
case
'
M
'
:
if
(
substringStartsWith
(
data
,
s
,
e
,
'
MODEL
'
))
{
if
(
substringStartsWith
(
data
,
s
,
e
,
'
MODEL
'
))
{
modelNum
++
;
modelNum
++
;
modelStr
=
''
+
modelNum
;
modelStr
=
''
+
modelNum
;
}
}
if
(
substringStartsWith
(
data
,
s
,
e
,
'
MTRIX
'
))
{
let
j
=
i
+
1
;
while
(
true
)
{
s
=
indices
[
2
*
j
];
e
=
indices
[
2
*
j
+
1
];
if
(
!
substringStartsWith
(
data
,
s
,
e
,
'
MTRIX
'
))
break
;
j
++
;
}
helperCategories
.
push
(...
parseMtrix
(
lines
,
i
,
j
));
i
=
j
-
1
;
}
break
;
break
;
case
'
R
'
:
{
case
'
O
'
:
// TODO
// ORIGX to generate _atom_sites
break
;
case
'
R
'
:
if
(
substringStartsWith
(
data
,
s
,
e
,
'
REMARK 350
'
))
{
if
(
substringStartsWith
(
data
,
s
,
e
,
'
REMARK 350
'
))
{
let
j
=
i
+
1
;
let
j
=
i
+
1
;
while
(
true
)
{
while
(
true
)
{
...
@@ -235,8 +251,10 @@ export async function pdbToMmCif(pdb: PdbFile): Promise<CifFrame> {
...
@@ -235,8 +251,10 @@ export async function pdbToMmCif(pdb: PdbFile): Promise<CifFrame> {
i
=
j
-
1
;
i
=
j
-
1
;
}
}
break
;
break
;
}
case
'
S
'
:
// TODO
// SHEET
break
;
}
}
}
}
...
...
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