Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add many tests / Remove unused codes about slurp fasta #60

Merged

Conversation

ayamada
Copy link
Contributor

@ayamada ayamada commented Apr 19, 2017

@codecov-io
Copy link

codecov-io commented Apr 19, 2017

Codecov Report

Merging #60 into master will increase coverage by 8.53%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #60      +/-   ##
=========================================
+ Coverage   73.87%   82.4%   +8.53%     
=========================================
  Files          56      56              
  Lines        3288    3285       -3     
  Branches      334     363      +29     
=========================================
+ Hits         2429    2707     +278     
+ Misses        525     215     -310     
- Partials      334     363      +29
Impacted Files Coverage Δ
src/cljam/fasta/reader.clj 89.18% <ø> (+18.91%) ⬆️
src/cljam/fasta/core.clj 100% <ø> (+23.52%) ⬆️
src/cljam/pileup.clj 93.33% <0%> (-6.67%) ⬇️
src/cljam/bam_index/writer.clj 74.87% <0%> (+1.47%) ⬆️
src/cljam/bam_index/core.clj 71.92% <0%> (+1.75%) ⬆️
src/cljam/tabix.clj 100% <0%> (+3.92%) ⬆️
src/cljam/bam/writer.clj 76.86% <0%> (+4.47%) ⬆️
src/cljam/twobit.clj 78.21% <0%> (+4.95%) ⬆️
src/cljam/sam/writer.clj 70% <0%> (+5%) ⬆️
src/cljam/util.clj 78.87% <0%> (+5.63%) ⬆️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e365309...e566fee. Read the comment docs.

(let [in-file test-sorted-bam-file
out-file (str temp-dir "/deduped.bam")]
(is (not-throw? (dedupe/dedupe in-file out-file)))
;; TODO: check alignments of out-file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you open issues for TODOs in this diff?
Coverage will be increased but almost no code semantics is tested here.
I think we need to track the problem to remind that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will open issue for this, later.
Some tests needs to check result data certainly, but I cannot create those data.

(with-before-after {:before (prepare-cache!)
:after (clean-cache!)}
(let [rdr (bam/reader test-sorted-bam-file :ignore-index false)]
;; TODO: Does not works?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open an issue for here, too.

I think representing entire region of a single chromosome by {:chr REFNAME} will be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right, I will open issue for this, too.
I guess I wrong something, but I didn't know this reason.

Copy link
Member

@totakke totakke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for great contribution. I've added some comments. Awaiting for your fix or response.

true
(when (and (= (:rname aln1) (:rname aln2))
(= (:pos aln1) (:pos aln2)))
(recur (rest alns1) (rest alns2))))))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation using loop/recur is complicated. I think

(defn- shallow= [alns1 alns2]
  (= (map #(selece-keys % [:rname :pos]) alns1)
     (map #(selece-keys % [:rname :pos]) alns2)))

is more simple. Or are there any reason? (memory usage?). Also pointer=.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review.
I guess sure too, I fixed 88ff657 .

(deftest bamreader
(with-before-after {:before (do (prepare-cache!)
(spit-bam-for-test temp-file test-sam))
:after (clean-cache!)}
(let [rdr (bam/reader temp-file :ignore-index true)]
(is (= (io/read-refs rdr) test-sam-refs)))))
(let [rdr (bam/reader temp-file :ignore-index false)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BAMReader will not be closed. with-open should be used instead of let. (I don't know why original code uses let...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, fixed 91ae96e .

(is (= (count (io/read-alignments r {:chr "chr1" :start 23000000 :end 24000000 :depth :deep}))
10010))
(is (= (count (io/read-alignments r {:chr "chr1" :start 23000000 :end 23500000 :depth :deep}))
3806))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are is better than is because similar codes are repeated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed e566fee .


(defmacro with-out-file
[f & body]
`(binding [*out* (clojure.java.io/writer ~f)]
~@body))
`(let [os# (clojure.java.io/output-stream ~f)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

io/output-stream

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed cf24f13 .

ps# (PrintStream. os#)]
(try
(System/setOut ps#)
(binding [*out* (clojure.java.io/writer os#)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

io/writer

(is (thrown? java.io.IOException
(let [rdr (fasta/reader test-tabix-file)]
(fasta/read rdr))))
(let [rdr (fasta/reader test-fa-file)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with-open instead of let

(is (= (util/str->int "-456") -456))
(is (= (util/str->int "+789") 789))
(is (= Integer (type (util/str->int "123"))))
(is (= Long (type (util/str->int "12345678901"))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel (instance? Long (util/str->int "12345678901")) is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 74f19e4 .

Thanks for your reviews!

@ayamada
Copy link
Contributor Author

ayamada commented Apr 20, 2017

I fixed above problems, are these OK ?

@totakke
Copy link
Member

totakke commented Apr 20, 2017

Perfect, thanks.

@ayamada
Copy link
Contributor Author

ayamada commented Apr 20, 2017

Thanks for merge!
I created related issues #61 and #62 .

@ayamada ayamada deleted the feature/add-tests-for-coverage-only-fixes-s branch April 28, 2017 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants