Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
baseLess
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lannoy, Carlos de
baseLess
Commits
f67ec03b
Commit
f67ec03b
authored
3 years ago
by
Noordijk, Ben
Browse files
Options
Downloads
Patches
Plain Diff
DB creation can now handle edge cases
parent
c188067d
No related branches found
Branches containing commit
No related tags found
1 merge request
!5
compare_accuracy.py now saves confusion matrices and can be called on the...
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
db_building/TrainingRead.py
+13
-2
13 additions, 2 deletions
db_building/TrainingRead.py
train_nn.py
+2
-0
2 additions, 0 deletions
train_nn.py
with
15 additions
and
2 deletions
db_building/TrainingRead.py
+
13
−
2
View file @
f67ec03b
...
...
@@ -196,6 +196,15 @@ class TrainingRead(Persistent):
width_l
-=
random_offset
width_r
+=
random_offset
mid_idx
=
ch
[
1
]
+
len
(
ch
[
2
])
//
2
# Handle edge cases
if
width_l
>
mid_idx
:
# Cannot cut off enough on left side
width_l
=
mid_idx
width_r
=
width
-
width_l
elif
width_r
>
len
(
self
.
raw
)
-
mid_idx
:
# Cannot cut off enough on right side
width_r
=
len
(
self
.
raw
)
-
mid_idx
width_l
=
width
-
width_r
candidate_raw
=
self
.
raw
[
mid_idx
-
width_l
:
mid_idx
+
width_r
]
kmer_in_read
=
np
.
all
(
np
.
in1d
(
ch
[
2
],
candidate_raw
))
...
...
@@ -221,14 +230,16 @@ class TrainingRead(Persistent):
pos_kmer_seqs
=
[
pos_event
[
2
]
for
pos_event
in
pos_events
]
# Make sure the negative examples are far enough away from
# the target k mer (manually add 30 to be extra safe).
idx_list
.
remove
(
cur_idx
)
if
np
.
all
(
np
.
array
(
distances_to_kmer
)
>
width
):
mid_idx
=
cur_condensed_event
[
1
]
+
len
(
cur_condensed_event
[
2
])
//
2
candidate_raw
=
self
.
raw
[
mid_idx
-
width_l
:
mid_idx
+
width_r
]
target_kmer_in_read
=
np
.
all
([
np
.
in1d
(
pos_raw
,
candidate_raw
)
for
pos_raw
in
pos_kmer_seqs
])
assert
not
target_kmer_in_read
,
'
Target kmer in negative read
'
if
target_kmer_in_read
:
# Something went wrong (probably edge case (that I should fix)), try again
continue
raw_hits_out
.
append
(
candidate_raw
)
raw_kmers_out
.
append
(
cur_condensed_event
[
0
])
idx_list
.
remove
(
cur_idx
)
return
raw_hits_out
,
raw_kmers_out
This diff is collapsed.
Click to expand it.
train_nn.py
+
2
−
0
View file @
f67ec03b
import
random
import
re
from
collections
import
Counter
import
yaml
import
pickle
import
importlib
...
...
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