Created
February 9, 2012 16:37
-
-
Save ship561/1780967 to your computer and use it in GitHub Desktop.
convert a stockholm file to clustal w format.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn sto->aln | |
"Convert a stockhom format alignment file into its ClustalW | |
equivalent ALN format. STOIN is the filespec for the stockholm | |
format file and ALNOUT is the filespec for the resulting | |
conversion (it is overwritten if it already exists!)" | |
[stoin alnout] | |
(let [seq-lines (second (join-sto-fasta-lines stoin "")) | |
seq-lines (map (fn [[nm [uid sl]]] | |
[nm [uid (map #(str/join "" %) (partition-all 60 (str/replace-re #"\." "-" sl)))]]) | |
seq-lines)] | |
(io/with-out-writer alnout | |
(println "CLUSTAL W (1.83) multiple sequence alignment\n") | |
(loop [x seq-lines] | |
(let [[nm [uid sl]] (first x)] | |
(when (not-empty sl) | |
(do | |
(doseq [[nm [uid sl]] x] | |
(cl-format true "~A~40T~A~%" nm (first sl))) | |
(println "") | |
(recur (map (fn [[nm [uid sl]]] | |
[nm [uid (rest sl)]]) | |
x))))))) | |
alnout) | |
;; (let [seq-lines (filter #(not (or (= "//" %) (re-find #"^#" %))) | |
;; (first (sto-GC-and-seq-lines stoin))) | |
;; seq-lines (map #(str/replace-re #"\." "-" %) seq-lines)] | |
;; (io/with-out-writer (fs/fullpath alnout) | |
;; (println "CLUSTAL W (1.83) multiple sequence alignment\n") | |
;; (doseq [sl seq-lines] | |
;; (println sl))) | |
;; alnout) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment