miga-base 0.3.0.0 → 0.3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -4
  3. data/actions/init.rb +258 -0
  4. data/actions/run_local.rb +1 -2
  5. data/actions/test_taxonomy.rb +4 -1
  6. data/bin/miga +8 -1
  7. data/lib/miga/dataset.rb +4 -4
  8. data/lib/miga/dataset_result.rb +7 -4
  9. data/lib/miga/version.rb +2 -2
  10. data/scripts/_distances_noref_nomulti.bash +3 -1
  11. data/scripts/clade_finding.bash +1 -1
  12. data/scripts/init.bash +1 -1
  13. data/scripts/miga.bash +1 -1
  14. data/scripts/mytaxa.bash +78 -72
  15. data/scripts/mytaxa_scan.bash +67 -62
  16. data/scripts/ogs.bash +1 -1
  17. data/scripts/trimmed_fasta.bash +4 -3
  18. data/utils/enveomics/Examples/aai-matrix.bash +66 -0
  19. data/utils/enveomics/Examples/ani-matrix.bash +66 -0
  20. data/utils/enveomics/Examples/essential-phylogeny.bash +105 -0
  21. data/utils/enveomics/Examples/unus-genome-phylogeny.bash +100 -0
  22. data/utils/enveomics/LICENSE.txt +73 -0
  23. data/utils/enveomics/Makefile +52 -0
  24. data/utils/enveomics/Manifest/Tasks/aasubs.json +103 -0
  25. data/utils/enveomics/Manifest/Tasks/blasttab.json +703 -0
  26. data/utils/enveomics/Manifest/Tasks/distances.json +161 -0
  27. data/utils/enveomics/Manifest/Tasks/fasta.json +571 -0
  28. data/utils/enveomics/Manifest/Tasks/fastq.json +208 -0
  29. data/utils/enveomics/Manifest/Tasks/graphics.json +126 -0
  30. data/utils/enveomics/Manifest/Tasks/ogs.json +339 -0
  31. data/utils/enveomics/Manifest/Tasks/other.json +746 -0
  32. data/utils/enveomics/Manifest/Tasks/remote.json +355 -0
  33. data/utils/enveomics/Manifest/Tasks/sequence-identity.json +454 -0
  34. data/utils/enveomics/Manifest/Tasks/tables.json +308 -0
  35. data/utils/enveomics/Manifest/Tasks/trees.json +68 -0
  36. data/utils/enveomics/Manifest/Tasks/variants.json +111 -0
  37. data/utils/enveomics/Manifest/categories.json +132 -0
  38. data/utils/enveomics/Manifest/examples.json +154 -0
  39. data/utils/enveomics/Manifest/tasks.json +4 -0
  40. data/utils/enveomics/Pipelines/assembly.pbs/CONFIG.mock.bash +69 -0
  41. data/utils/enveomics/Pipelines/assembly.pbs/FastA.N50.pl +56 -0
  42. data/utils/enveomics/Pipelines/assembly.pbs/FastA.filterN.pl +60 -0
  43. data/utils/enveomics/Pipelines/assembly.pbs/FastA.length.pl +38 -0
  44. data/utils/enveomics/Pipelines/assembly.pbs/README.md +189 -0
  45. data/utils/enveomics/Pipelines/assembly.pbs/RUNME-2.bash +112 -0
  46. data/utils/enveomics/Pipelines/assembly.pbs/RUNME-3.bash +23 -0
  47. data/utils/enveomics/Pipelines/assembly.pbs/RUNME-4.bash +44 -0
  48. data/utils/enveomics/Pipelines/assembly.pbs/RUNME.bash +50 -0
  49. data/utils/enveomics/Pipelines/assembly.pbs/kSelector.R +37 -0
  50. data/utils/enveomics/Pipelines/assembly.pbs/newbler.pbs +68 -0
  51. data/utils/enveomics/Pipelines/assembly.pbs/newbler_preparator.pl +49 -0
  52. data/utils/enveomics/Pipelines/assembly.pbs/soap.pbs +80 -0
  53. data/utils/enveomics/Pipelines/assembly.pbs/stats.pbs +57 -0
  54. data/utils/enveomics/Pipelines/assembly.pbs/velvet.pbs +63 -0
  55. data/utils/enveomics/Pipelines/blast.pbs/01.pbs.bash +38 -0
  56. data/utils/enveomics/Pipelines/blast.pbs/02.pbs.bash +73 -0
  57. data/utils/enveomics/Pipelines/blast.pbs/03.pbs.bash +21 -0
  58. data/utils/enveomics/Pipelines/blast.pbs/BlastTab.recover_job.pl +72 -0
  59. data/utils/enveomics/Pipelines/blast.pbs/CONFIG.mock.bash +98 -0
  60. data/utils/enveomics/Pipelines/blast.pbs/FastA.split.pl +55 -0
  61. data/utils/enveomics/Pipelines/blast.pbs/README.md +127 -0
  62. data/utils/enveomics/Pipelines/blast.pbs/RUNME.bash +109 -0
  63. data/utils/enveomics/Pipelines/blast.pbs/TASK.check.bash +128 -0
  64. data/utils/enveomics/Pipelines/blast.pbs/TASK.dry.bash +16 -0
  65. data/utils/enveomics/Pipelines/blast.pbs/TASK.eo.bash +22 -0
  66. data/utils/enveomics/Pipelines/blast.pbs/TASK.pause.bash +26 -0
  67. data/utils/enveomics/Pipelines/blast.pbs/TASK.run.bash +89 -0
  68. data/utils/enveomics/Pipelines/blast.pbs/sentinel.pbs.bash +29 -0
  69. data/utils/enveomics/Pipelines/idba.pbs/README.md +49 -0
  70. data/utils/enveomics/Pipelines/idba.pbs/RUNME.bash +95 -0
  71. data/utils/enveomics/Pipelines/idba.pbs/run.pbs +56 -0
  72. data/utils/enveomics/Pipelines/trim.pbs/README.md +54 -0
  73. data/utils/enveomics/Pipelines/trim.pbs/RUNME.bash +70 -0
  74. data/utils/enveomics/Pipelines/trim.pbs/run.pbs +130 -0
  75. data/utils/enveomics/README.md +40 -0
  76. data/utils/enveomics/Scripts/AAsubs.log2ratio.rb +171 -0
  77. data/utils/enveomics/Scripts/Aln.cat.rb +162 -0
  78. data/utils/enveomics/Scripts/Aln.convert.pl +35 -0
  79. data/utils/enveomics/Scripts/AlphaDiversity.pl +152 -0
  80. data/utils/enveomics/Scripts/BlastPairwise.AAsubs.pl +102 -0
  81. data/utils/enveomics/Scripts/BlastTab.addlen.rb +61 -0
  82. data/utils/enveomics/Scripts/BlastTab.advance.bash +48 -0
  83. data/utils/enveomics/Scripts/BlastTab.best_hit_sorted.pl +55 -0
  84. data/utils/enveomics/Scripts/BlastTab.catsbj.pl +106 -0
  85. data/utils/enveomics/Scripts/BlastTab.cogCat.rb +76 -0
  86. data/utils/enveomics/Scripts/BlastTab.filter.pl +47 -0
  87. data/utils/enveomics/Scripts/BlastTab.kegg_pep2path_rest.pl +194 -0
  88. data/utils/enveomics/Scripts/BlastTab.metaxaPrep.pl +104 -0
  89. data/utils/enveomics/Scripts/BlastTab.pairedHits.rb +157 -0
  90. data/utils/enveomics/Scripts/BlastTab.recplot2.R +40 -0
  91. data/utils/enveomics/Scripts/BlastTab.seqdepth.pl +86 -0
  92. data/utils/enveomics/Scripts/BlastTab.seqdepth_ZIP.pl +119 -0
  93. data/utils/enveomics/Scripts/BlastTab.seqdepth_nomedian.pl +86 -0
  94. data/utils/enveomics/Scripts/BlastTab.subsample.pl +47 -0
  95. data/utils/enveomics/Scripts/BlastTab.sumPerHit.pl +114 -0
  96. data/utils/enveomics/Scripts/BlastTab.taxid2taxrank.pl +90 -0
  97. data/utils/enveomics/Scripts/BlastTab.topHits_sorted.rb +101 -0
  98. data/utils/enveomics/Scripts/Chao1.pl +97 -0
  99. data/utils/enveomics/Scripts/CharTable.classify.rb +234 -0
  100. data/utils/enveomics/Scripts/EBIseq2tax.rb +83 -0
  101. data/utils/enveomics/Scripts/FastA.N50.pl +56 -0
  102. data/utils/enveomics/Scripts/FastA.filter.pl +52 -0
  103. data/utils/enveomics/Scripts/FastA.filterLen.pl +28 -0
  104. data/utils/enveomics/Scripts/FastA.filterN.pl +60 -0
  105. data/utils/enveomics/Scripts/FastA.fragment.rb +92 -0
  106. data/utils/enveomics/Scripts/FastA.gc.pl +42 -0
  107. data/utils/enveomics/Scripts/FastA.interpose.pl +87 -0
  108. data/utils/enveomics/Scripts/FastA.length.pl +38 -0
  109. data/utils/enveomics/Scripts/FastA.per_file.pl +36 -0
  110. data/utils/enveomics/Scripts/FastA.qlen.pl +57 -0
  111. data/utils/enveomics/Scripts/FastA.rename.pl +65 -0
  112. data/utils/enveomics/Scripts/FastA.revcom.pl +23 -0
  113. data/utils/enveomics/Scripts/FastA.slider.pl +85 -0
  114. data/utils/enveomics/Scripts/FastA.split.pl +55 -0
  115. data/utils/enveomics/Scripts/FastA.subsample.pl +131 -0
  116. data/utils/enveomics/Scripts/FastA.tag.rb +64 -0
  117. data/utils/enveomics/Scripts/FastA.wrap.rb +48 -0
  118. data/utils/enveomics/Scripts/FastQ.filter.pl +54 -0
  119. data/utils/enveomics/Scripts/FastQ.interpose.pl +90 -0
  120. data/utils/enveomics/Scripts/FastQ.offset.pl +90 -0
  121. data/utils/enveomics/Scripts/FastQ.split.pl +53 -0
  122. data/utils/enveomics/Scripts/FastQ.tag.rb +63 -0
  123. data/utils/enveomics/Scripts/FastQ.toFastA.awk +24 -0
  124. data/utils/enveomics/Scripts/GenBank.add_fields.rb +84 -0
  125. data/utils/enveomics/Scripts/HMM.essential.rb +254 -0
  126. data/utils/enveomics/Scripts/HMMsearch.extractIds.rb +83 -0
  127. data/utils/enveomics/Scripts/JPlace.distances.rb +88 -0
  128. data/utils/enveomics/Scripts/JPlace.to_iToL.rb +306 -0
  129. data/utils/enveomics/Scripts/M5nr.getSequences.rb +81 -0
  130. data/utils/enveomics/Scripts/MeTaxa.distribution.pl +198 -0
  131. data/utils/enveomics/Scripts/MyTaxa.fragsByTax.pl +35 -0
  132. data/utils/enveomics/Scripts/MyTaxa.seq-taxrank.rb +49 -0
  133. data/utils/enveomics/Scripts/NCBIacc2tax.rb +92 -0
  134. data/utils/enveomics/Scripts/Newick.autoprune.R +27 -0
  135. data/utils/enveomics/Scripts/RAxML-EPA.to_iToL.pl +228 -0
  136. data/utils/enveomics/Scripts/RefSeq.download.bash +48 -0
  137. data/utils/enveomics/Scripts/SRA.download.bash +50 -0
  138. data/utils/enveomics/Scripts/TRIBS.plot-test.R +36 -0
  139. data/utils/enveomics/Scripts/TRIBS.test.R +39 -0
  140. data/utils/enveomics/Scripts/Table.barplot.R +30 -0
  141. data/utils/enveomics/Scripts/Table.df2dist.R +30 -0
  142. data/utils/enveomics/Scripts/Table.filter.pl +61 -0
  143. data/utils/enveomics/Scripts/Table.merge.pl +77 -0
  144. data/utils/enveomics/Scripts/Table.replace.rb +69 -0
  145. data/utils/enveomics/Scripts/Table.round.rb +63 -0
  146. data/utils/enveomics/Scripts/Table.split.pl +57 -0
  147. data/utils/enveomics/Scripts/Taxonomy.silva2ncbi.rb +227 -0
  148. data/utils/enveomics/Scripts/VCF.KaKs.rb +147 -0
  149. data/utils/enveomics/Scripts/VCF.SNPs.rb +88 -0
  150. data/utils/enveomics/Scripts/aai.rb +373 -0
  151. data/utils/enveomics/Scripts/ani.rb +362 -0
  152. data/utils/enveomics/Scripts/gi2tax.rb +103 -0
  153. data/utils/enveomics/Scripts/in_silico_GA_GI.pl +96 -0
  154. data/utils/enveomics/Scripts/lib/data/essential.hmm.gz +0 -0
  155. data/utils/enveomics/Scripts/lib/enveomics_rb/enveomics.rb +26 -0
  156. data/utils/enveomics/Scripts/lib/enveomics_rb/jplace.rb +253 -0
  157. data/utils/enveomics/Scripts/lib/enveomics_rb/og.rb +182 -0
  158. data/utils/enveomics/Scripts/lib/enveomics_rb/remote_data.rb +74 -0
  159. data/utils/enveomics/Scripts/lib/enveomics_rb/seq_range.rb +237 -0
  160. data/utils/enveomics/Scripts/lib/enveomics_rb/stat.rb +30 -0
  161. data/utils/enveomics/Scripts/lib/enveomics_rb/vcf.rb +135 -0
  162. data/utils/enveomics/Scripts/ogs.annotate.rb +88 -0
  163. data/utils/enveomics/Scripts/ogs.core-pan.rb +160 -0
  164. data/utils/enveomics/Scripts/ogs.extract.rb +125 -0
  165. data/utils/enveomics/Scripts/ogs.mcl.rb +186 -0
  166. data/utils/enveomics/Scripts/ogs.rb +104 -0
  167. data/utils/enveomics/Scripts/ogs.stats.rb +131 -0
  168. data/utils/enveomics/Scripts/rbm.rb +137 -0
  169. data/utils/enveomics/Tests/Makefile +10 -0
  170. data/utils/enveomics/Tests/Mgen_M2288.faa +3189 -0
  171. data/utils/enveomics/Tests/Mgen_M2288.fna +8282 -0
  172. data/utils/enveomics/Tests/Mgen_M2321.fna +8288 -0
  173. data/utils/enveomics/Tests/Nequ_Kin4M.faa +2970 -0
  174. data/utils/enveomics/Tests/Xanthomonas_oryzae-PilA.tribs.Rdata +0 -0
  175. data/utils/enveomics/Tests/Xanthomonas_oryzae-PilA.txt +7 -0
  176. data/utils/enveomics/Tests/Xanthomonas_oryzae.aai-mat.tsv +17 -0
  177. data/utils/enveomics/Tests/Xanthomonas_oryzae.aai.tsv +137 -0
  178. data/utils/enveomics/Tests/a_mg.cds-go.blast.tsv +123 -0
  179. data/utils/enveomics/Tests/a_mg.reads-cds.blast.tsv +200 -0
  180. data/utils/enveomics/Tests/a_mg.reads-cds.counts.tsv +55 -0
  181. data/utils/enveomics/Tests/alkB.nwk +1 -0
  182. data/utils/enveomics/Tests/anthrax-cansnp-data.tsv +13 -0
  183. data/utils/enveomics/Tests/anthrax-cansnp-key.tsv +17 -0
  184. data/utils/enveomics/Tests/hiv1.faa +59 -0
  185. data/utils/enveomics/Tests/hiv1.fna +134 -0
  186. data/utils/enveomics/Tests/hiv2.faa +70 -0
  187. data/utils/enveomics/Tests/hiv_mix-hiv1.blast.tsv +233 -0
  188. data/utils/enveomics/Tests/hiv_mix-hiv1.blast.tsv.lim +1 -0
  189. data/utils/enveomics/Tests/hiv_mix-hiv1.blast.tsv.rec +233 -0
  190. data/utils/enveomics/Tests/phyla_counts.tsv +10 -0
  191. data/utils/enveomics/Tests/primate_lentivirus.ogs +11 -0
  192. data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv1-hiv1.rbm +9 -0
  193. data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv1-hiv2.rbm +8 -0
  194. data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv1-siv.rbm +6 -0
  195. data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv2-hiv2.rbm +9 -0
  196. data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv2-siv.rbm +6 -0
  197. data/utils/enveomics/Tests/primate_lentivirus.rbm/siv-siv.rbm +6 -0
  198. data/utils/enveomics/build_enveomics_r.bash +44 -0
  199. data/utils/enveomics/enveomics.R/DESCRIPTION +31 -0
  200. data/utils/enveomics/enveomics.R/NAMESPACE +35 -0
  201. data/utils/enveomics/enveomics.R/R/autoprune.R +121 -0
  202. data/utils/enveomics/enveomics.R/R/barplot.R +165 -0
  203. data/utils/enveomics/enveomics.R/R/cliopts.R +119 -0
  204. data/utils/enveomics/enveomics.R/R/df2dist.R +117 -0
  205. data/utils/enveomics/enveomics.R/R/growthcurve.R +263 -0
  206. data/utils/enveomics/enveomics.R/R/recplot.R +320 -0
  207. data/utils/enveomics/enveomics.R/R/recplot2.R +745 -0
  208. data/utils/enveomics/enveomics.R/R/tribs.R +423 -0
  209. data/utils/enveomics/enveomics.R/R/utils.R +16 -0
  210. data/utils/enveomics/enveomics.R/README.md +52 -0
  211. data/utils/enveomics/enveomics.R/data/growth.curves.rda +0 -0
  212. data/utils/enveomics/enveomics.R/data/phyla.counts.rda +0 -0
  213. data/utils/enveomics/enveomics.R/man/enve.GrowthCurve-class.Rd +30 -0
  214. data/utils/enveomics/enveomics.R/man/enve.TRIBS-class.Rd +43 -0
  215. data/utils/enveomics/enveomics.R/man/enve.TRIBS.merge.Rd +19 -0
  216. data/utils/enveomics/enveomics.R/man/enve.TRIBStest-class.Rd +37 -0
  217. data/utils/enveomics/enveomics.R/man/enve.__prune.iter.Rd +24 -0
  218. data/utils/enveomics/enveomics.R/man/enve.__prune.reduce.Rd +24 -0
  219. data/utils/enveomics/enveomics.R/man/enve.__tribs.Rd +33 -0
  220. data/utils/enveomics/enveomics.R/man/enve.barplot.Rd +64 -0
  221. data/utils/enveomics/enveomics.R/man/enve.cliopts.Rd +37 -0
  222. data/utils/enveomics/enveomics.R/man/enve.col.alpha.Rd +19 -0
  223. data/utils/enveomics/enveomics.R/man/enve.col2alpha.Rd +18 -0
  224. data/utils/enveomics/enveomics.R/man/enve.df2dist.Rd +26 -0
  225. data/utils/enveomics/enveomics.R/man/enve.df2dist.group.Rd +25 -0
  226. data/utils/enveomics/enveomics.R/man/enve.df2dist.list.Rd +26 -0
  227. data/utils/enveomics/enveomics.R/man/enve.growthcurve.Rd +49 -0
  228. data/utils/enveomics/enveomics.R/man/enve.prune.dist.Rd +28 -0
  229. data/utils/enveomics/enveomics.R/man/enve.recplot.Rd +97 -0
  230. data/utils/enveomics/enveomics.R/man/enve.recplot2-class.Rd +40 -0
  231. data/utils/enveomics/enveomics.R/man/enve.recplot2.Rd +40 -0
  232. data/utils/enveomics/enveomics.R/man/enve.recplot2.__counts.Rd +24 -0
  233. data/utils/enveomics/enveomics.R/man/enve.recplot2.__findPeak.Rd +40 -0
  234. data/utils/enveomics/enveomics.R/man/enve.recplot2.__findPeaks.Rd +18 -0
  235. data/utils/enveomics/enveomics.R/man/enve.recplot2.__peakHist.Rd +22 -0
  236. data/utils/enveomics/enveomics.R/man/enve.recplot2.__whichClosestPeak.Rd +20 -0
  237. data/utils/enveomics/enveomics.R/man/enve.recplot2.changeCutoff.Rd +18 -0
  238. data/utils/enveomics/enveomics.R/man/enve.recplot2.corePeak.Rd +18 -0
  239. data/utils/enveomics/enveomics.R/man/enve.recplot2.extractWindows.Rd +27 -0
  240. data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.Rd +53 -0
  241. data/utils/enveomics/enveomics.R/man/enve.recplot2.peak-class.Rd +44 -0
  242. data/utils/enveomics/enveomics.R/man/enve.tribs.Rd +44 -0
  243. data/utils/enveomics/enveomics.R/man/enve.tribs.test.Rd +21 -0
  244. data/utils/enveomics/enveomics.R/man/enveomics.R-package.Rd +15 -0
  245. data/utils/enveomics/enveomics.R/man/growth.curves.Rd +14 -0
  246. data/utils/enveomics/enveomics.R/man/phyla.counts.Rd +13 -0
  247. data/utils/enveomics/enveomics.R/man/plot.enve.GrowthCurve.Rd +43 -0
  248. data/utils/enveomics/enveomics.R/man/plot.enve.TRIBS.Rd +29 -0
  249. data/utils/enveomics/enveomics.R/man/plot.enve.TRIBStest.Rd +30 -0
  250. data/utils/enveomics/enveomics.R/man/plot.enve.recplot2.Rd +71 -0
  251. data/utils/enveomics/enveomics.R/man/summary.enve.GrowthCurve.Rd +18 -0
  252. data/utils/enveomics/enveomics.R/man/summary.enve.TRIBS.Rd +18 -0
  253. data/utils/enveomics/enveomics.R/man/summary.enve.TRIBStest.Rd +18 -0
  254. data/utils/enveomics/enveomics.R/man/z$-methods.Rd +27 -0
  255. data/utils/enveomics/globals.mk +8 -0
  256. data/utils/enveomics/manifest.json +9 -0
  257. data/utils/index_metadata.rb +0 -0
  258. data/utils/plot-taxdist.R +0 -0
  259. data/utils/requirements.txt +19 -19
  260. metadata +242 -2
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env Rscript
2
+ #
3
+ # @author Luis M. Rodriguez-R
4
+ # @update Jan-07-2016
5
+ # @license artistic license 2.0
6
+ #
7
+
8
+ #= Load stuff
9
+ args <- commandArgs(trailingOnly = F)
10
+ enveomics_R <- file.path(dirname(
11
+ sub("^--file=", "", args[grep("^--file=", args)])),
12
+ "lib", "enveomics.R")
13
+ source(file.path(enveomics_R, "R", "cliopts.R"))
14
+ source(file.path(enveomics_R, "R", "autoprune.R"))
15
+
16
+ #= Generate interface
17
+ opt <- enve.cliopts(enve.prune.dist,
18
+ file.path(enveomics_R, "man", "enve.prune.dist.Rd"),
19
+ positional_arguments=1,
20
+ usage="usage: %prog [options] output.nwk",
21
+ mandatory=c("t"),
22
+ number=c("min_dist","order"),
23
+ o_desc=list(t="A tree to prune in Newick format."))
24
+
25
+ #= Run it!
26
+ pt <- do.call("enve.prune.dist", opt$options)
27
+ ape::write.tree(pt, opt$args[1])
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/env perl
2
+
3
+ # @author Luis M Rodriguez-R <lmrodriguezr at gmail dot com>
4
+ # @update Mar-23-2015
5
+ # @license Artistic License 2.0
6
+
7
+ use warnings;
8
+ use strict;
9
+ use List::Util qw/sum max/;
10
+ use Getopt::Std;
11
+ use Math::Round qw/round/;
12
+ our $VERSION = 1.1;
13
+
14
+ warn <<WARN
15
+
16
+
17
+ ┌──[ IMPORTANT ]─────────────────────────────────────────────────┐
18
+ │ This script has been deprecated in favor of JPlace.to_iToL.rb. │
19
+ │ Please use the new version, together with the RAxML EPA's file │
20
+ │ RAxML_portableTree.*.jplace instead. │
21
+ └────────────────────────────────────────────────────────────────┘
22
+ WARN
23
+ ;
24
+ sub HELP_MESSAGE {
25
+ die "
26
+ Description:
27
+ Reformats the node names (labels) of a RAxML_originalLabelledTree.<NAME> file
28
+ (produced by RAxML's EPA, -f v), so it can be opened in most tree viewers (like
29
+ iToL and FigTree). Also, it creates iToL-compatible files to draw pie-charts
30
+ (based on the classification of short reads) in the nodes of the reference tree.
31
+
32
+ Usage:
33
+ $0 -n <NAME> [other options...]
34
+
35
+ -n <str> * Name of the run used in RAxML.
36
+ -t <str> Use this file as original labelled tree, instead of generating one
37
+ based on the job name. By default, RAxML_originalLabelledTree.<NAME>
38
+ in the -d directory. See [NOTE1].
39
+ -d <str> Directory containing RAxML files. By default: current directory.
40
+ -o <str> Output tree. By default, it takes the path to the input tree and
41
+ appends .nwk to it.
42
+ -l <str> File containing a list of internal nodes. The nodes in the list
43
+ will be renamed, and the reads of all children nodes will be
44
+ transferred to it. This can be useful if you want to display
45
+ these nodes collapsed. The format of the file is raw text, with
46
+ two columns separated by tabs or spaces, where the first column is
47
+ the original name of the internal node (without the brackets) and
48
+ the second is the name to be used. See [NOTE2].
49
+ -a Append original label to the renamed nodes (only if -l is passed).
50
+ -s <str> The names of the reads will be assumed to contain the sample name,
51
+ separated by this string. For example, if the value is '_', and
52
+ a read has the name 'hco_ABCDEF/1#ACTG', it will be assumed to be
53
+ a read from the sample 'hco'. If not provided, all the reads are
54
+ assumed to come from the same sample (called 'unknown').
55
+ -m <str> Comma-delimited list of samples. If not provided, all found samples
56
+ will be used (unsorted).
57
+ -c <str> Comma-delimited list of colors (in RGB hexadecimal) to represent
58
+ the different samples. If not provided (or if insufficient values
59
+ are provided) random colors are generated.
60
+ -N <str> Comma-delimited list of normalizing factors per dataset. Typically,
61
+ the size of the datasets divided by a fixed value (e.g. size x 1,000,
62
+ to express sizes as reads per thousand).
63
+ -T Use the total number of assigned reads per sample (times a constant)
64
+ as the normalizing factor. The constant used corresponds to the 100
65
+ times the size of the largest factor. If passed, -N is ignored.
66
+ -q Run quietly.
67
+ -h/--help Displays this message and exits.
68
+
69
+ * Mandatory
70
+ [NOTE1] The tree provided by -t MUST be based on a tree produced by this script
71
+ without the -l option.
72
+ [NOTE2] The tree produced by RAxML-EPA is usually not correctly rooted, which
73
+ makes the -l option useless. However, you can manually root the tree and provide
74
+ the rooted tree in Newick format using the -t option. If you do this, make
75
+ sure the program doesn't change/delete the names of the internal nodes. I know
76
+ that iToL can do it correctly (if you export preserving the original IDs), while
77
+ FigTree deletes the labels. I didn't try any other tool.
78
+
79
+ ";
80
+ }
81
+
82
+ my %o;
83
+ getopts('n:t:d:o:l:s:m:c:N:Tqh', \%o);
84
+ $o{d} ||= '.';
85
+ $o{n} or &HELP_MESSAGE;
86
+ $o{h} and &HELP_MESSAGE;
87
+ $o{c} = [split /,/, (defined $o{c}?$o{c}:"")];
88
+ $o{N} = [split /,/, (defined $o{N}?$o{N}:"")];
89
+
90
+ # Set files
91
+ my $inTree = ($o{t} || $o{d}."/RAxML_originalLabelledTree.".$o{n});
92
+ my $outTree = ($o{o} || $inTree.".nwk");
93
+ my $inClass = $o{d}."/RAxML_classification.".$o{n};
94
+ my $outClass = $inClass.".iToL";
95
+ my $outColl = $outTree.".collapse.iToL";
96
+
97
+ # Relocate tree node names
98
+ print STDERR "o Reformatting tree.\n" unless $o{q};
99
+ open INTREE, "<", $inTree or die "Cannot read file: $inTree: $!\n";
100
+ my $tree = <INTREE>;
101
+ $tree =~ s/:([\d\.]+)(\[.+?\])/$2:$1/g unless $o{t};
102
+ close INTREE;
103
+
104
+ # Read leaf nodes
105
+ print STDERR "o Reading nodes.\n" unless $o{q};
106
+ my %tags = ();
107
+
108
+ my $t = $tree;
109
+ while($t =~ m/([A-Za-z0-9_\|\.-]+\[([A-Za-z0-9_\|\.-]+)\])/){
110
+ my $n = $1;
111
+ my $ta = $2;
112
+ $tags{$ta} = $n;
113
+ $t = substr $t, (length($n) + index $t, $n);
114
+ }
115
+
116
+ # Label/collapse internal nodes
117
+ if($o{l}){
118
+ print STDERR "o Labeling/collapsing internal nodes.\n";
119
+ open LIST, "<", $o{l} or die "Cannot read file: $o{l}: $!\n";
120
+ open COLL, ">", $outColl or die "Cannot create file: $outColl: $!\n";
121
+ while(<LIST>){
122
+ chomp;
123
+ next if /^#/ or /^\s*$/;
124
+ # Label internal node
125
+ my @l = split /\s+/;
126
+ $l[0] =~ m/^\[(.+)\]$/ or die "Unable to parse internal node name: $l[0].\n";
127
+ my $ori = $1;
128
+ my $new = $l[1];
129
+ if(exists $tags{$ori}){
130
+ warn "Warning: Trying to label/collapse $ori as $new, already defined as $tags{$ori}.\n";
131
+ next;
132
+ }
133
+ $new =~ s/[^A-Za-z0-9_\|\.\-]/_/g;
134
+ $new.= "[$ori]" if $o{a};
135
+ $tags{$ori} = $new;
136
+ $tree =~ s/\[$ori\]/$new/;
137
+ # Isolate node
138
+ $t = substr $tree, 0, index($tree, $new);
139
+ my $i=length($t)-2;
140
+ for(my $c=1 ; $i and $c; $i--){
141
+ my $char = substr $t, $i, 1;
142
+ $c++ if $char eq ')';
143
+ $c-- if $char eq '(';
144
+ }
145
+ $t = substr $t, $i;
146
+ # Get children
147
+ $t =~ s/:[\d\.]+|[\(\)]/,/g;
148
+ $t =~ s/,+/,/g;
149
+ my $chn=0;
150
+ for my $child (split /,/, $t){
151
+ next unless $child;
152
+ $child =~ s/.*\[(.+?)\]/$1/;
153
+ $tags{$child} = $new;
154
+ $chn++;
155
+ }
156
+ print STDERR " Collapsing $new: $chn children.\n" unless $o{q};
157
+ print COLL "$new\n";
158
+ }
159
+ close LIST;
160
+ close COLL;
161
+ }
162
+
163
+ # Save tree
164
+ open OUTTREE, ">", $outTree or die "Cannot create file: $outTree: $!\n";
165
+ print OUTTREE $tree;
166
+ close OUTTREE;
167
+
168
+ # Count reads
169
+ my %samples = ();
170
+ my %nodes = ();
171
+ print STDERR "o Counting reads.\n";
172
+ my $s = defined $o{s} ? $o{s} : "";
173
+ open INCLASS, "<", $inClass or die "Cannot read file: $inClass: $!\n";
174
+ while(<INCLASS>){
175
+ my @ln = split /\s+/;
176
+ $ln[0] =~ s/$s.+$//; # Sample name
177
+ ($samples{$ln[0]} ||= 0)++;
178
+ $tags{$ln[1]} ||= "[".$ln[1]."]"; # Node name
179
+ (($nodes{$tags{$ln[1]}} ||= {})->{$ln[0]} ||= 0)++;
180
+ }
181
+ close INCLASS;
182
+
183
+
184
+ my $labs = 'LABELS';
185
+ my $cols = 'COLORS';
186
+ my @samples = $o{m} ? (split /,/, $o{m}) : (keys %samples);
187
+ my @normfac = ();
188
+ for my $sample (@samples){
189
+ my $col = shift @{$o{c}};
190
+ unless(defined $col and length($col)==6){
191
+ $col = '';
192
+ for (1 .. 3){
193
+ my $v = int rand 16;
194
+ $v = chr $v+55 if $v>9;
195
+ $col.="$v$v";
196
+ }
197
+ }
198
+ my $nf = shift @{$o{N}};
199
+ $nf = 1 unless defined $nf and $nf>0;
200
+ $labs.= ','.($sample || 'unknown');
201
+ $cols.= ',#'.$col;
202
+ push @normfac, $nf+0;
203
+ }
204
+
205
+ open OUTCLASS, ">", $outClass or die "Cannot create file: $outClass: $!\n";
206
+ print OUTCLASS "$labs\n$cols\n";
207
+ my $tiny=0;
208
+ for my $node (keys %nodes){
209
+ my $i=0;
210
+ for my $s (@samples){
211
+ $nodes{$node}->{$s} = ($nodes{$node}->{$s} || 0)/($o{T} ? ($samples{$s}||1)/(max(values %samples)*100) : ($normfac[$i++]||1));
212
+ }
213
+ my $r = round(sum(values %{$nodes{$node}}));
214
+ print OUTCLASS "$node,R$r";
215
+ for my $sample (@samples){
216
+ print OUTCLASS ",".round($nodes{$node}->{$sample} || 0);
217
+ }
218
+ print OUTCLASS "\n";
219
+ $tiny++ unless $r;
220
+ }
221
+ close OUTCLASS;
222
+
223
+ unless($o{q}) {
224
+ print "Total counts per dataset:\n";
225
+ print " $_\t".($samples{$_}||0)."\n" for @samples;
226
+ }
227
+ warn "$tiny node assignments are too small to represent. Decrease the values of -N or use an alternative like -T." if $tiny;
228
+
@@ -0,0 +1,48 @@
1
+ #!/bin/bash
2
+
3
+ #
4
+ # @author Luis M. Rodriguez-R
5
+ # @update Oct-20-2015
6
+ # @license artistic license 2.0
7
+ #
8
+
9
+ FTP="ftp://ftp.ncbi.nlm.nih.gov/genomes/refseq/bacteria"
10
+ ORG=$1
11
+ EXT=${2:-.*.gz}
12
+ STT=${3:-Any}
13
+ DIR=${4:-$ORG}
14
+
15
+ if [[ "$ORG" == "" ]] ; then
16
+ echo "
17
+ Downloads a collection of sequences and/or annotations from NCBI's RefSeq.
18
+
19
+ Usage:
20
+ $0 <organism> [<extension>[ <level>[ <dir>]]]
21
+
22
+ <organism> The organism to download (e.g., Streptococcus_pneumoniae).
23
+ <extension> Extension to download. Common extensions include '.fna.gz'
24
+ (genomic sequences), '.faa.gz' (protein sequences), and
25
+ '.gff.gz' (annotations). By default: '.*.gz' (all data).
26
+ <level> Use only genomes with this assembly level. Common levels are
27
+ 'Complete Genome' and 'Contig'. By default, any assembly
28
+ level is allowed ('Any').
29
+ <dir> Directory where the files are to be downladed. By default,
30
+ same as <organism>.
31
+ " >&2
32
+ exit
33
+ fi
34
+
35
+ [[ -d "$DIR" ]] || mkdir "$DIR"
36
+
37
+ curl -s "$FTP/$ORG/assembly_summary.txt" -o "$DIR/assembly_summary.txt"
38
+ for path in $(cat "$DIR/assembly_summary.txt" \
39
+ | awk -F"\t" "\$12==\"$STT\" || \"$STT\"==\"Any\" {print \$20}" ) ; do
40
+ dir="$DIR/$(basename "$path")"
41
+ [[ -d "$dir" ]] || mkdir "$dir"
42
+ for file in $(curl -s "$path/" | awk '{print $9}') ; do
43
+ if [[ "$file" == *$EXT ]] ; then
44
+ curl -s "$path/$file" -o "$dir/$file"
45
+ fi
46
+ done
47
+ done
48
+
@@ -0,0 +1,50 @@
1
+ #!/bin/bash
2
+
3
+ #
4
+ # @author Luis M. Rodriguez-R
5
+ # @update Nov-27-2015
6
+ # @license artistic license 2.0
7
+ #
8
+
9
+ DATA_LINK="http://www.ebi.ac.uk/ena/data/warehouse/filereport"
10
+ DATA_OPS="result=read_run&fields=run_accession,fastq_ftp,fastq_md5"
11
+ SRX=$1
12
+ DIR=${1:-$SRX}
13
+
14
+ if [[ "$SRX" == "" ]] ; then
15
+ echo "
16
+ Downloads the set of runs from a project, sample, or experiment in SRA.
17
+
18
+ Usage:
19
+ $0 <SRA-ID>[ <dir>]
20
+
21
+ <SRA-ID> ID of the SRA Project, Sample, or Experiment.
22
+ <dir> Directory where the files are to be downladed. By default,
23
+ same as <SRA-ID>.
24
+ " >&2
25
+ exit
26
+ fi
27
+
28
+ [[ -d "$DIR" ]] || mkdir "$DIR"
29
+
30
+ curl -s "$DATA_LINK?$DATA_OPS&accession=$SRX" -o "$DIR/srr_list.txt"
31
+ tail -n +2 "$DIR/srr_list.txt" | while read ln ; do
32
+ srr=$(echo "$ln"|cut -f 1)
33
+ ftp=$(echo "$ln"|cut -f 2)
34
+ md5=$(echo "$ln"|cut -f 3)
35
+ dir="$DIR/$srr"
36
+ [[ -d "$dir" ]] || mkdir "$dir"
37
+ echo "o $srr" >&2
38
+ for uri in $(echo "$ftp" | tr ";" " ") ; do
39
+ file="$dir/$(basename $uri)"
40
+ curl "$uri" -o "$file"
41
+ md5obs=$(md5sum "$file" | awk '{print $1}')
42
+ if [[ "$md5" == "$md5obs"* ]] ; then
43
+ md5=$(echo "$md5" | perl -pe 's/^[^;]+;//')
44
+ else
45
+ echo "Corrupt file: $file" >&2
46
+ echo " MD5 mismatch: $md5obs not in $md5" >&2
47
+ exit 1;
48
+ fi
49
+ done
50
+ done
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env Rscript
2
+ #
3
+ # @author Luis M. Rodriguez-R
4
+ # @update Jan-05-2016
5
+ # @license artistic license 2.0
6
+ #
7
+
8
+ #= Load stuff
9
+ suppressPackageStartupMessages(library(enveomics.R))
10
+ args <- commandArgs(trailingOnly = F)
11
+ enveomics_R <- file.path(dirname(
12
+ sub("^--file=", "", args[grep("^--file=", args)])),
13
+ "lib", "enveomics.R")
14
+
15
+ #= Generate interface
16
+ opt <- enve.cliopts(plot.enve.TRIBStest,
17
+ file.path(enveomics_R, "man", "plot.enve.TRIBStest.Rd"),
18
+ positional_arguments=c(1,3),
19
+ usage="usage: %prog [options] output.pdf [width height]",
20
+ mandatory=c("x"),
21
+ vectorize=c("xlim","ylim"),
22
+ number=c("xlim","ylim"),
23
+ defaults=c(type="overlap", xlim=NA, ylim=NA))
24
+
25
+ #= Run it!
26
+ a <- new.env()
27
+ load(opt$options[['x']], a)
28
+ opt$options[['x']] <- get(ls(envir=a),envir=a)
29
+ summary(opt$options[['x']])
30
+ if(is.na(opt$options[['xlim']][1])) opt$options[['xlim']] <- NULL
31
+ if(is.na(opt$options[['ylim']][1])) opt$options[['ylim']] <- NULL
32
+ args = as.list(opt$args)
33
+ for(i in 2:3) if(length(args)>=i) args[[i]] <- as.numeric(args[[i]])
34
+ do.call("pdf", args)
35
+ do.call("plot.enve.TRIBStest", opt$options)
36
+ dev.off()
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env Rscript
2
+ #
3
+ # @author Luis M. Rodriguez-R
4
+ # @update Jan-05-2016
5
+ # @license artistic license 2.0
6
+ #
7
+
8
+ #= Load stuff
9
+ suppressPackageStartupMessages(library(enveomics.R))
10
+ args <- commandArgs(trailingOnly = F)
11
+ enveomics_R <- file.path(dirname(
12
+ sub("^--file=", "", args[grep("^--file=", args)])),
13
+ "lib", "enveomics.R")
14
+
15
+ #= Generate interface
16
+ opt <- suppressWarnings(enve.cliopts(enve.tribs,
17
+ file.path(enveomics_R, "man", "enve.tribs.Rd"),
18
+ positional_arguments=c(0,2),
19
+ usage="usage: %prog [options] [output.Rdata [bins=50]]",
20
+ mandatory=c("dist", "selection"),
21
+ defaults=c(dimensions=0, selection=NULL),
22
+ ignore=c("metaMDS.opts","points","pre.tribs","subsamples"),
23
+ o_desc=list(dist="A tab-delimited matrix of distances.",
24
+ selection="A list of names with the selection to evaluate."),
25
+ p_desc=paste("",
26
+ "Estimates the empirical difference between all the distances",
27
+ "in a set of objects and a subset, together with its statistical",
28
+ "significance.",sep="\n\t")))
29
+
30
+ #= Run it!
31
+ opt$options[['dist']] <- as.dist(read.table(opt$options[['dist']],
32
+ header=TRUE, sep="\t", row.names=1))
33
+ opt$options[['selection']] <- read.table(opt$options[['selection']],
34
+ header=FALSE, sep="\t", as.is=TRUE)[,1]
35
+ if(opt$options[['dimensions']]==0) opt$options[['dimensions']] <- NULL
36
+ if(length(opt$args)>1) opt$options[['bins']] <- as.numeric(opt$args[2])
37
+ t <- do.call("enve.tribs.test", opt$options)
38
+ summary(t)
39
+ if(length(opt$args)>0) save(t, file=opt$args[1])
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env Rscript
2
+ #
3
+ # @author Luis M. Rodriguez-R
4
+ # @update Dec-29-2015
5
+ # @license artistic license 2.0
6
+ #
7
+
8
+ #= Load stuff
9
+ args <- commandArgs(trailingOnly = F)
10
+ enveomics_R <- file.path(dirname(
11
+ sub("^--file=", "", args[grep("^--file=", args)])),
12
+ "lib", "enveomics.R")
13
+ source(file.path(enveomics_R, "R", "cliopts.R"))
14
+ source(file.path(enveomics_R, "R", "barplot.R"))
15
+
16
+ #= Generate interface
17
+ opt <- enve.cliopts(enve.barplot,
18
+ file.path(enveomics_R, "man", "enve.barplot.Rd"),
19
+ positional_arguments=c(1,3),
20
+ usage="usage: %prog [options] output.pdf [width height]",
21
+ mandatory=c("x"), vectorize=c("sizes","order","col"),
22
+ number=c("sizes","order"),
23
+ o_desc=list(x="A tab-delimited file containing header (first row) and row names (first column)."))
24
+
25
+ #= Run it!
26
+ args = as.list(opt$args)
27
+ for(i in 2:3) if(length(args)>=i) args[[i]] <- as.numeric(args[[i]])
28
+ do.call("pdf", args)
29
+ do.call("enve.barplot", opt$options)
30
+ dev.off()