Skip to content

Commit

Permalink
Add some extensions for FASTA format.
Browse files Browse the repository at this point in the history
  • Loading branch information
alumi committed Dec 14, 2017
1 parent 649204b commit 0eadbdd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/cljam/io/fasta/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@

(defn- fasta-index
[fasta-path]
(if-let [fai-path (->> ["$1.fai" ".fai" "$1.FAI" ".FAI"]
(eduction
(comp
(map #(cstr/replace fasta-path #"(?i)(\.fa(sta)?)$" %))
(filter #(.isFile (cio/file %)))))
first)]
(fai/reader fai-path)
(throw (FileNotFoundException.
(str "Could not find FASTA Index file for " fasta-path)))))
(let [fasta-exts #"(?i)(\.(fa|fasta|fas|fsa|seq|fna|faa|ffn|frn|mpfa)?)$"]
(if-let [fai-path (->> ["$1.fai" ".fai" "$1.FAI" ".FAI"]
(eduction
(comp
(map #(cstr/replace fasta-path fasta-exts %))
(filter #(.isFile (cio/file %)))))
first)]
(fai/reader fai-path)
(throw (FileNotFoundException.
(str "Could not find FASTA Index file for " fasta-path))))))

(defn ^FASTAReader reader
[f]
Expand Down
2 changes: 1 addition & 1 deletion src/cljam/io/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
#"(?i)\.bam$" :bam
#"(?i)\.f(ast)?q" :fastq
#"(?i)\.fai$" :fai
#"(?i)\.fa(sta)?" :fasta
#"(?i)\.(fa|fasta|fas|fsa|seq|fna|faa|ffn|frn|mpfa)" :fasta
#"(?i)\.2bit$" :2bit
#"(?i)\.vcf" :vcf
#"(?i)\.bcf$" :bcf
Expand Down
8 changes: 8 additions & 0 deletions test/cljam/io/util_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
"foo.FA.GZ" :fasta
"foo.FASTA" :fasta
"foo.FASTA.GZ" :fasta
"foo.fas" :fasta
"foo.fsa" :fasta
"foo.seq" :fasta
"foo.fna" :fasta
"foo.faa" :fasta
"foo.ffn" :fasta
"foo.frn" :fasta
"foo.mpfa" :fasta
"foo.fai" :fai
"foo.fa.fai" :fai
"foo.2bit" :2bit
Expand Down

0 comments on commit 0eadbdd

Please sign in to comment.