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,104 @@
1
+ #!/usr/bin/env perl
2
+
3
+ #
4
+ # @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
5
+ # @update Mar-23-2015
6
+ # @license artistic license 2.0
7
+ #
8
+
9
+ use warnings;
10
+ use strict;
11
+ use Getopt::Std;
12
+
13
+
14
+ sub HELP_MESSAGE { die "
15
+ Usage:
16
+ $0 [options] genes.txt blast.txt ... > blast_metaxa.txt
17
+
18
+ genes.gff2 File containing the genes in any supported format
19
+ (see option -f).
20
+ blast.txt ... One or more tabular BLAST files.
21
+ blast_metaxa.txt Input file for MeTaxa.
22
+
23
+ Options:
24
+ -l <float> Minimum fraction of the gene aligned to consider a
25
+ hit. By default: 0.75. Ignored if -f 'no'.
26
+ -f <str> Format of the genes prediction. Any of:
27
+ o gff2: GFF v2 as produced by MetaGeneMark.hmm.
28
+ o gff3: GFF v3 with id field in the last column.
29
+ o tab: Tabular file with columns gene, gene length,
30
+ and contig.
31
+ o no: Ignores genes file.
32
+ By default: gff2.
33
+ -q Run quietly.
34
+ -h Display this message and exit.
35
+
36
+ ";}
37
+
38
+ my %o;
39
+ getopts('l:f:qh',\%o);
40
+ my($gff, @blasts) = @ARGV;
41
+ ($gff and $#blasts>=0) or &HELP_MESSAGE;
42
+ $o{h} and &HELP_MESSAGE;
43
+ $o{f} ||= "gff2";
44
+ $o{f} = lc $o{f};
45
+ $o{l} ||= 0.75;
46
+
47
+ my %gene;
48
+ if($o{f} ne 'no'){
49
+ print STDERR "Reading genes collection.\n" unless $o{q};
50
+ open GFF, "<", $gff or die "Cannot read file: $gff: $!\n";
51
+ while(<GFF>){
52
+ next if /^#/;
53
+ next if /^\s*$/;
54
+ chomp;
55
+ my @ln = split /\t/;
56
+ if($o{f} eq 'gff2'){
57
+ exists $ln[8] or die "Cannot parse line $.: $_\n";
58
+ my $id = $ln[8];
59
+ $id =~ s/gene_id /gene_id_/;
60
+ $ln[0] =~ s/ .*//;
61
+ $gene{$id} = [$ln[0], (1+$ln[4]-$ln[3])/3];
62
+ }elsif($o{f} eq 'gff3'){
63
+ exists $ln[8] or die "Cannot parse line $.: $_\n";
64
+ $ln[8] =~ /id=([^;]+)/ or die "Cannot parse line $.: $_\n";
65
+ my $id = $1;
66
+ $ln[0] =~ s/ .*//;
67
+ $gene{$id} = [$ln[0], (1+$ln[4]-$ln[3])/3];
68
+ }elsif($o{f} eq 'tab'){
69
+ exists $ln[2] or die "Cannot parse line $.: $_\n";
70
+ $ln[1]+0 or die "$ln[0]: Length zero.\n";
71
+ $gene{$ln[0]} = [$ln[2], $ln[1]/3];
72
+ }else{
73
+ die "Unsupported format: ".$o{f}.".\n";
74
+ }
75
+ }
76
+ close GFF;
77
+ }
78
+
79
+ my $i=0;
80
+ my $p=0;
81
+ print STDERR "Generating MeTaxa input.\n" unless $o{q};
82
+ for my $blast (@blasts){
83
+ print STDERR " o $blast\n" unless $o{q};
84
+ open BLAST, "<", $blast or die "Cannot read file: $blast: $!\n";
85
+ while(<BLAST>){
86
+ chomp;
87
+ my @l = split /\t/;
88
+ $i++;
89
+ my $ctg;
90
+ if($o{f} eq 'no'){
91
+ $ctg = $l[0];
92
+ }else{
93
+ exists $gene{$l[0]} or die "Cannot find contig for gene $l[0].\n";
94
+ next unless $l[3] >= $o{l}*$gene{$l[0]}->[1];
95
+ $ctg = $gene{$l[0]}->[0];
96
+ }
97
+ $l[1] =~ m/gi\|(\d+)\|/ or die "Cannot parse GI in $l[1].\n";
98
+ print "".join("\t", @l, $ctg, $l[0], $1)."\n";
99
+ $p++;
100
+ }
101
+ close BLAST;
102
+ }
103
+ print STDERR " Found $i results, reported $p.\n" unless $o{q};
104
+
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
5
+ # @update: Jul-29-2015
6
+ # @license artistic license 2.0
7
+ #
8
+
9
+ require 'optparse'
10
+
11
+ opts = {:minscore=>0, :besthits=>0, :orient=>0, :sisprefix=>"_"}
12
+ ARGV << '-h' if ARGV.size==0
13
+ OptionParser.new do |opt|
14
+ opt.separator "Identifies the best hits of paired-reads."
15
+ opt.separator ""
16
+ opt.on("-i", "--blast FILE", "Input BLAST file."){ |v| opts[:blast]=v }
17
+ opt.on("-s", "--minscore FLOAT", "Minimum (summed) Bit-Score to consider a pair-match."){ |v| opts[:minscore] = v.to_f }
18
+ opt.on("-b", "--besthits INT", "Outputs top best-hits only (use 0 to output all the paired hits)."){ |v| opts[:besthits]=v.to_i }
19
+ opt.on("-o", "--orient INT", "Checks the orientation of the hit. Values are: 0, no checking; 1, same direction; 2,",
20
+ "inwards; 3, outwards; 4, different direction (i.e., 2 or 3)."){ |v| opts[:orient]=v.to_i }
21
+ opt.on("-p", "--sisprefix STR", "Sister read number prefix in the name of the reads. Escape characters as dots (\\.),",
22
+ "parenthesis (\\(, \\), \\[, \\]), or other characters with special meaning in regular expressions",
23
+ "(\\*, \\+, \\^, \\$, \\|). This prefix allows regular expressions (for example, use ':|\\.' to use any of",
24
+ "colon or dot). Notice that the prefix will not be included in the base name reported in the output."){ |v| opts[:sisprefix]=v }
25
+ opt.on("-h","--help","Display this screen") do
26
+ puts opt
27
+ exit
28
+ end
29
+ opt.separator ""
30
+ opt.separator "Output:"
31
+ opt.separator " Tab-delimited flat file, with the following columns:"
32
+ opt.separator " 1. Query ID (without the \"sister\" identifier)."
33
+ opt.separator " 2. Subject ID."
34
+ opt.separator " 3. Bit score (summed from both sister reads)."
35
+ opt.separator " 4/5. From/To (subject) coordinates for read 1."
36
+ opt.separator " 6/7. From/To (subject) coordinates for read 2."
37
+ opt.separator " 8. Reads orientation (1: same direction, 2: inwards, 3: outwards)."
38
+ opt.separator " 9. Estimated insert size."
39
+ opt.separator ""
40
+ opt.separator "Important note: This script assumes that paired hits are next to each other."
41
+ opt.separator " If this is not the case (e.g., because the blast was concatenated),"
42
+ opt.separator " you must sort the input before running this script."
43
+ opt.separator ""
44
+ end.parse!
45
+ abort "-i/--blast is mandatory." if opts[:blast].nil?
46
+ abort "-i/--blast must exist." unless File.exists? opts[:blast]
47
+
48
+ class SingleHit
49
+ attr_reader :sbj, :score, :orient, :sfrom, :sto, :qfrom, :qto
50
+ def initialize(blast_ln)
51
+ blast_ln.chomp!
52
+ ln = blast_ln.split("\t")
53
+ @sbj = ln[1]
54
+ @score = ln[11].to_f
55
+ @qfrom = ln[6].to_i
56
+ @qto = ln[7].to_i
57
+ @sfrom = ln[8].to_i
58
+ @sto = ln[9].to_i
59
+ @orient = @sfrom < @sto ? 1 : -1;
60
+ end
61
+ end
62
+ class DoubleHit
63
+ attr_reader :name, :sbj, :score, :orient, :hitA, :hitB
64
+ def initialize(name, hitA, hitB)
65
+ raise "Trying to set DoubleHit from hits with different subjects" unless hitA.sbj == hitB.sbj
66
+ @name = name
67
+ @hitA = hitA
68
+ @hitB = hitB
69
+ @sbj = hitA.sbj
70
+ @score = hitA.score + hitB.score
71
+ @orient = (hitA.orient == hitB.orient ? 1:
72
+ ((hitA.orient>0 and hitB.orient<0) ? 2: 3))
73
+ end
74
+ def to_s
75
+ coords = [@hitA.sfrom, @hitB.sfrom, @hitA.sto, @hitB.sto]
76
+ @name + "\t" + @sbj + "\t" + @score.to_s + "\t" +
77
+ @hitA.sfrom.to_s + "\t" + @hitA.sto.to_s + "\t" +
78
+ @hitB.sfrom.to_s + "\t" + @hitB.sto.to_s + "\t" +
79
+ @orient.to_s + "\t" + (coords.max-coords.min).to_s + "\n"
80
+ end
81
+ end
82
+ class PairedHits
83
+ attr_reader :name, :hitsA, :hitsB
84
+ @@minscore = 0
85
+ @@orient = 0
86
+ @@besthits = 0
87
+ def initialize(name)
88
+ @name = name
89
+ @hitsA = []
90
+ @hitsB = []
91
+ @hits = []
92
+ end
93
+ def hits
94
+ @hits = []
95
+ # Search for paired hits
96
+ @hitsA.each do |hitA|
97
+ @hitsB.each do |hitB|
98
+ if hitA.sbj == hitB.sbj
99
+ hit = DoubleHit.new(@name, hitA, hitB)
100
+ next if hit.score <= @@minscore # Minimum bit-score check
101
+ next if ((1 .. 3).include?(@@orient) and @@orient != hit.orient) # "typical" orientation check
102
+ next if (@@orient == 4 and not((2 .. 3).include?(hit.orient))) # "different-orientation" check
103
+ @hits.push(hit)
104
+ end
105
+ end
106
+ end
107
+ # Sort the hits
108
+ @hits.sort! {|x,y| x.score <=> y.score }
109
+ if @@besthits==0
110
+ @hits
111
+ else
112
+ @hits.take(@@besthits)
113
+ end
114
+ end
115
+ def hitsX(x)
116
+ if x == 1
117
+ @hitsA
118
+ else
119
+ @hitsB
120
+ end
121
+ end
122
+ # Class methods
123
+ def PairedHits.minscore=(value)
124
+ @@minscore = value
125
+ end
126
+ def PairedHits.orient=(value)
127
+ @@orient = value
128
+ end
129
+ def PairedHits.besthits=(value)
130
+ @@besthits = value
131
+ end
132
+ end
133
+
134
+ PairedHits.minscore = opts[:minscore]
135
+ PairedHits.orient = opts[:orient]
136
+ PairedHits.besthits = opts[:besthits]
137
+
138
+ begin
139
+ f = File.open(opts[:blast], "r")
140
+ currPair = PairedHits.new(" ")
141
+ while(ln = f.gets)
142
+ m = /^([^\s]*)(?:#{opts[:sisprefix]})([12])/.match(ln)
143
+ raise "Impossible to parse read name in line #{$.} using sister prefix '#{opts[:sisprefix]}':\n#{ln}" unless m
144
+ if m[1] != currPair.name
145
+ currPair.hits.each { |hit| puts hit.to_s }
146
+ currPair = PairedHits.new(m[1])
147
+ end
148
+ currPair.hitsX(m[2].to_i).push(SingleHit.new(ln));
149
+ end
150
+ currPair.hits.each { |hit| puts hit.to_s }
151
+ f.close
152
+ rescue => err
153
+ $stderr.puts "Exception: #{err}\n\n"
154
+ err.backtrace.each { |l| $stderr.puts l + "\n" }
155
+ err
156
+ end
157
+
@@ -0,0 +1,40 @@
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(enve.recplot2,
17
+ file.path(enveomics_R, "man", "enve.recplot2.Rd"),
18
+ positional_arguments=c(1,4),
19
+ usage="usage: %prog [options] output.Rdata [output.pdf [width height]]",
20
+ mandatory=c("prefix"),
21
+ o_desc=list(pos.breaks="Breaks in the positions histogram.",
22
+ id.breaks="Breaks in the identity histogram.",
23
+ id.summary="Function summarizing the identity bins. By default: sum."),
24
+ p_desc=paste("","Produce recruitment plot objects provided that",
25
+ "BlastTab.catsbj.pl has been previously executed.", sep="\n\t"),
26
+ ignore=c("plot"),
27
+
28
+ defaults=c(id.metric="identity"))
29
+
30
+ #= Run it!
31
+ if(length(opt$args)>1){
32
+ args = as.list(opt$args[-1])
33
+ for(i in 2:3) if(length(args)>=i) args[[i]] <- as.numeric(args[[i]])
34
+ do.call("pdf", args)
35
+ }else{
36
+ opt$options[["plot"]] <- FALSE
37
+ }
38
+ rp <- do.call("enve.recplot2", opt$options)
39
+ save(rp, file=opt$args[1])
40
+ if(length(opt$args)>1) dev.off()
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env perl
2
+ #
3
+ # @author: Luis M Rodriguez-R <lmrodriguezr at gmail dot com>
4
+ # @license: artistic license 2.0
5
+ # @update: Mar-23-2015
6
+ #
7
+
8
+ use strict;
9
+ use warnings;
10
+ use List::Util qw/min max sum/;
11
+
12
+ my $fna = shift @ARGV;
13
+ $fna or die "
14
+ Usage:
15
+ cat blast1... | $0 genes_or_ctgs.fna > genes_or_ctgs.cov
16
+
17
+ blast1... One or more Tabular BLAST files of reads vs genes (or contigs).
18
+ genes_or_ctgs.fna A FastA file containing the genes or the contigs (db).
19
+ genes_or_ctgs.cov The output file.
20
+
21
+ Output:
22
+ A tab-delimited file with the following columns:
23
+ 1. Subject ID
24
+ 2. Average sequencing depth
25
+ 3. Median sequencing depth
26
+ 4. Number of mapped reads
27
+ 5. Length of the subject sequence
28
+
29
+ ";
30
+
31
+ my $size = {};
32
+ my $gene = {};
33
+ my $reads = {};
34
+
35
+ SIZE:{
36
+ local $/=">";
37
+ print STDERR "== Reading fasta\n";
38
+ open FNA, "<", $fna or die "Cannot read the file: $fna: $!\n";
39
+ my $i=0;
40
+ while(<FNA>){
41
+ chomp;
42
+ my @g = split /\n/, $_, 2;
43
+ next unless $g[1];
44
+ #$g[1] =~ s/[^A-Za-z]//g;
45
+ #$size->{$g[0]} = length $g[1];
46
+ $g[0] =~ s/\s.*//;
47
+ $size->{$g[0]} = ( $g[1] =~ tr/[A-Za-z]// );
48
+ print STDERR " Measuring sequence ".($i).": $g[0] \r" unless ++$i%500;
49
+ }
50
+ close FNA;
51
+ print STDERR " Found $i sequences".(" "x30)."\n";
52
+ }
53
+
54
+ MAP:{
55
+ print STDERR "== Reading mapping\n";
56
+ my $i=0;
57
+ while(<>){
58
+ my @ln = split /\t/;
59
+ $gene->{$ln[1]} ||= [];
60
+ for my $pos (min($ln[8], $ln[9]) .. max($ln[8], $ln[9])){ ($gene->{$ln[1]}->[$pos]||=0)++ }
61
+ ($reads->{$ln[1]} ||= 0)++;
62
+ print STDERR " Saving hit ".($i).": $ln[1] \r" unless ++$i%5000;
63
+ }
64
+ print STDERR " Found $i hits".(" "x30)."\n";
65
+ }
66
+
67
+ OUT:{
68
+ print STDERR "== Creating output\n";
69
+ my $i=0;
70
+ for my $g (keys %$gene){
71
+ $gene->{$g}->[$_] ||= 0 for (0 .. $size->{$g});
72
+ my @sorted = sort {$a <=> $b} @{$gene->{$g}};
73
+ die "Cannot find gene in $fna: $g.\n" unless exists $size->{$g};
74
+ printf "%s\t%.6f\t%d\t%d\t%d\n", $g,
75
+ sum(@{$gene->{$g}})/$size->{$g},
76
+ $sorted[$#sorted/2],
77
+ $reads->{$g},
78
+ $size->{$g};
79
+ delete $gene->{$g};
80
+ print STDERR " Saving sequence $g:".($i)."\r" unless ++$i%500;
81
+ }
82
+ print STDERR " Saved $i sequences".(" "x30)."\n";
83
+ }
84
+
85
+ print STDERR " done.\n";
86
+
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env perl
2
+ #
3
+ # @author: Luis M Rodriguez-R <lmrodriguezr at gmail dot com>
4
+ # @license: artistic license 2.0
5
+ # @update: Mar-23-2015
6
+ #
7
+
8
+ use strict;
9
+ use warnings;
10
+ use List::Util qw/min max sum/;
11
+
12
+ my $fna = shift @ARGV;
13
+ $fna or die "
14
+ Description:
15
+ Estimates the average sequencing depth of subject sequences (genes or contigs)
16
+ assuming a Zero-Inflated Poisson distribution (ZIP) to correct for non-covered
17
+ positions. It uses the corrected method of moments estimators (CMMEs) as described
18
+ by Beckett et al [1]. Note that [1] has a mistake in eq. (2.4), that should be:
19
+ pi-hat-MM = 1 - (X-bar / lambda-hat-MM)
20
+
21
+ Also note that a more elaborated mixture distribution can arise from coverage
22
+ histograms (e.g., see [2] for an additional correction called 'tail distribution'
23
+ and mixtures involving negative binomial) so take these results cum grano salis.
24
+
25
+ Usage:
26
+ cat blast1... | $0 genes_or_ctgs.fna > genes_or_ctgs.cov
27
+
28
+ blast1... One or more Tabular BLAST files of reads vs genes (or contigs).
29
+ genes_or_ctgs.fna A FastA file containing the genes or the contigs (db).
30
+ genes_or_ctgs.cov The output file.
31
+
32
+ Output:
33
+ A tab-delimited file with the following columns (the one you want is #2):
34
+ 1. Subject ID
35
+ 2. Estimated average sequencing depth (CMME lambda)
36
+ 3. Zero-inflation (CMME pi)
37
+ 4. Observed average sequencing depth
38
+ 5. Observed median sequencing depth
39
+ 6. Observed median sequencing depth excluding zeroes
40
+ 7. Number of mapped reads
41
+ 8. Length of the subject sequence
42
+
43
+ References:
44
+ [1] http://anisette.ucs.louisiana.edu/Academic/Sciences/MATH/stage/stat2012.pdf
45
+ [2] Lindner et al, Bioinformatics, 2013.
46
+
47
+ ";
48
+
49
+ my $size = {};
50
+ my $gene = {};
51
+ my $reads = {};
52
+
53
+ SIZE:{
54
+ local $/=">";
55
+ print STDERR "== Reading fasta\n";
56
+ open FNA, "<", $fna or die "Cannot read the file: $fna: $!\n";
57
+ my $i=0;
58
+ while(<FNA>){
59
+ chomp;
60
+ my @g = split /\n/, $_, 2;
61
+ next unless $g[1];
62
+ #$g[1] =~ s/[^A-Za-z]//g;
63
+ #$size->{$g[0]} = length $g[1];
64
+ $g[0] =~ s/\s.*//;
65
+ $size->{$g[0]} = ( $g[1] =~ tr/[A-Za-z]// );
66
+ print STDERR " Measuring sequence ".($i).": $g[0] \r" unless ++$i%500;
67
+ }
68
+ close FNA;
69
+ print STDERR " Found $i sequences".(" "x30)."\n";
70
+ }
71
+
72
+ MAP:{
73
+ print STDERR "== Reading mapping\n";
74
+ my $i=0;
75
+ while(<>){
76
+ my @ln = split /\t/;
77
+ $gene->{$ln[1]} ||= [];
78
+ for my $pos (min($ln[8], $ln[9]) .. max($ln[8], $ln[9])){ ($gene->{$ln[1]}->[$pos]||=0)++ }
79
+ ($reads->{$ln[1]} ||= 0)++;
80
+ print STDERR " Saving hit ".($i).": $ln[1] \r" unless ++$i%5000;
81
+ }
82
+ print STDERR " Found $i hits".(" "x30)."\n";
83
+ }
84
+
85
+ OUT:{
86
+ print STDERR "== Creating output\n";
87
+ my $i=0;
88
+ for my $g (keys %$gene){
89
+ unless(exists $size->{$g}){
90
+ warn "Warning: Cannot find gene in $fna: $g.\n";
91
+ next;
92
+ }
93
+ $gene->{$g}->[$_] ||= 0 for (0 .. $size->{$g});
94
+ die "Hits out-of-boundaries in gene $g: $#{$gene->{$g}} != $size->{$g}.\n" if $#{$gene->{$g}} != $size->{$g};
95
+ my @sorted = sort {$a <=> $b} @{$gene->{$g}};
96
+ my @sorted_nz = grep { $_>0 } @sorted;
97
+ my $xbar = sum(@{$gene->{$g}})/$size->{$g};
98
+ my $xsqbar = sum(map { ($_ - $xbar)**2 } @{$gene->{$g}})/($size->{$g}-1);
99
+ my $var = $xsqbar - $xbar**2;
100
+ my $lambdaMM = $xbar + ($var/$xbar) - 1;
101
+ my $piMM = $lambdaMM==0 ? 0 : 1 - $xbar/$lambdaMM;
102
+ printf "%s\t%.6f\t%.6f\t%.6f\t%d\t%d\t%d\t%d\n", $g,
103
+ ($xbar >= $var ? $xbar : $lambdaMM),
104
+ ($xbar >= $var ? 0 : $piMM),
105
+ #$lambdaMM,
106
+ #$piMM,
107
+ sum(@{$gene->{$g}})/$size->{$g},
108
+ $sorted[$#sorted/2],
109
+ $sorted_nz[$#sorted_nz/2],
110
+ $reads->{$g},
111
+ $size->{$g};
112
+ delete $gene->{$g};
113
+ print STDERR " Saving sequence $g:".($i)." \r" unless ++$i%500;
114
+ }
115
+ print STDERR " Saved $i sequences".(" "x30)." \n";
116
+ }
117
+
118
+ print STDERR " done.\n";
119
+