Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
7f9090e4
Commit
7f9090e4
authored
1 year ago
by
Studer Gabriel
Browse files
Options
Downloads
Patches
Plain Diff
mmcif writer: cleanup
parent
d72c2972
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/io/src/mol/mmcif_writer.cc
+35
-54
35 additions, 54 deletions
modules/io/src/mol/mmcif_writer.cc
modules/io/src/mol/star_writer.hh
+3
-2
3 additions, 2 deletions
modules/io/src/mol/star_writer.hh
with
38 additions
and
56 deletions
modules/io/src/mol/mmcif_writer.cc
+
35
−
54
View file @
7f9090e4
...
@@ -898,8 +898,7 @@ namespace {
...
@@ -898,8 +898,7 @@ namespace {
for
(
int
i
=
0
;
i
<
N
;
++
i
)
{
for
(
int
i
=
0
;
i
<
N
;
++
i
)
{
symbols
.
insert
(
data
[
i
*
desc_size
+
type_symbol_idx
].
GetValue
());
symbols
.
insert
(
data
[
i
*
desc_size
+
type_symbol_idx
].
GetValue
());
}
}
std
::
vector
<
ost
::
io
::
StarWriterValue
>
atom_type_data
;
std
::
vector
<
ost
::
io
::
StarWriterValue
>
atom_type_data
(
1
);
atom_type_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
""
));
for
(
auto
symbol
:
symbols
)
{
for
(
auto
symbol
:
symbols
)
{
atom_type_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
symbol
);
atom_type_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
symbol
);
atom_type_ptr
->
AddData
(
atom_type_data
);
atom_type_ptr
->
AddData
(
atom_type_data
);
...
@@ -914,14 +913,10 @@ namespace {
...
@@ -914,14 +913,10 @@ namespace {
ost
::
io
::
MMCifWriterEntity
&
entity_info
,
ost
::
io
::
MMCifWriterEntity
&
entity_info
,
const
T
&
res_list
)
{
const
T
&
res_list
)
{
std
::
vector
<
ost
::
io
::
StarWriterValue
>
data
;
std
::
vector
<
ost
::
io
::
StarWriterValue
>
data
(
7
);
data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
label_asym_id
));
// processing chain by chain, label_asym_id and label_entity_id are constant
data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
label_entity_id
));
data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
label_asym_id
);
data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
""
));
data
[
1
]
=
ost
::
io
::
StarWriterValue
::
FromInt
(
label_entity_id
);
data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
0
));
data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
""
));
data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
0
));
data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
""
));
int
asym_idx
=
entity_info
.
GetAsymIdx
(
label_asym_id
);
int
asym_idx
=
entity_info
.
GetAsymIdx
(
label_asym_id
);
const
std
::
vector
<
String
>&
aln
=
entity_info
.
asym_alns
[
asym_idx
];
const
std
::
vector
<
String
>&
aln
=
entity_info
.
asym_alns
[
asym_idx
];
...
@@ -979,6 +974,7 @@ namespace {
...
@@ -979,6 +974,7 @@ namespace {
int
asym_idx
=
entity_info
.
GetAsymIdx
(
label_asym_id
);
int
asym_idx
=
entity_info
.
GetAsymIdx
(
label_asym_id
);
const
std
::
vector
<
String
>&
aln
=
entity_info
.
asym_alns
[
asym_idx
];
const
std
::
vector
<
String
>&
aln
=
entity_info
.
asym_alns
[
asym_idx
];
int
label_seq_id
=
0
;
// 0-based index
int
label_seq_id
=
0
;
// 0-based index
std
::
vector
<
ost
::
io
::
StarWriterValue
>
at_data
(
17
);
for
(
auto
res
:
res_list
)
{
for
(
auto
res
:
res_list
)
{
String
comp_id
=
res
.
GetName
();
String
comp_id
=
res
.
GetName
();
...
@@ -1004,49 +1000,48 @@ namespace {
...
@@ -1004,49 +1000,48 @@ namespace {
}
}
for
(
auto
at
:
at_list
)
{
for
(
auto
at
:
at_list
)
{
std
::
vector
<
ost
::
io
::
StarWriterValue
>
at_data
;
// group_PDB
// group_PDB
if
(
at
.
IsHetAtom
())
{
if
(
at
.
IsHetAtom
())
{
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
"HETATM"
)
)
;
at_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
"HETATM"
);
}
else
{
}
else
{
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
"ATOM"
)
)
;
at_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
"ATOM"
);
}
}
// type_symbol
// type_symbol
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
at
.
GetElement
())
)
;
at_data
[
1
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
at
.
GetElement
());
// label_atom_id
// label_atom_id
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
at
.
GetName
())
)
;
at_data
[
2
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
at
.
GetName
());
// label_comp_id
// label_comp_id
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
comp_id
)
)
;
at_data
[
3
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
comp_id
);
// label_asym_id
// label_asym_id
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
label_asym_id
)
)
;
at_data
[
4
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
label_asym_id
);
// label_entity_id
// label_entity_id
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
label_entity_id
)
)
;
at_data
[
5
]
=
ost
::
io
::
StarWriterValue
::
FromInt
(
label_entity_id
);
// label_seq_id
// label_seq_id
if
(
entity_info
.
is_poly
)
{
if
(
entity_info
.
is_poly
)
{
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
label_seq_id
+
1
)
)
;
at_data
[
6
]
=
ost
::
io
::
StarWriterValue
::
FromInt
(
label_seq_id
+
1
);
}
else
{
}
else
{
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
"."
)
)
;
at_data
[
6
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
"."
);
}
}
// label_alt_id
// label_alt_id
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
"."
)
)
;
at_data
[
7
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
"."
);
// Cartn_x
// Cartn_x
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromFloat
(
at
.
GetPos
().
GetX
(),
3
)
)
;
at_data
[
8
]
=
ost
::
io
::
StarWriterValue
::
FromFloat
(
at
.
GetPos
().
GetX
(),
3
);
// Cartn_y
// Cartn_y
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromFloat
(
at
.
GetPos
().
GetY
(),
3
)
)
;
at_data
[
9
]
=
ost
::
io
::
StarWriterValue
::
FromFloat
(
at
.
GetPos
().
GetY
(),
3
);
// Cartn_z
// Cartn_z
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromFloat
(
at
.
GetPos
().
GetZ
(),
3
)
)
;
at_data
[
10
]
=
ost
::
io
::
StarWriterValue
::
FromFloat
(
at
.
GetPos
().
GetZ
(),
3
);
// occupancy
// occupancy
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromFloat
(
at
.
GetOccupancy
(),
2
)
)
;
at_data
[
11
]
=
ost
::
io
::
StarWriterValue
::
FromFloat
(
at
.
GetOccupancy
(),
2
);
// B_iso_or_equiv
// B_iso_or_equiv
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromFloat
(
at
.
GetBFactor
(),
2
)
)
;
at_data
[
12
]
=
ost
::
io
::
StarWriterValue
::
FromFloat
(
at
.
GetBFactor
(),
2
);
// auth_seq_id
// auth_seq_id
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
auth_seq_id
)
)
;
at_data
[
13
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
auth_seq_id
);
// auth_asym_id
// auth_asym_id
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
auth_asym_id
)
)
;
at_data
[
14
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
auth_asym_id
);
// id
// id
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
atom_site_ptr
->
GetN
())
)
;
at_data
[
15
]
=
ost
::
io
::
StarWriterValue
::
FromInt
(
atom_site_ptr
->
GetN
());
// pdbx_PDB_ins_code
// pdbx_PDB_ins_code
at_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
ins_code
)
)
;
at_data
[
16
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
ins_code
);
atom_site_ptr
->
AddData
(
at_data
);
atom_site_ptr
->
AddData
(
at_data
);
}
}
++
label_seq_id
;
++
label_seq_id
;
...
@@ -1055,21 +1050,21 @@ namespace {
...
@@ -1055,21 +1050,21 @@ namespace {
void
Feed_entity
(
ost
::
io
::
StarWriterLoopPtr
entity_ptr
,
void
Feed_entity
(
ost
::
io
::
StarWriterLoopPtr
entity_ptr
,
const
std
::
vector
<
ost
::
io
::
MMCifWriterEntity
>&
entity_info
)
{
const
std
::
vector
<
ost
::
io
::
MMCifWriterEntity
>&
entity_info
)
{
std
::
vector
<
ost
::
io
::
StarWriterValue
>
ent_data
(
2
);
for
(
size_t
entity_idx
=
0
;
entity_idx
<
entity_info
.
size
();
++
entity_idx
)
{
for
(
size_t
entity_idx
=
0
;
entity_idx
<
entity_info
.
size
();
++
entity_idx
)
{
std
::
vector
<
ost
::
io
::
StarWriterValue
>
ent_data
;
ent_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromInt
(
entity_idx
);
ent_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
entity_idx
));
ent_data
[
1
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
entity_info
[
entity_idx
].
type
);
ent_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
entity_info
[
entity_idx
].
type
));
entity_ptr
->
AddData
(
ent_data
);
entity_ptr
->
AddData
(
ent_data
);
}
}
}
}
void
Feed_struct_asym
(
ost
::
io
::
StarWriterLoopPtr
struct_asym_ptr
,
void
Feed_struct_asym
(
ost
::
io
::
StarWriterLoopPtr
struct_asym_ptr
,
const
std
::
vector
<
ost
::
io
::
MMCifWriterEntity
>&
entity_info
)
{
const
std
::
vector
<
ost
::
io
::
MMCifWriterEntity
>&
entity_info
)
{
std
::
vector
<
ost
::
io
::
StarWriterValue
>
asym_data
(
2
);
for
(
size_t
entity_idx
=
0
;
entity_idx
<
entity_info
.
size
();
++
entity_idx
)
{
for
(
size_t
entity_idx
=
0
;
entity_idx
<
entity_info
.
size
();
++
entity_idx
)
{
for
(
auto
asym_id
:
entity_info
[
entity_idx
].
asym_ids
)
{
for
(
auto
asym_id
:
entity_info
[
entity_idx
].
asym_ids
)
{
std
::
vector
<
ost
::
io
::
StarWriterValue
>
asym_data
;
asym_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
asym_id
);
asym_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
asym_id
));
asym_data
[
1
]
=
ost
::
io
::
StarWriterValue
::
FromInt
(
entity_idx
);
asym_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
entity_idx
));
struct_asym_ptr
->
AddData
(
asym_data
);
struct_asym_ptr
->
AddData
(
asym_data
);
}
}
}
}
...
@@ -1077,12 +1072,7 @@ namespace {
...
@@ -1077,12 +1072,7 @@ namespace {
void
Feed_entity_poly_seq
(
ost
::
io
::
StarWriterLoopPtr
entity_poly_seq_ptr
,
void
Feed_entity_poly_seq
(
ost
::
io
::
StarWriterLoopPtr
entity_poly_seq_ptr
,
const
std
::
vector
<
ost
::
io
::
MMCifWriterEntity
>&
entity_info
)
{
const
std
::
vector
<
ost
::
io
::
MMCifWriterEntity
>&
entity_info
)
{
// reuse data vector for efficiency
std
::
vector
<
ost
::
io
::
StarWriterValue
>
entity_poly_seq_data
(
3
);
std
::
vector
<
ost
::
io
::
StarWriterValue
>
entity_poly_seq_data
;
entity_poly_seq_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
0
));
entity_poly_seq_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
"ALA"
));
entity_poly_seq_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
1
));
for
(
size_t
entity_idx
=
0
;
entity_idx
<
entity_info
.
size
();
++
entity_idx
)
{
for
(
size_t
entity_idx
=
0
;
entity_idx
<
entity_info
.
size
();
++
entity_idx
)
{
if
(
entity_info
[
entity_idx
].
is_poly
)
{
if
(
entity_info
[
entity_idx
].
is_poly
)
{
const
std
::
vector
<
String
>&
mon_ids
=
entity_info
[
entity_idx
].
mon_ids
;
const
std
::
vector
<
String
>&
mon_ids
=
entity_info
[
entity_idx
].
mon_ids
;
...
@@ -1098,12 +1088,7 @@ namespace {
...
@@ -1098,12 +1088,7 @@ namespace {
void
Feed_entity_poly
(
ost
::
io
::
StarWriterLoopPtr
entity_poly_ptr
,
void
Feed_entity_poly
(
ost
::
io
::
StarWriterLoopPtr
entity_poly_ptr
,
const
std
::
vector
<
ost
::
io
::
MMCifWriterEntity
>&
entity_info
)
{
const
std
::
vector
<
ost
::
io
::
MMCifWriterEntity
>&
entity_info
)
{
// reuse data vector for efficiency
std
::
vector
<
ost
::
io
::
StarWriterValue
>
entity_poly_data
(
4
);
std
::
vector
<
ost
::
io
::
StarWriterValue
>
entity_poly_data
;
entity_poly_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
0
));
entity_poly_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
"other"
));
entity_poly_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
"A"
));
entity_poly_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
"A"
));
for
(
size_t
entity_idx
=
0
;
entity_idx
<
entity_info
.
size
();
++
entity_idx
)
{
for
(
size_t
entity_idx
=
0
;
entity_idx
<
entity_info
.
size
();
++
entity_idx
)
{
if
(
entity_info
[
entity_idx
].
is_poly
)
{
if
(
entity_info
[
entity_idx
].
is_poly
)
{
entity_poly_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromInt
(
entity_idx
);
entity_poly_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromInt
(
entity_idx
);
...
@@ -1133,9 +1118,7 @@ namespace {
...
@@ -1133,9 +1118,7 @@ namespace {
void
Feed_chem_comp
(
ost
::
io
::
StarWriterLoopPtr
chem_comp_ptr
,
void
Feed_chem_comp
(
ost
::
io
::
StarWriterLoopPtr
chem_comp_ptr
,
const
std
::
map
<
String
,
ost
::
io
::
MMCifWriterComp
>&
comp_infos
)
{
const
std
::
map
<
String
,
ost
::
io
::
MMCifWriterComp
>&
comp_infos
)
{
std
::
vector
<
ost
::
io
::
StarWriterValue
>
comp_data
;
std
::
vector
<
ost
::
io
::
StarWriterValue
>
comp_data
(
2
);
comp_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
"ALA"
));
comp_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
"L-PEPTIDE LINKING"
));
for
(
auto
it
=
comp_infos
.
begin
();
it
!=
comp_infos
.
end
();
++
it
)
{
for
(
auto
it
=
comp_infos
.
begin
();
it
!=
comp_infos
.
end
();
++
it
)
{
comp_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
it
->
first
);
comp_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
it
->
first
);
comp_data
[
1
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
it
->
second
.
type
);
comp_data
[
1
]
=
ost
::
io
::
StarWriterValue
::
FromString
(
it
->
second
.
type
);
...
@@ -1145,9 +1128,7 @@ namespace {
...
@@ -1145,9 +1128,7 @@ namespace {
void
Feed_pdbx_entity_branch
(
ost
::
io
::
StarWriterLoopPtr
pdbx_entity_branch_ptr
,
void
Feed_pdbx_entity_branch
(
ost
::
io
::
StarWriterLoopPtr
pdbx_entity_branch_ptr
,
const
std
::
vector
<
ost
::
io
::
MMCifWriterEntity
>&
entity_infos
)
{
const
std
::
vector
<
ost
::
io
::
MMCifWriterEntity
>&
entity_infos
)
{
std
::
vector
<
ost
::
io
::
StarWriterValue
>
branch_data
;
std
::
vector
<
ost
::
io
::
StarWriterValue
>
branch_data
(
2
);
branch_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromInt
(
0
));
branch_data
.
push_back
(
ost
::
io
::
StarWriterValue
::
FromString
(
"oligosaccharide"
));
for
(
size_t
i
=
0
;
i
<
entity_infos
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
entity_infos
.
size
();
++
i
)
{
if
(
entity_infos
[
i
].
type
==
"branched"
)
{
if
(
entity_infos
[
i
].
type
==
"branched"
)
{
branch_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromInt
(
i
);
branch_data
[
0
]
=
ost
::
io
::
StarWriterValue
::
FromInt
(
i
);
...
...
This diff is collapsed.
Click to expand it.
modules/io/src/mol/star_writer.hh
+
3
−
2
View file @
7f9090e4
...
@@ -88,6 +88,9 @@ public:
...
@@ -88,6 +88,9 @@ public:
class
DLLEXPORT_OST_IO
StarWriterValue
{
class
DLLEXPORT_OST_IO
StarWriterValue
{
public:
public:
StarWriterValue
()
{
}
static
StarWriterValue
FromInt
(
int
int_value
)
{
static
StarWriterValue
FromInt
(
int
int_value
)
{
StarWriterValue
value
;
StarWriterValue
value
;
value
.
value_
=
std
::
to_string
(
int_value
);
value
.
value_
=
std
::
to_string
(
int_value
);
...
@@ -123,8 +126,6 @@ public:
...
@@ -123,8 +126,6 @@ public:
}
}
const
String
&
GetValue
()
const
{
return
value_
;
}
const
String
&
GetValue
()
const
{
return
value_
;
}
private
:
private
:
// force construction through static members
StarWriterValue
()
{
}
String
value_
;
String
value_
;
};
};
...
...
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