New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add utilities for whole-genome coordinate. #103
Conversation
Codecov Report
@@ Coverage Diff @@
## master #103 +/- ##
==========================================
+ Coverage 84.94% 85.22% +0.27%
==========================================
Files 60 61 +1
Lines 3966 4019 +53
Branches 400 403 +3
==========================================
+ Hits 3369 3425 +56
Misses 197 197
+ Partials 400 397 -3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the enhancement! Implementation seems good. I commented about code style and naming. Please reply to me if you cannot agree on the naming convention.
test/cljam/util/t_whole_genome.clj
Outdated
(testing "whole-genome -> chr" | ||
(are [?wg-pos ?chr-and-pos] | ||
(= (wg/to-chr-and-pos idx ?wg-pos) ?chr-and-pos) | ||
0 nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect indentations
src/cljam/util/whole_genome.clj
Outdated
[e-offset {e-name :name e-len :len}] (first (rsubseq offset->ref <= (dec end')))] | ||
(if (= s-offset e-offset) | ||
[{:chr s-name, :start (- start' s-offset), :end (min (- end' s-offset) s-len)}] | ||
(concat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to-regions
returns a vector when the region is in a ref, returning a lazy sequence when not. I think it should return a vector in both cases.
src/cljam/util/whole_genome.clj
Outdated
(map (fn [r offset] [(:name r) {:offset offset, :len (:len r)}]) refs) | ||
(into {}))) | ||
|
||
(defn to-whole-genome-coord |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
->
is used for conversion functions in cljam. I prefer ->whole-genome-coord
.
src/cljam/util/whole_genome.clj
Outdated
(reductions + 0)) | ||
refs))) | ||
|
||
(defn to-chr-and-pos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer ->chr-and-pos
.
src/cljam/util/whole_genome.clj
Outdated
(when (<= 1 (- wg-pos offset) len) | ||
[name (- wg-pos offset)]))) | ||
|
||
(defn to-regions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer ->regions
.
src/cljam/util/whole_genome.clj
Outdated
@@ -0,0 +1,53 @@ | |||
(ns cljam.util.whole-genome | |||
"Utilities for conversions between chromosomal positions and whole-genome positions.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap a line at 80 characters if possible. cf. clojure-style-guide#80-character-limits
src/cljam/util/whole_genome.clj
Outdated
(ns cljam.util.whole-genome | ||
"Utilities for conversions between chromosomal positions and whole-genome positions.") | ||
|
||
(defn create-chr-to-whole-genome-index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In cljam, create-*
is used for file-generating functions such as bam-indexer/create-index
and dict/create-dict
. I think make-*
is better for this function, or simply chr-to-whole-genome-index
is also good.
src/cljam/util/whole_genome.clj
Outdated
(when (<= 1 pos len) | ||
(inc (+ offset (dec pos)))))) | ||
|
||
(defn create-whole-genome-to-chr-index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the comment on create-chr-to-whole-genome-index
Thank you so much for the advice! 馃槀 I also modified |
Perfect, thanks! |
Summary
This PR adds some utilities for conversion between chromosomal positions and positions in whole-genome coordinate like this one and this one.
Tests
lein test :all
馃啑