Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mrdna
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
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
tbgl
tools
mrdna
Commits
817951ed
Commit
817951ed
authored
6 years ago
by
cmaffeo2
Browse files
Options
Downloads
Patches
Plain Diff
Made segmentmodel_from_lists reader create splines from more than two points
parent
d291aa85
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mrdna/readers/segmentmodel_from_lists.py
+23
-18
23 additions, 18 deletions
mrdna/readers/segmentmodel_from_lists.py
mrdna/segmentmodel.py
+5
-3
5 additions, 3 deletions
mrdna/segmentmodel.py
with
28 additions
and
21 deletions
mrdna/readers/segmentmodel_from_lists.py
+
23
−
18
View file @
817951ed
...
@@ -81,6 +81,22 @@ def SegmentModelFromPdb(*args,**kwargs):
...
@@ -81,6 +81,22 @@ def SegmentModelFromPdb(*args,**kwargs):
## Build map from residue index to helix index
## Build map from residue index to helix index
def
set_splines
(
seg
,
coordinates
,
hid
,
hmap
,
hrank
):
maxrank
=
np
.
max
(
hrank
[
hmap
==
hid
]
)
if
maxrank
==
0
:
ids
=
np
.
where
((
hmap
==
hid
))[
0
]
pos
=
np
.
mean
(
[
coordinates
[
r
,:]
for
r
in
ids
],
axis
=
0
)
coords
=
[
pos
,
pos
]
contours
=
[
0
,
1
]
else
:
coords
,
contours
=
[[],[]]
for
rank
in
range
(
int
(
maxrank
)
+
1
):
ids
=
np
.
where
((
hmap
==
hid
)
*
(
hrank
==
rank
))[
0
]
coords
.
append
(
np
.
mean
(
[
coordinates
[
r
,:]
for
r
in
ids
],
axis
=
0
))
contours
.
append
(
float
(
rank
)
/
maxrank
)
coords
=
np
.
array
(
coords
)
seg
.
set_splines
(
coords
,
contours
)
def
model_from_basepair_stack_3prime
(
coordinates
,
basepair
,
stack
,
three_prime
,
sequence
=
None
):
def
model_from_basepair_stack_3prime
(
coordinates
,
basepair
,
stack
,
three_prime
,
sequence
=
None
):
"""
"""
...
@@ -160,32 +176,20 @@ def model_from_basepair_stack_3prime(coordinates, basepair, stack, three_prime,
...
@@ -160,32 +176,20 @@ def model_from_basepair_stack_3prime(coordinates, basepair, stack, three_prime,
## Create double-stranded segments
## Create double-stranded segments
doubleSegments
=
[]
doubleSegments
=
[]
for
hid
in
double_stranded_helices
:
for
hid
in
double_stranded_helices
:
maxrank
=
np
.
max
(
hrank
[
hmap
==
hid
]
)
start
=
np
.
where
((
hmap
==
hid
)
*
(
hrank
==
0
))[
0
]
end
=
np
.
where
((
hmap
==
hid
)
*
(
hrank
==
maxrank
))[
0
]
start_pos
=
np
.
mean
(
[
coordinates
[
r
,:]
for
r
in
start
],
axis
=
0
)
end_pos
=
np
.
mean
(
[
coordinates
[
r
,:]
for
r
in
end
],
axis
=
0
)
seg
=
DoubleStrandedSegment
(
name
=
str
(
hid
),
seg
=
DoubleStrandedSegment
(
name
=
str
(
hid
),
num_bp
=
np
.
sum
(
hmap
==
hid
)
//
2
,
num_bp
=
np
.
sum
(
hmap
==
hid
)
//
2
)
start_position
=
start_pos
,
set_splines
(
seg
,
coordinates
,
hid
,
hmap
,
hrank
)
end_position
=
end_pos
)
assert
(
hid
==
len
(
doubleSegments
))
assert
(
hid
==
len
(
doubleSegments
))
doubleSegments
.
append
(
seg
)
doubleSegments
.
append
(
seg
)
## Create single-stranded segments
## Create single-stranded segments
singleSegments
=
[]
singleSegments
=
[]
for
hid
in
single_stranded_helices
:
for
hid
in
single_stranded_helices
:
maxrank
=
np
.
max
(
hrank
[
hmap
==
hid
]
)
start
=
np
.
where
((
hmap
==
hid
)
*
(
hrank
==
0
))[
0
]
end
=
np
.
where
((
hmap
==
hid
)
*
(
hrank
==
maxrank
))[
0
]
start_pos
=
np
.
mean
(
[
coordinates
[
r
,:]
for
r
in
start
],
axis
=
0
)
end_pos
=
np
.
mean
(
[
coordinates
[
r
,:]
for
r
in
end
],
axis
=
0
)
seg
=
SingleStrandedSegment
(
name
=
str
(
hid
),
seg
=
SingleStrandedSegment
(
name
=
str
(
hid
),
num_nt
=
np
.
sum
(
hmap
==
hid
)
,
num_nt
=
np
.
sum
(
hmap
==
hid
)
)
start_position
=
start_pos
,
set_splines
(
seg
,
coordinates
,
hid
,
hmap
,
hrank
)
end_position
=
end_pos
)
assert
(
hid
==
len
(
doubleSegments
)
+
len
(
singleSegments
))
assert
(
hid
==
len
(
doubleSegments
)
+
len
(
singleSegments
))
singleSegments
.
append
(
seg
)
singleSegments
.
append
(
seg
)
...
@@ -230,6 +234,7 @@ def model_from_basepair_stack_3prime(coordinates, basepair, stack, three_prime,
...
@@ -230,6 +234,7 @@ def model_from_basepair_stack_3prime(coordinates, basepair, stack, three_prime,
local_twist
=
False
,
local_twist
=
False
,
dimensions
=
(
5000
,
5000
,
5000
))
dimensions
=
(
5000
,
5000
,
5000
))
if
sequence
is
None
:
if
sequence
is
None
:
model
.
randomize_unset_sequence
()
model
.
randomize_unset_sequence
()
...
...
This diff is collapsed.
Click to expand it.
mrdna/segmentmodel.py
+
5
−
3
View file @
817951ed
...
@@ -385,12 +385,14 @@ class Segment(ConnectableElement, Group):
...
@@ -385,12 +385,14 @@ class Segment(ConnectableElement, Group):
def
__repr__
(
self
):
def
__repr__
(
self
):
return
"
<{} {}[{:d}]>
"
.
format
(
type
(
self
),
self
.
name
,
self
.
num_nt
)
return
"
<{} {}[{:d}]>
"
.
format
(
type
(
self
),
self
.
name
,
self
.
num_nt
)
def
set_splines
(
self
,
coords
,
contours
):
tck
,
u
=
interpolate
.
splprep
(
coords
.
T
,
u
=
contours
,
s
=
0
,
k
=
1
)
self
.
position_spline_params
=
tck
def
_set_splines_from_ends
(
self
):
def
_set_splines_from_ends
(
self
):
a
=
np
.
array
([
self
.
start_position
,
self
.
end_position
]).
T
tck
,
u
=
interpolate
.
splprep
(
a
,
u
=
[
0
,
1
],
s
=
0
,
k
=
1
)
self
.
position_spline_params
=
tck
self
.
quaternion_spline_params
=
None
self
.
quaternion_spline_params
=
None
self
.
set_splines
(
np
.
array
([
self
.
start_position
,
self
.
end_position
]),
[
0
,
1
])
def
clear_all
(
self
):
def
clear_all
(
self
):
...
...
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