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,60 @@
1
+ #!/usr/bin/env perl
2
+ #
3
+ # @author Luis M. Rodriguez-R
4
+ # @update Oct-07-2015
5
+ # @license artistic license 2.0
6
+ #
7
+
8
+ use warnings;
9
+ use strict;
10
+
11
+ my($file, $content, $stretch) = @ARGV;
12
+ $file or die <<HELP
13
+
14
+ Description:
15
+ Filter sequences by N-content and presence of long homopolymers.
16
+ Usage:
17
+ $0 sequences.fa [content [stretch]] > filtered.fa
18
+ Where:
19
+ sequences.fa Input file in FastA format
20
+ content A number between 0 and 1 indicating the maximum proportion of Ns
21
+ (1 to turn off, 0.5 by default)
22
+ stretch A number indicating the maximum number of consecutive identical
23
+ nucleotides allowed (0 to turn off, 100 by default)
24
+ filtered.fa Filtered set of sequences.
25
+
26
+ HELP
27
+ ;
28
+ ($content ||= 0.5)+=0;
29
+ ($stretch ||= 100)+=0;
30
+
31
+ my $good = 0;
32
+ my $N = 0;
33
+
34
+ FASTA: {
35
+ local $/ = "\n>";
36
+ open FILE, "<", $file or die "I can not open the file: $file: $!\n";
37
+ SEQ: while(<FILE>){
38
+ $N++;
39
+ s/^;.*//gm;
40
+ s/>//g;
41
+ my($n,$s) = split /\n/, $_, 2;
42
+ (my $clean = $s) =~ s/[^ACTGN]//g;
43
+ if($content < 1){
44
+ (my $Ns = $clean) =~ s/[^N]//g;
45
+ next SEQ if length($Ns)>length($clean)*$content;
46
+ }
47
+ if($stretch > 0){
48
+ for my $nuc (qw(A C T G N)){
49
+ next SEQ if $clean =~ m/[$nuc]{$stretch}/;
50
+ }
51
+ }
52
+ print ">$n\n$s\n";
53
+ $good++;
54
+ }
55
+ close FILE;
56
+ print STDERR "Total sequences: $N\nAfter filtering: $good\n";
57
+ }
58
+
59
+
60
+
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # @author Luis M. Rodriguez-R
4
+ # @license artistic license 2.0
5
+
6
+ $:.push File.expand_path("../lib", __FILE__)
7
+ require "enveomics_rb/enveomics"
8
+ require "enveomics_rb/stat"
9
+
10
+ o = {q:false, completeness:nil, minlen:500, shuffle:true}
11
+ OptionParser.new do |opts|
12
+ opts.banner = "
13
+ Simulates incomplete (fragmented) drafts from complete genomes.
14
+
15
+ Usage: #{$0} [options]"
16
+ opts.separator ""
17
+ opts.separator "Mandatory"
18
+ opts.on("-i", "--in FILE",
19
+ "Path to the FastA file containing the complete sequences."
20
+ ){ |v| o[:in] = v }
21
+ opts.on("-o", "--out FILE", "Path to the FastA to create."){ |v| o[:out] = v }
22
+ opts.on("-c", "--completeness FLOAT",
23
+ "Fraction of genome completeness to simulate from 0 to 1."
24
+ ){ |v| o[:completeness] = v.to_f }
25
+ opts.separator ""
26
+ opts.separator "Options"
27
+ opts.on("-m", "--minlen INT",
28
+ "Minimum fragment length to report. By default: #{o[:minlen]}."
29
+ ){ |v| o[:minlen] = v.to_i }
30
+ opts.on("-s", "--sorted", "Keep fragments sorted as in the input file. ",
31
+ "By default, fragments are shuffled."){ |v| o[:shuffle] = !v }
32
+ opts.on("-q", "--quiet", "Run quietly (no STDERR output)"){ o[:q] = true }
33
+ opts.on("-h", "--help", "Display this screen") do
34
+ puts opts
35
+ exit
36
+ end
37
+ opts.separator ""
38
+ end.parse!
39
+ abort "-i is mandatory" if o[:in].nil?
40
+ abort "-o is mandatory" if o[:out].nil?
41
+ abort "-c is mandatory" if o[:completeness].nil?
42
+
43
+ begin
44
+ # Read input sequences
45
+ g_id = []
46
+ g_seq = []
47
+ File.open(o[:in], "r") do |ifh|
48
+ id = ""
49
+ ifh.each_line do |ln|
50
+ if ln =~ /^>(\S*)/
51
+ g_id << $1
52
+ g_seq << ""
53
+ else
54
+ g_seq[g_seq.size-1] += ln.gsub(/[^A-Za-z]/,"")
55
+ end
56
+ end
57
+ end
58
+
59
+ # Fragment genomes
60
+ f = {}
61
+ binlen = [1, (o[:minlen].to_f/(1.5**2)).ceil].max
62
+ p = [0.001, [1.0, 1.0 - (o[:completeness]/1.25 + 0.1)].min].max
63
+ while not g_seq.empty?
64
+ id = g_id.shift
65
+ seq = g_seq.shift
66
+ gL = seq.length
67
+ while not seq.empty?
68
+ fL = [0, ((Enve::Stat.r_geom(p).to_f +
69
+ Enve::Stat.r_unif(-0.5,0.5))*binlen).round].max
70
+ f["#{f.size+1}_#{id}"] = seq[0,fL] if fL >= o[:minlen]
71
+ seq = seq[(fL+1) .. -1]
72
+ seq = "" if seq.nil?
73
+ end
74
+ end
75
+
76
+ # Save output
77
+ k = f.keys
78
+ k.shuffle! if o[:shuffle]
79
+ File.open(o[:out], "w") do |ofh|
80
+ k.each do |id|
81
+ ofh.puts ">#{id}"
82
+ ofh.puts f[id].gsub(/(\S{50})/, "\\1\n")
83
+ end
84
+ end
85
+
86
+ rescue => err
87
+ $stderr.puts "Exception: #{err}\n\n"
88
+ err.backtrace.each { |l| $stderr.puts l + "\n" }
89
+ err
90
+ end
91
+
92
+
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env perl
2
+ #
3
+ # @author Luis M Rodriguez-R
4
+ # @update Mar-23-2016
5
+ # @license artistic license 2.0
6
+ #
7
+
8
+ use warnings;
9
+ use strict;
10
+
11
+ $#ARGV>=0 or die "
12
+ Usage:
13
+ $0 seqs.fa... > gc.txt
14
+
15
+ seqs.fa One or more FastA files.
16
+ gc.txt A table with the G+C content of the sequences.
17
+
18
+ ";
19
+
20
+ for my $fa (@ARGV){
21
+ open FA, "<", $fa or die "Cannot open file: $fa: $!\n";
22
+ my $def = "";
23
+ my $len = 0;
24
+ my $gc = 0;
25
+ while(<FA>){
26
+ next if /^;/;
27
+ if(m/^>(\S*)/){
28
+ print "$def\t".($gc/$len)."\n" if $len;
29
+ $def = $1;
30
+ $len = 0;
31
+ $gc = 0;
32
+ }else{
33
+ s/[^ACTGactg]//g;
34
+ $len += length $_;
35
+ s/[^GC]//g;
36
+ $gc += length $_;
37
+ }
38
+ }
39
+ print "$def\t".($gc/$len)."\n" if $len;
40
+ close FA;
41
+ }
42
+
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env perl
2
+
3
+ # Interpose sequences in FastA format from two files into one output file. If more than two files are
4
+ # provided, the script will interpose all the input files.
5
+ # Please note that this script will check for the consistency of the names (assuming a pair of related reads
6
+ # contains the same name varying only in a trailing slash (/) followed by a digit. If you want to turn this
7
+ # feature off just set the $eval_T variable to zero. If you want to decrease the sampling period (to speed
8
+ # the script up) or increase it (to make it more sensitive to errors) just change $eval_T accordingly.
9
+ #
10
+ # @author Luis M. Rodriguez-R
11
+ # @version 1.0
12
+ # @created Nov-27-2012
13
+ # @update Mar-23-2015
14
+ # @license artistic license 2.0
15
+ #
16
+ # Usage: FastQ.interpose.pl <output_fastq> <input_fastq_1> <input_fastq_2> [additional input files...]
17
+
18
+ use strict;
19
+ use warnings;
20
+ use Symbol;
21
+
22
+ my $HELP = <<HELP
23
+ Usage:
24
+ $0 <output_fasta> <input_fasta_1> <input_fasta_2> [additional input files...]
25
+
26
+ Where,
27
+ output_fasta : Output file
28
+ input_fasta_1 : First FastA file
29
+ input_fasta_2 : Second FastA file
30
+ ... : Any additional FastA files (or none)
31
+
32
+ HELP
33
+ ;
34
+ my $eval_T = 1000; # Period (in number of entries) of evaluation for consistency of the names.
35
+ # To turn off evaluation set to 0 (zero).
36
+ my $out = shift @ARGV;
37
+ my @in = @ARGV;
38
+ $/ = "\n>";
39
+
40
+
41
+ die $HELP unless $out and $#in >= 1;
42
+ open OUT, ">", $out or die "Unable to write on $out: $!\n";
43
+ print "Output file: $out\n";
44
+
45
+ my @in_fh = ();
46
+
47
+ for my $k (0 .. $#in) {
48
+ $in_fh[$k] = gensym;
49
+ open $in_fh[$k], "<", $in[$k] or die "Unable to read $in[$k]: $!\n";
50
+ print "Input file: $in[$k]\n";
51
+ }
52
+
53
+ my $i = 0;
54
+ my $frl;
55
+ LINE: while(1){
56
+ my $name = "";
57
+ print STDERR "\rEntry: $i " unless $i % 1000;
58
+ FILE: for my $k (0 .. $#in_fh){
59
+ my $ln = readline($in_fh[$k]);
60
+ last LINE if $k==0 and not defined $ln;
61
+ defined $ln or die "Impossible to read next entry ($.) from $in[$k]: $!\n";
62
+ $ln =~ s/^\>?/>/;
63
+ $ln =~ s/\>$//;
64
+ $ln =~ s/^;.*//gm;
65
+ if($eval_T and not $i % $eval_T){
66
+ unless($name){
67
+ $ln =~ m/^>(.*?)[\/ \\_]\d+/ or die "Impossible to evaluate names!\n offending entry:\n$ln\n";
68
+ $name = $1;
69
+ }
70
+ die "Inconsistent name!\n base name is $name\n offending entry is:\n$ln\n" unless $ln =~ /^>$name/;
71
+ }
72
+ unless($frl){
73
+ $ln =~ m/^>.*?\n(.*?)\n/ or die "Unexpected format!\n offending entry:\n$ln\n";
74
+ my $i = $ln;
75
+ $i =~ s/^>.*?\n//;
76
+ $i =~ s/\n//g;
77
+ $frl = length $i;
78
+ }
79
+ print OUT $ln;
80
+ }
81
+ $i++;
82
+ }
83
+ print "\rNumber of entries: $i \nFirst read length: $frl\n";
84
+ close OUT;
85
+
86
+ for my $k(0..$#in_fh){print "ALERT: The file $in[$k] contains trailing entries\n" if defined readline($in_fh[$k])}
87
+
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env perl
2
+ #
3
+ # @author Luis M Rodriguez-R
4
+ # @update Oct-07-2015
5
+ # @license artistic license 2.0
6
+ #
7
+
8
+ use warnings;
9
+ use strict;
10
+
11
+ $#ARGV>=0 or die "
12
+ Usage:
13
+ $0 seqs.fa... > length.txt
14
+
15
+ seqs.fa One or more FastA files.
16
+ length.txt A table with the lengths of the sequences.
17
+
18
+ ";
19
+
20
+ for my $fa (@ARGV){
21
+ open FA, "<", $fa or die "Cannot open file: $fa: $!\n";
22
+ my $def = '';
23
+ my $len = 0;
24
+ while(<FA>){
25
+ next if /^;/;
26
+ if(m/^>(\S+)\s?/){
27
+ print "$def\t$len\n" if $def;
28
+ $def = $1;
29
+ $len = 0;
30
+ }else{
31
+ s/[^A-Za-z]//g;
32
+ $len+= length $_;
33
+ }
34
+ }
35
+ print "$def\t$len\n" if $def;
36
+ close FA;
37
+ }
38
+
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env perl
2
+ #
3
+ # @author Luis M Rodriguez-R
4
+ # @update Mar-17-2016
5
+ # @license artistic license 2.0
6
+ #
7
+
8
+ use warnings;
9
+ use strict;
10
+
11
+ $#ARGV>=1 or die "
12
+ Usage:
13
+ $0 outdir seqs.fa...
14
+
15
+ outdir Output directory for the individual files.
16
+ seqs.fa One or more FastA files.
17
+
18
+ ";
19
+
20
+ my $dir = shift @ARGV;
21
+
22
+ for my $fa (@ARGV){
23
+ open FA, "<", $fa or die "Cannot open file: $fa: $!\n";
24
+ my $file = '';
25
+ while(<FA>){
26
+ next if /^;/;
27
+ if(m/^>(\S+)\s?/){
28
+ close ONE if $file;
29
+ $file = $dir."/".$1.".fasta";
30
+ open ONE, ">", $file or die "Cannot open file: $file: $!\n";
31
+ }
32
+ print ONE $_ if $file;
33
+ }
34
+ close ONE if $file;
35
+ }
36
+
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env perl
2
+ #
3
+ # @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
4
+ # @update Dec-22-2015
5
+ # @license artistic license 2.0
6
+ #
7
+ use strict;
8
+ use warnings;
9
+ use List::Util qw/sum min max/;
10
+
11
+ my ($seqs, $minlen) = @ARGV;
12
+ $seqs or die "
13
+ Description:
14
+ Calculates the quartiles of the length in a set of sequences. The Q2 is
15
+ also known as the median. Q0 is the minimum length, and Q4 is the maximum
16
+ length. It also calculates TOTAL, the added length of the sequences in
17
+ the file, and AVG, the average length.
18
+
19
+ Usage:
20
+ $0 seqs.fa[ minlen]
21
+
22
+ seqs.fa A FastA file containing the sequences.
23
+ minlen (optional) The minimum length to take into consideration.
24
+ By default: 0.
25
+
26
+ ";
27
+ $minlen ||= 0;
28
+
29
+ # Read files
30
+ my @len = ();
31
+ open FA, "<", $seqs or die "Cannot open file: $seqs: $!\n";
32
+ my $def = '';
33
+ my $len = 0;
34
+ while(<FA>){
35
+ next if /^;/;
36
+ if(m/^>(\S+)\s?/){
37
+ push(@len, int($len)) if $def and not $len<$minlen;
38
+ $def = $1;
39
+ $len = 0;
40
+ }else{
41
+ s/[^A-Za-z]//g;
42
+ $len+= length $_;
43
+ }
44
+ }
45
+ push(@len, int($len)) if $def and not $len<$minlen;
46
+ close FA;
47
+
48
+ # Sort and estimates quantiles
49
+ @len = sort { $a <=> $b } @len;
50
+ for my $q (0 .. 4){
51
+ my $ii = int(my $i = $#len*$q/4);
52
+ print "Q$q: ".($i==$ii ? $len[$i] : ($len[$ii]+$len[$ii+1])/2 )."\n";
53
+ }
54
+ my $sum = sum @len;
55
+ print "N: ".scalar(@len)."\n";
56
+ print "TOTAL: $sum\n";
57
+ print "AVG: ".($sum/scalar(@len))."\n";
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env perl
2
+ #
3
+ # @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
4
+ # @update Oct-07-2015
5
+ # @license artistic license 2.0
6
+ #
7
+
8
+ use warnings;
9
+ use strict;
10
+ use Getopt::Std;
11
+
12
+ sub HELP_MESSAGE { die "
13
+ .Description:
14
+ Renames a set of sequences in FastA format.
15
+
16
+ .Usage: $0 [options] list.txt seqs.fa > renamed.fa
17
+
18
+ [options]
19
+ -f Filter list. Ignores sequences NOT present in the list.
20
+ -q Runs quietly.
21
+ -h Prints this message and exits.
22
+
23
+ [mandatory]
24
+ list.txt Tab-delimited list of sequences, with the original ID in the
25
+ first column and the ID to use in the second.
26
+ seqs.fa FastA file containing the superset of sequences.
27
+ renamed.fa FastA file to be created.
28
+
29
+ " }
30
+
31
+ my %o=();
32
+ getopts('fhq', \%o);
33
+ my($list, $fa) = @ARGV;
34
+ ($list and $fa) or &HELP_MESSAGE;
35
+ $o{h} and &HELP_MESSAGE;
36
+
37
+ print STDERR "Reading list.\n" unless $o{q};
38
+ open LI, "<", $list or die "Cannot read file: $list: $!\n";
39
+ my %li = map { my $l=$_; chomp $l; my @r=split(/\t/,$l); $r[0] => $r[1] } <LI>;
40
+ close LI;
41
+
42
+ print STDERR "Renaming FastA.\n" unless $o{q};
43
+ open FA, "<", $fa or die "Cannot read file: $fa: $!\n";
44
+ my $good = 0;
45
+ while(my $ln = <FA>){
46
+ next if $ln =~ /^;/;
47
+ chomp $ln;
48
+ if($ln =~ m/^>((\S+).*)/){
49
+ my $rep=0;
50
+ $rep = ">".$li{$ln} if exists $li{$ln};
51
+ $rep = ">".$li{$1} if exists $li{$1} and not $rep;
52
+ $rep = ">".$li{">$1"} if exists $li{">$1"} and not $rep;
53
+ $rep = ">".$li{$2} if exists $li{$2} and not $rep;
54
+ if($rep){
55
+ $ln = $rep;
56
+ $good = 1;
57
+ }
58
+ }elsif($ln =~ m/^>/){
59
+ $good=0;
60
+ print STDERR "Warning: Non-cannonical defline, line $.: $ln\n";
61
+ }
62
+ print "$ln\n" if $good or not $o{f};
63
+ }
64
+ close FA;
65
+