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
a1c74efa
Commit
a1c74efa
authored
11 months ago
by
Bienchen
Browse files
Options
Downloads
Patches
Plain Diff
Expose ChainNameGenerator
parent
b2879441
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/io/pymod/export_mmcif_io.cc
+5
-0
5 additions, 0 deletions
modules/io/pymod/export_mmcif_io.cc
modules/io/src/mol/mmcif_writer.cc
+40
-47
40 additions, 47 deletions
modules/io/src/mol/mmcif_writer.cc
modules/io/src/mol/mmcif_writer.hh
+12
-0
12 additions, 0 deletions
modules/io/src/mol/mmcif_writer.hh
with
57 additions
and
47 deletions
modules/io/pymod/export_mmcif_io.cc
+
5
−
0
View file @
a1c74efa
...
@@ -152,6 +152,11 @@ void export_mmcif_io()
...
@@ -152,6 +152,11 @@ void export_mmcif_io()
.
def
(
"Write"
,
&
WrapStarWriterWrite
,
(
arg
(
"data_name"
),
arg
(
"filename"
)))
.
def
(
"Write"
,
&
WrapStarWriterWrite
,
(
arg
(
"data_name"
),
arg
(
"filename"
)))
;
;
class_
<
ChainNameGenerator
>
(
"ChainNameGenerator"
,
init
<>
())
.
def
(
"Get"
,
&
ChainNameGenerator
::
Get
)
.
def
(
"Reset"
,
&
ChainNameGenerator
::
Reset
)
;
class_
<
MMCifWriterEntity
>
(
"MMCifWriterEntity"
,
no_init
)
class_
<
MMCifWriterEntity
>
(
"MMCifWriterEntity"
,
no_init
)
.
def
(
"FromPolymer"
,
&
MMCifWriterEntity
::
FromPolymer
).
staticmethod
(
"FromPolymer"
)
.
def
(
"FromPolymer"
,
&
MMCifWriterEntity
::
FromPolymer
).
staticmethod
(
"FromPolymer"
)
.
def
(
"AddHet"
,
&
MMCifWriterEntity
::
AddHet
,
(
arg
(
"rnum"
),
arg
(
"mon_id"
)))
.
def
(
"AddHet"
,
&
MMCifWriterEntity
::
AddHet
,
(
arg
(
"rnum"
),
arg
(
"mon_id"
)))
...
...
This diff is collapsed.
Click to expand it.
modules/io/src/mol/mmcif_writer.cc
+
40
−
47
View file @
a1c74efa
...
@@ -24,52 +24,6 @@
...
@@ -24,52 +24,6 @@
namespace
{
namespace
{
// generates as many chain names as you want (potentially multiple characters)
struct
ChainNameGenerator
{
ChainNameGenerator
()
{
chain_names
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"
;
n_chain_names
=
chain_names
.
size
();
indices
.
push_back
(
-
1
);
}
String
Get
()
{
int
idx
=
indices
.
size
()
-
1
;
indices
[
idx
]
+=
1
;
bool
more_digits
=
false
;
while
(
idx
>=
0
)
{
if
(
indices
[
idx
]
>=
n_chain_names
)
{
indices
[
idx
]
=
0
;
if
(
idx
>
0
)
{
indices
[
idx
-
1
]
+=
1
;
--
idx
;
}
else
{
more_digits
=
true
;
break
;
}
}
else
{
break
;
}
}
if
(
more_digits
)
{
indices
.
insert
(
indices
.
begin
(),
0
);
}
String
ch_name
(
indices
.
size
(),
'X'
);
for
(
uint
i
=
0
;
i
<
indices
.
size
();
++
i
)
{
ch_name
[
i
]
=
chain_names
[
indices
[
i
]];
}
return
ch_name
;
}
void
Reset
()
{
indices
.
clear
();
indices
.
push_back
(
-
1
);
}
String
chain_names
;
int
n_chain_names
;
std
::
vector
<
int
>
indices
;
};
void
CheckValidEntityPolyType
(
const
String
&
entity_poly_type
)
{
void
CheckValidEntityPolyType
(
const
String
&
entity_poly_type
)
{
std
::
unordered_set
<
std
::
string
>
s
=
{
"cyclic-pseudo-peptide"
,
std
::
unordered_set
<
std
::
string
>
s
=
{
"cyclic-pseudo-peptide"
,
"other"
,
"other"
,
...
@@ -1066,7 +1020,7 @@ namespace {
...
@@ -1066,7 +1020,7 @@ namespace {
"is not mmcif_conform"
);
"is not mmcif_conform"
);
}
}
ChainNameGenerator
chain_name_gen
;
ost
::
io
::
ChainNameGenerator
chain_name_gen
;
std
::
set
<
String
>
unique_compounds
;
std
::
set
<
String
>
unique_compounds
;
for
(
auto
res_list
:
res_lists
)
{
for
(
auto
res_list
:
res_lists
)
{
...
@@ -1465,6 +1419,45 @@ namespace {
...
@@ -1465,6 +1419,45 @@ namespace {
namespace
ost
{
namespace
io
{
namespace
ost
{
namespace
io
{
ChainNameGenerator
::
ChainNameGenerator
()
{
chain_names
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"
;
n_chain_names
=
chain_names
.
size
();
indices
.
push_back
(
-
1
);
}
String
ChainNameGenerator
::
Get
()
{
int
idx
=
indices
.
size
()
-
1
;
indices
[
idx
]
+=
1
;
bool
more_digits
=
false
;
while
(
idx
>=
0
)
{
if
(
indices
[
idx
]
>=
n_chain_names
)
{
indices
[
idx
]
=
0
;
if
(
idx
>
0
)
{
indices
[
idx
-
1
]
+=
1
;
--
idx
;
}
else
{
more_digits
=
true
;
break
;
}
}
else
{
break
;
}
}
if
(
more_digits
)
{
indices
.
insert
(
indices
.
begin
(),
0
);
}
String
ch_name
(
indices
.
size
(),
'X'
);
for
(
uint
i
=
0
;
i
<
indices
.
size
();
++
i
)
{
ch_name
[
i
]
=
chain_names
[
indices
[
i
]];
}
return
ch_name
;
}
void
ChainNameGenerator
::
Reset
()
{
indices
.
clear
();
indices
.
push_back
(
-
1
);
}
MMCifWriterEntity
MMCifWriterEntity
::
FromPolymer
(
const
String
&
entity_poly_type
,
MMCifWriterEntity
MMCifWriterEntity
::
FromPolymer
(
const
String
&
entity_poly_type
,
const
std
::
vector
<
String
>&
mon_ids
,
const
std
::
vector
<
String
>&
mon_ids
,
conop
::
CompoundLibPtr
compound_lib
)
{
conop
::
CompoundLibPtr
compound_lib
)
{
...
...
This diff is collapsed.
Click to expand it.
modules/io/src/mol/mmcif_writer.hh
+
12
−
0
View file @
a1c74efa
...
@@ -30,6 +30,18 @@
...
@@ -30,6 +30,18 @@
namespace
ost
{
namespace
io
{
namespace
ost
{
namespace
io
{
// generates as many chain names as you want (potentially multiple characters)
struct
ChainNameGenerator
{
ChainNameGenerator
();
String
Get
();
void
Reset
();
String
chain_names
;
int
n_chain_names
;
std
::
vector
<
int
>
indices
;
};
struct
MMCifWriterEntity
{
struct
MMCifWriterEntity
{
...
...
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