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.
- checksums.yaml +4 -4
- data/README.md +21 -4
- data/actions/init.rb +258 -0
- data/actions/run_local.rb +1 -2
- data/actions/test_taxonomy.rb +4 -1
- data/bin/miga +8 -1
- data/lib/miga/dataset.rb +4 -4
- data/lib/miga/dataset_result.rb +7 -4
- data/lib/miga/version.rb +2 -2
- data/scripts/_distances_noref_nomulti.bash +3 -1
- data/scripts/clade_finding.bash +1 -1
- data/scripts/init.bash +1 -1
- data/scripts/miga.bash +1 -1
- data/scripts/mytaxa.bash +78 -72
- data/scripts/mytaxa_scan.bash +67 -62
- data/scripts/ogs.bash +1 -1
- data/scripts/trimmed_fasta.bash +4 -3
- data/utils/enveomics/Examples/aai-matrix.bash +66 -0
- data/utils/enveomics/Examples/ani-matrix.bash +66 -0
- data/utils/enveomics/Examples/essential-phylogeny.bash +105 -0
- data/utils/enveomics/Examples/unus-genome-phylogeny.bash +100 -0
- data/utils/enveomics/LICENSE.txt +73 -0
- data/utils/enveomics/Makefile +52 -0
- data/utils/enveomics/Manifest/Tasks/aasubs.json +103 -0
- data/utils/enveomics/Manifest/Tasks/blasttab.json +703 -0
- data/utils/enveomics/Manifest/Tasks/distances.json +161 -0
- data/utils/enveomics/Manifest/Tasks/fasta.json +571 -0
- data/utils/enveomics/Manifest/Tasks/fastq.json +208 -0
- data/utils/enveomics/Manifest/Tasks/graphics.json +126 -0
- data/utils/enveomics/Manifest/Tasks/ogs.json +339 -0
- data/utils/enveomics/Manifest/Tasks/other.json +746 -0
- data/utils/enveomics/Manifest/Tasks/remote.json +355 -0
- data/utils/enveomics/Manifest/Tasks/sequence-identity.json +454 -0
- data/utils/enveomics/Manifest/Tasks/tables.json +308 -0
- data/utils/enveomics/Manifest/Tasks/trees.json +68 -0
- data/utils/enveomics/Manifest/Tasks/variants.json +111 -0
- data/utils/enveomics/Manifest/categories.json +132 -0
- data/utils/enveomics/Manifest/examples.json +154 -0
- data/utils/enveomics/Manifest/tasks.json +4 -0
- data/utils/enveomics/Pipelines/assembly.pbs/CONFIG.mock.bash +69 -0
- data/utils/enveomics/Pipelines/assembly.pbs/FastA.N50.pl +56 -0
- data/utils/enveomics/Pipelines/assembly.pbs/FastA.filterN.pl +60 -0
- data/utils/enveomics/Pipelines/assembly.pbs/FastA.length.pl +38 -0
- data/utils/enveomics/Pipelines/assembly.pbs/README.md +189 -0
- data/utils/enveomics/Pipelines/assembly.pbs/RUNME-2.bash +112 -0
- data/utils/enveomics/Pipelines/assembly.pbs/RUNME-3.bash +23 -0
- data/utils/enveomics/Pipelines/assembly.pbs/RUNME-4.bash +44 -0
- data/utils/enveomics/Pipelines/assembly.pbs/RUNME.bash +50 -0
- data/utils/enveomics/Pipelines/assembly.pbs/kSelector.R +37 -0
- data/utils/enveomics/Pipelines/assembly.pbs/newbler.pbs +68 -0
- data/utils/enveomics/Pipelines/assembly.pbs/newbler_preparator.pl +49 -0
- data/utils/enveomics/Pipelines/assembly.pbs/soap.pbs +80 -0
- data/utils/enveomics/Pipelines/assembly.pbs/stats.pbs +57 -0
- data/utils/enveomics/Pipelines/assembly.pbs/velvet.pbs +63 -0
- data/utils/enveomics/Pipelines/blast.pbs/01.pbs.bash +38 -0
- data/utils/enveomics/Pipelines/blast.pbs/02.pbs.bash +73 -0
- data/utils/enveomics/Pipelines/blast.pbs/03.pbs.bash +21 -0
- data/utils/enveomics/Pipelines/blast.pbs/BlastTab.recover_job.pl +72 -0
- data/utils/enveomics/Pipelines/blast.pbs/CONFIG.mock.bash +98 -0
- data/utils/enveomics/Pipelines/blast.pbs/FastA.split.pl +55 -0
- data/utils/enveomics/Pipelines/blast.pbs/README.md +127 -0
- data/utils/enveomics/Pipelines/blast.pbs/RUNME.bash +109 -0
- data/utils/enveomics/Pipelines/blast.pbs/TASK.check.bash +128 -0
- data/utils/enveomics/Pipelines/blast.pbs/TASK.dry.bash +16 -0
- data/utils/enveomics/Pipelines/blast.pbs/TASK.eo.bash +22 -0
- data/utils/enveomics/Pipelines/blast.pbs/TASK.pause.bash +26 -0
- data/utils/enveomics/Pipelines/blast.pbs/TASK.run.bash +89 -0
- data/utils/enveomics/Pipelines/blast.pbs/sentinel.pbs.bash +29 -0
- data/utils/enveomics/Pipelines/idba.pbs/README.md +49 -0
- data/utils/enveomics/Pipelines/idba.pbs/RUNME.bash +95 -0
- data/utils/enveomics/Pipelines/idba.pbs/run.pbs +56 -0
- data/utils/enveomics/Pipelines/trim.pbs/README.md +54 -0
- data/utils/enveomics/Pipelines/trim.pbs/RUNME.bash +70 -0
- data/utils/enveomics/Pipelines/trim.pbs/run.pbs +130 -0
- data/utils/enveomics/README.md +40 -0
- data/utils/enveomics/Scripts/AAsubs.log2ratio.rb +171 -0
- data/utils/enveomics/Scripts/Aln.cat.rb +162 -0
- data/utils/enveomics/Scripts/Aln.convert.pl +35 -0
- data/utils/enveomics/Scripts/AlphaDiversity.pl +152 -0
- data/utils/enveomics/Scripts/BlastPairwise.AAsubs.pl +102 -0
- data/utils/enveomics/Scripts/BlastTab.addlen.rb +61 -0
- data/utils/enveomics/Scripts/BlastTab.advance.bash +48 -0
- data/utils/enveomics/Scripts/BlastTab.best_hit_sorted.pl +55 -0
- data/utils/enveomics/Scripts/BlastTab.catsbj.pl +106 -0
- data/utils/enveomics/Scripts/BlastTab.cogCat.rb +76 -0
- data/utils/enveomics/Scripts/BlastTab.filter.pl +47 -0
- data/utils/enveomics/Scripts/BlastTab.kegg_pep2path_rest.pl +194 -0
- data/utils/enveomics/Scripts/BlastTab.metaxaPrep.pl +104 -0
- data/utils/enveomics/Scripts/BlastTab.pairedHits.rb +157 -0
- data/utils/enveomics/Scripts/BlastTab.recplot2.R +40 -0
- data/utils/enveomics/Scripts/BlastTab.seqdepth.pl +86 -0
- data/utils/enveomics/Scripts/BlastTab.seqdepth_ZIP.pl +119 -0
- data/utils/enveomics/Scripts/BlastTab.seqdepth_nomedian.pl +86 -0
- data/utils/enveomics/Scripts/BlastTab.subsample.pl +47 -0
- data/utils/enveomics/Scripts/BlastTab.sumPerHit.pl +114 -0
- data/utils/enveomics/Scripts/BlastTab.taxid2taxrank.pl +90 -0
- data/utils/enveomics/Scripts/BlastTab.topHits_sorted.rb +101 -0
- data/utils/enveomics/Scripts/Chao1.pl +97 -0
- data/utils/enveomics/Scripts/CharTable.classify.rb +234 -0
- data/utils/enveomics/Scripts/EBIseq2tax.rb +83 -0
- data/utils/enveomics/Scripts/FastA.N50.pl +56 -0
- data/utils/enveomics/Scripts/FastA.filter.pl +52 -0
- data/utils/enveomics/Scripts/FastA.filterLen.pl +28 -0
- data/utils/enveomics/Scripts/FastA.filterN.pl +60 -0
- data/utils/enveomics/Scripts/FastA.fragment.rb +92 -0
- data/utils/enveomics/Scripts/FastA.gc.pl +42 -0
- data/utils/enveomics/Scripts/FastA.interpose.pl +87 -0
- data/utils/enveomics/Scripts/FastA.length.pl +38 -0
- data/utils/enveomics/Scripts/FastA.per_file.pl +36 -0
- data/utils/enveomics/Scripts/FastA.qlen.pl +57 -0
- data/utils/enveomics/Scripts/FastA.rename.pl +65 -0
- data/utils/enveomics/Scripts/FastA.revcom.pl +23 -0
- data/utils/enveomics/Scripts/FastA.slider.pl +85 -0
- data/utils/enveomics/Scripts/FastA.split.pl +55 -0
- data/utils/enveomics/Scripts/FastA.subsample.pl +131 -0
- data/utils/enveomics/Scripts/FastA.tag.rb +64 -0
- data/utils/enveomics/Scripts/FastA.wrap.rb +48 -0
- data/utils/enveomics/Scripts/FastQ.filter.pl +54 -0
- data/utils/enveomics/Scripts/FastQ.interpose.pl +90 -0
- data/utils/enveomics/Scripts/FastQ.offset.pl +90 -0
- data/utils/enveomics/Scripts/FastQ.split.pl +53 -0
- data/utils/enveomics/Scripts/FastQ.tag.rb +63 -0
- data/utils/enveomics/Scripts/FastQ.toFastA.awk +24 -0
- data/utils/enveomics/Scripts/GenBank.add_fields.rb +84 -0
- data/utils/enveomics/Scripts/HMM.essential.rb +254 -0
- data/utils/enveomics/Scripts/HMMsearch.extractIds.rb +83 -0
- data/utils/enveomics/Scripts/JPlace.distances.rb +88 -0
- data/utils/enveomics/Scripts/JPlace.to_iToL.rb +306 -0
- data/utils/enveomics/Scripts/M5nr.getSequences.rb +81 -0
- data/utils/enveomics/Scripts/MeTaxa.distribution.pl +198 -0
- data/utils/enveomics/Scripts/MyTaxa.fragsByTax.pl +35 -0
- data/utils/enveomics/Scripts/MyTaxa.seq-taxrank.rb +49 -0
- data/utils/enveomics/Scripts/NCBIacc2tax.rb +92 -0
- data/utils/enveomics/Scripts/Newick.autoprune.R +27 -0
- data/utils/enveomics/Scripts/RAxML-EPA.to_iToL.pl +228 -0
- data/utils/enveomics/Scripts/RefSeq.download.bash +48 -0
- data/utils/enveomics/Scripts/SRA.download.bash +50 -0
- data/utils/enveomics/Scripts/TRIBS.plot-test.R +36 -0
- data/utils/enveomics/Scripts/TRIBS.test.R +39 -0
- data/utils/enveomics/Scripts/Table.barplot.R +30 -0
- data/utils/enveomics/Scripts/Table.df2dist.R +30 -0
- data/utils/enveomics/Scripts/Table.filter.pl +61 -0
- data/utils/enveomics/Scripts/Table.merge.pl +77 -0
- data/utils/enveomics/Scripts/Table.replace.rb +69 -0
- data/utils/enveomics/Scripts/Table.round.rb +63 -0
- data/utils/enveomics/Scripts/Table.split.pl +57 -0
- data/utils/enveomics/Scripts/Taxonomy.silva2ncbi.rb +227 -0
- data/utils/enveomics/Scripts/VCF.KaKs.rb +147 -0
- data/utils/enveomics/Scripts/VCF.SNPs.rb +88 -0
- data/utils/enveomics/Scripts/aai.rb +373 -0
- data/utils/enveomics/Scripts/ani.rb +362 -0
- data/utils/enveomics/Scripts/gi2tax.rb +103 -0
- data/utils/enveomics/Scripts/in_silico_GA_GI.pl +96 -0
- data/utils/enveomics/Scripts/lib/data/essential.hmm.gz +0 -0
- data/utils/enveomics/Scripts/lib/enveomics_rb/enveomics.rb +26 -0
- data/utils/enveomics/Scripts/lib/enveomics_rb/jplace.rb +253 -0
- data/utils/enveomics/Scripts/lib/enveomics_rb/og.rb +182 -0
- data/utils/enveomics/Scripts/lib/enveomics_rb/remote_data.rb +74 -0
- data/utils/enveomics/Scripts/lib/enveomics_rb/seq_range.rb +237 -0
- data/utils/enveomics/Scripts/lib/enveomics_rb/stat.rb +30 -0
- data/utils/enveomics/Scripts/lib/enveomics_rb/vcf.rb +135 -0
- data/utils/enveomics/Scripts/ogs.annotate.rb +88 -0
- data/utils/enveomics/Scripts/ogs.core-pan.rb +160 -0
- data/utils/enveomics/Scripts/ogs.extract.rb +125 -0
- data/utils/enveomics/Scripts/ogs.mcl.rb +186 -0
- data/utils/enveomics/Scripts/ogs.rb +104 -0
- data/utils/enveomics/Scripts/ogs.stats.rb +131 -0
- data/utils/enveomics/Scripts/rbm.rb +137 -0
- data/utils/enveomics/Tests/Makefile +10 -0
- data/utils/enveomics/Tests/Mgen_M2288.faa +3189 -0
- data/utils/enveomics/Tests/Mgen_M2288.fna +8282 -0
- data/utils/enveomics/Tests/Mgen_M2321.fna +8288 -0
- data/utils/enveomics/Tests/Nequ_Kin4M.faa +2970 -0
- data/utils/enveomics/Tests/Xanthomonas_oryzae-PilA.tribs.Rdata +0 -0
- data/utils/enveomics/Tests/Xanthomonas_oryzae-PilA.txt +7 -0
- data/utils/enveomics/Tests/Xanthomonas_oryzae.aai-mat.tsv +17 -0
- data/utils/enveomics/Tests/Xanthomonas_oryzae.aai.tsv +137 -0
- data/utils/enveomics/Tests/a_mg.cds-go.blast.tsv +123 -0
- data/utils/enveomics/Tests/a_mg.reads-cds.blast.tsv +200 -0
- data/utils/enveomics/Tests/a_mg.reads-cds.counts.tsv +55 -0
- data/utils/enveomics/Tests/alkB.nwk +1 -0
- data/utils/enveomics/Tests/anthrax-cansnp-data.tsv +13 -0
- data/utils/enveomics/Tests/anthrax-cansnp-key.tsv +17 -0
- data/utils/enveomics/Tests/hiv1.faa +59 -0
- data/utils/enveomics/Tests/hiv1.fna +134 -0
- data/utils/enveomics/Tests/hiv2.faa +70 -0
- data/utils/enveomics/Tests/hiv_mix-hiv1.blast.tsv +233 -0
- data/utils/enveomics/Tests/hiv_mix-hiv1.blast.tsv.lim +1 -0
- data/utils/enveomics/Tests/hiv_mix-hiv1.blast.tsv.rec +233 -0
- data/utils/enveomics/Tests/phyla_counts.tsv +10 -0
- data/utils/enveomics/Tests/primate_lentivirus.ogs +11 -0
- data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv1-hiv1.rbm +9 -0
- data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv1-hiv2.rbm +8 -0
- data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv1-siv.rbm +6 -0
- data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv2-hiv2.rbm +9 -0
- data/utils/enveomics/Tests/primate_lentivirus.rbm/hiv2-siv.rbm +6 -0
- data/utils/enveomics/Tests/primate_lentivirus.rbm/siv-siv.rbm +6 -0
- data/utils/enveomics/build_enveomics_r.bash +44 -0
- data/utils/enveomics/enveomics.R/DESCRIPTION +31 -0
- data/utils/enveomics/enveomics.R/NAMESPACE +35 -0
- data/utils/enveomics/enveomics.R/R/autoprune.R +121 -0
- data/utils/enveomics/enveomics.R/R/barplot.R +165 -0
- data/utils/enveomics/enveomics.R/R/cliopts.R +119 -0
- data/utils/enveomics/enveomics.R/R/df2dist.R +117 -0
- data/utils/enveomics/enveomics.R/R/growthcurve.R +263 -0
- data/utils/enveomics/enveomics.R/R/recplot.R +320 -0
- data/utils/enveomics/enveomics.R/R/recplot2.R +745 -0
- data/utils/enveomics/enveomics.R/R/tribs.R +423 -0
- data/utils/enveomics/enveomics.R/R/utils.R +16 -0
- data/utils/enveomics/enveomics.R/README.md +52 -0
- data/utils/enveomics/enveomics.R/data/growth.curves.rda +0 -0
- data/utils/enveomics/enveomics.R/data/phyla.counts.rda +0 -0
- data/utils/enveomics/enveomics.R/man/enve.GrowthCurve-class.Rd +30 -0
- data/utils/enveomics/enveomics.R/man/enve.TRIBS-class.Rd +43 -0
- data/utils/enveomics/enveomics.R/man/enve.TRIBS.merge.Rd +19 -0
- data/utils/enveomics/enveomics.R/man/enve.TRIBStest-class.Rd +37 -0
- data/utils/enveomics/enveomics.R/man/enve.__prune.iter.Rd +24 -0
- data/utils/enveomics/enveomics.R/man/enve.__prune.reduce.Rd +24 -0
- data/utils/enveomics/enveomics.R/man/enve.__tribs.Rd +33 -0
- data/utils/enveomics/enveomics.R/man/enve.barplot.Rd +64 -0
- data/utils/enveomics/enveomics.R/man/enve.cliopts.Rd +37 -0
- data/utils/enveomics/enveomics.R/man/enve.col.alpha.Rd +19 -0
- data/utils/enveomics/enveomics.R/man/enve.col2alpha.Rd +18 -0
- data/utils/enveomics/enveomics.R/man/enve.df2dist.Rd +26 -0
- data/utils/enveomics/enveomics.R/man/enve.df2dist.group.Rd +25 -0
- data/utils/enveomics/enveomics.R/man/enve.df2dist.list.Rd +26 -0
- data/utils/enveomics/enveomics.R/man/enve.growthcurve.Rd +49 -0
- data/utils/enveomics/enveomics.R/man/enve.prune.dist.Rd +28 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot.Rd +97 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2-class.Rd +40 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2.Rd +40 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2.__counts.Rd +24 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2.__findPeak.Rd +40 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2.__findPeaks.Rd +18 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2.__peakHist.Rd +22 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2.__whichClosestPeak.Rd +20 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2.changeCutoff.Rd +18 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2.corePeak.Rd +18 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2.extractWindows.Rd +27 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2.findPeaks.Rd +53 -0
- data/utils/enveomics/enveomics.R/man/enve.recplot2.peak-class.Rd +44 -0
- data/utils/enveomics/enveomics.R/man/enve.tribs.Rd +44 -0
- data/utils/enveomics/enveomics.R/man/enve.tribs.test.Rd +21 -0
- data/utils/enveomics/enveomics.R/man/enveomics.R-package.Rd +15 -0
- data/utils/enveomics/enveomics.R/man/growth.curves.Rd +14 -0
- data/utils/enveomics/enveomics.R/man/phyla.counts.Rd +13 -0
- data/utils/enveomics/enveomics.R/man/plot.enve.GrowthCurve.Rd +43 -0
- data/utils/enveomics/enveomics.R/man/plot.enve.TRIBS.Rd +29 -0
- data/utils/enveomics/enveomics.R/man/plot.enve.TRIBStest.Rd +30 -0
- data/utils/enveomics/enveomics.R/man/plot.enve.recplot2.Rd +71 -0
- data/utils/enveomics/enveomics.R/man/summary.enve.GrowthCurve.Rd +18 -0
- data/utils/enveomics/enveomics.R/man/summary.enve.TRIBS.Rd +18 -0
- data/utils/enveomics/enveomics.R/man/summary.enve.TRIBStest.Rd +18 -0
- data/utils/enveomics/enveomics.R/man/z$-methods.Rd +27 -0
- data/utils/enveomics/globals.mk +8 -0
- data/utils/enveomics/manifest.json +9 -0
- data/utils/index_metadata.rb +0 -0
- data/utils/plot-taxdist.R +0 -0
- data/utils/requirements.txt +19 -19
- metadata +242 -2
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# @author: Luis M. Rodriguez-R
|
5
|
+
# @update: Feb-06-2015
|
6
|
+
# @license: artistic license 2.0
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'optparse'
|
10
|
+
require 'rubygems'
|
11
|
+
require 'restclient'
|
12
|
+
require 'open-uri'
|
13
|
+
require 'JSON'
|
14
|
+
|
15
|
+
o = {:q=>FALSE, :url=>'http://api.metagenomics.anl.gov/m5nr', :max=>0, :recover=>FALSE}
|
16
|
+
ARGV << '-h' if ARGV.size==0
|
17
|
+
OptionParser.new do |opts|
|
18
|
+
opts.banner = "
|
19
|
+
Downloads a set of sequences from M5nr with a given functional annotation.
|
20
|
+
|
21
|
+
Usage: #{$0} [options]"
|
22
|
+
opts.separator ""
|
23
|
+
opts.separator "Mandatory"
|
24
|
+
opts.on("-f", "--function STR", "Functional annotation."){ |v| o[:function] = v }
|
25
|
+
opts.separator ""
|
26
|
+
opts.separator "Options"
|
27
|
+
opts.on("-m", "--max INT", "Maximum number of sequences to download. By default: all (0)."){ |v| o[:max] = v.to_i }
|
28
|
+
opts.on("-r", "--recover", "If set, tries to recover a previous FastA."){ o[:recover]=TRUE }
|
29
|
+
opts.on("-n", "--url STR", "URL for M5nr API. By default: #{o[:url]}."){ |v| o[:url] = v }
|
30
|
+
opts.on("-o", "--out FILE", "File containing the sequences. By default: value of -f appended with .fa."){ |v| o[:out] = v }
|
31
|
+
opts.on("-q", "--quiet", "Run quietly (no STDERR output)"){ o[:q] = TRUE }
|
32
|
+
opts.on("-h", "--help", "Display this screen") do
|
33
|
+
puts opts
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
opts.separator ""
|
37
|
+
end.parse!
|
38
|
+
abort "-f is mandatory" if o[:function].nil?
|
39
|
+
o[:out] = "#{o[:function].gsub(/ /,'_')}.fa" if o[:out].nil?
|
40
|
+
uri_fun = URI::encode(o[:function])
|
41
|
+
|
42
|
+
ignore = {}
|
43
|
+
if o[:recover] and File.exists? o[:out]
|
44
|
+
ih = File.open(o[:out], "r")
|
45
|
+
ih.each_line do |ln|
|
46
|
+
id = /^>(\S+)\s/.match(ln)
|
47
|
+
unless id.nil?
|
48
|
+
ignore[id[1]] = 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
ih.close
|
52
|
+
of = File.open(o[:out], "a+")
|
53
|
+
else
|
54
|
+
of = File.open(o[:out], "w")
|
55
|
+
end
|
56
|
+
|
57
|
+
next_url = "#{o[:url]}/function/#{uri_fun}"
|
58
|
+
i = 0
|
59
|
+
loop do
|
60
|
+
$stderr.print "Downloading sequence #{i+1}. \r" unless o[:q]
|
61
|
+
res_fun = RestClient.get next_url
|
62
|
+
abort "Unable to reach MG-RAST M5nr API, error code #{res_fun.code}." unless res_fun.code == 200
|
63
|
+
fun = JSON.parse(res_fun.to_str)
|
64
|
+
fun["data"].each do |datum|
|
65
|
+
if ignore["#{datum["source"]}:#{datum["accession"]}"].nil?
|
66
|
+
res_seq = RestClient.get "#{o[:url]}/md5/#{datum["md5"]}", {:params=>{:sequence=>1}}
|
67
|
+
abort "Unable to reach MG-RAST M5nr API, error code #{res_seq.code}." unless res_seq.code == 200
|
68
|
+
seq = JSON.parse(res_seq.to_str)
|
69
|
+
of.puts ">#{datum["source"]}:#{datum["accession"]} #{datum["function"]} [#{datum["organism"]} taxid:#{datum["ncbi_tax_id"]}]"
|
70
|
+
of.puts seq["data"]["sequence"].scan(/.{80}|.+/).map{ |x| x.strip }.join($/)
|
71
|
+
end
|
72
|
+
i += 1
|
73
|
+
break if o[:max]>0 and i >= o[:max]
|
74
|
+
end # |datum|
|
75
|
+
next_url = fun["next"]
|
76
|
+
break if next_url.nil? or (o[:max] > 0 and i >= o[:max])
|
77
|
+
end
|
78
|
+
of.close
|
79
|
+
|
80
|
+
$stderr.puts "Downloaded #{i} sequences." unless o[:q]
|
81
|
+
|
@@ -0,0 +1,198 @@
|
|
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
|
+
use warnings;
|
8
|
+
use strict;
|
9
|
+
use Symbol;
|
10
|
+
use Getopt::Std;
|
11
|
+
use List::Util qw/max/;
|
12
|
+
|
13
|
+
sub HELP_MESSAGE { die "
|
14
|
+
Usage:
|
15
|
+
$0 [args]
|
16
|
+
|
17
|
+
Mandatory:
|
18
|
+
-m <str> MyTaxa output.
|
19
|
+
|
20
|
+
Optional:
|
21
|
+
-g <str> Genes predicted in the format defined by -f. If not passed, abundance is assumed to be based
|
22
|
+
on contigs.
|
23
|
+
-f <str> Format of the predicted genes. One of:
|
24
|
+
o gff2: GFF v2 as produced by MetaGeneMark.hmm (default).
|
25
|
+
o gff3: GFF v3, including the field id in the last column (with the Gene ID).
|
26
|
+
o tab: A tab-delimited file with the gene ID (col #1), the length of the gene in bp (col #2),
|
27
|
+
and the ID of the corresponding contig (col #3). The length of the gene (col #2) isn't used
|
28
|
+
(and it can be empty), but the column must exist (i.e., 2 tabs per line) for compatibility
|
29
|
+
with BlastTab.metaxaPrep.pl
|
30
|
+
-c <str> Counts file: Sequence IDs (genes if -g is provided, contigs otherwise) and reads per sequence
|
31
|
+
in a tab-delimited file. If not provided, each sequence counts as 1.
|
32
|
+
-O <str> Prefix of the output files to be generated. By default, the value of -m.
|
33
|
+
-I <str> File containing the complete classification of all the contigs identified as Innominate taxa.
|
34
|
+
By default, this file is not created.
|
35
|
+
-G <str> File containing the classification of each gene. By default, this file is not created. This
|
36
|
+
requires -g to be set. Note: This option requires extra RAM.
|
37
|
+
-K <str> File containing a krona input file. By default, this file is not created.
|
38
|
+
-k <str> List of ranks to include in the Krona file, delimited by comma. It MUST be decreasing rank.
|
39
|
+
By default: 'superkingdom,phylum,class,family,genus,species'. This is ignored unless -K also
|
40
|
+
is passed.
|
41
|
+
-R <str> List of taxonomic ranks for which individual reports should be generated, delimited by comma.
|
42
|
+
It MUST be decreasing rank. By default: 'phylum,genus,species'.
|
43
|
+
-r If set, reports raw counts. Otherwise, reports permil of the rank.
|
44
|
+
-u Report Unknown taxa.
|
45
|
+
-q Run quietly.
|
46
|
+
-h Display this help message and exits.
|
47
|
+
|
48
|
+
" }
|
49
|
+
|
50
|
+
my %o;
|
51
|
+
getopts('g:f:c:m:O:I:G:K:k:R:ruqh', \%o);
|
52
|
+
$o{h} and &HELP_MESSAGE;
|
53
|
+
$o{m} or &HELP_MESSAGE;
|
54
|
+
$o{O} ||= $o{m};
|
55
|
+
$o{f} ||= "gff2";
|
56
|
+
$o{k} ||= "superkingdom,phylum,class,family,genus,species";
|
57
|
+
my @K = split /,/, lc $o{k};
|
58
|
+
$o{R} ||= "phylum,genus,species";
|
59
|
+
my @R = split /,/, lc $o{R};
|
60
|
+
($o{G} and not $o{g}) and die "-G requires -g to be set.\n";
|
61
|
+
|
62
|
+
|
63
|
+
my %gene;
|
64
|
+
my %count;
|
65
|
+
my %ctg=();
|
66
|
+
if($o{g}){
|
67
|
+
print STDERR "Reading genes collection.\n" unless $o{q};
|
68
|
+
open GFF, "<", $o{g} or die "Cannot read file: $o{g}: $!\n";
|
69
|
+
while(<GFF>){
|
70
|
+
next if /^#/;
|
71
|
+
next if /^\s*$/;
|
72
|
+
chomp;
|
73
|
+
my($id,$ctg);
|
74
|
+
my @ln = split /\t/;
|
75
|
+
if($o{f} eq 'gff2'){
|
76
|
+
exists $ln[8] or die "Cannot parse line $., expecting 9 columns: $_\n";
|
77
|
+
$id = $ln[8];
|
78
|
+
$id =~ s/gene_id /gene_id_/;
|
79
|
+
$ctg=$ln[0];
|
80
|
+
}elsif($o{f} eq 'gff3'){
|
81
|
+
exists $ln[8] or die "Cannot parse line $., expecting 9 columns: $_\n";
|
82
|
+
$ln[8] =~ /id=([^;]+)/ or die "Cannot parse line $.: $_\n";
|
83
|
+
$id = $1;
|
84
|
+
$ctg = $ln[0];
|
85
|
+
}elsif($o{f} eq 'tab'){
|
86
|
+
exists $ln[2] or die "Cannot parse line $., expecting 3 columns: $_\n";
|
87
|
+
$id = $ln[0];
|
88
|
+
$ctg = $ln[2];
|
89
|
+
}else{
|
90
|
+
die "Unsupported format: ".$o{f}.".\n";
|
91
|
+
}
|
92
|
+
$ctg =~ s/ .*//;
|
93
|
+
if($o{c}){
|
94
|
+
$gene{$id} = $ctg;
|
95
|
+
}else{
|
96
|
+
$count{$ctg}++;
|
97
|
+
}
|
98
|
+
push( @{$ctg{$ctg}||=[]}, $id ) if $o{G};
|
99
|
+
}
|
100
|
+
close GFF;
|
101
|
+
print STDERR " Found ".(scalar(keys %gene))." genes.\n" unless $o{q};
|
102
|
+
}
|
103
|
+
|
104
|
+
my $Nreads = 0;
|
105
|
+
if($o{c}){
|
106
|
+
print STDERR "Reading read-counts.\n" unless $o{q};
|
107
|
+
open COUNT, "<", $o{c} or die "Cannot read file: $o{c}: $!\n";
|
108
|
+
while(<COUNT>){
|
109
|
+
chomp;
|
110
|
+
my @l = split /\t/;
|
111
|
+
if($o{g}){
|
112
|
+
exists $gene{$l[0]} or die "Cannot find gene's contig: $l[0].\n";
|
113
|
+
$count{ $gene{$l[0]} } += $l[1];
|
114
|
+
delete $gene{$l[0]};
|
115
|
+
}else{
|
116
|
+
$count{ $l[0] } += $l[1];
|
117
|
+
}
|
118
|
+
$Nreads += $l[1];
|
119
|
+
}
|
120
|
+
close COUNT;
|
121
|
+
print STDERR " Found ".scalar(keys %gene)." genes without reads.\n" if scalar(keys %gene) and not $o{q};
|
122
|
+
$count{$_}+=0 for values %gene;
|
123
|
+
print STDERR " Found ".scalar(keys %count)." sequences and $Nreads reads.\n" unless $o{q};
|
124
|
+
}
|
125
|
+
|
126
|
+
print STDERR "Reading Metaxa results.\n";
|
127
|
+
open METAXA, "<", $o{m} or die "Cannot read file: $o{m}: $!\n";
|
128
|
+
my $ctg;
|
129
|
+
my $rank;
|
130
|
+
my @ofh = ();
|
131
|
+
my @n = (0,0,0);
|
132
|
+
my @out = ({},{},{});
|
133
|
+
my @rank_name = map { ucfirst } ('unknown', @R);
|
134
|
+
my %rank = map { ($rank_name[$_]=>$_) } 0 .. $#rank_name;
|
135
|
+
my @rank_tag = ("NA", map { "<$_>" } @R);
|
136
|
+
$o{I} and (open OUT_I, ">", $o{I} or die "Cannot create file: $o{I}: $!\n");
|
137
|
+
$o{K} and (open OUT_K, ">", $o{K} or die "Cannot create file: $o{K}: $!\n");
|
138
|
+
$o{G} and (open OUT_G, ">", $o{G} or die "Cannot create file: $o{G}: $!\n");
|
139
|
+
|
140
|
+
my $Nreads_class = 0;
|
141
|
+
my $Nno_read_ctg = 0;
|
142
|
+
while(not eof(METAXA)){
|
143
|
+
my @h=split /\t/, <METAXA>;
|
144
|
+
my $t=<METAXA>; chomp $t;
|
145
|
+
exists $h[3] or die "Cannot parse MyTaxa file, line $.: $_\n";
|
146
|
+
my $count_h;
|
147
|
+
if($o{c} or $o{g}){
|
148
|
+
unless(exists $count{$h[0]}){
|
149
|
+
$Nno_read_ctg++;
|
150
|
+
next;
|
151
|
+
}
|
152
|
+
$count_h = $count{$h[0]};
|
153
|
+
}else{
|
154
|
+
$count_h = 1;
|
155
|
+
}
|
156
|
+
if($o{G}){ print OUT_G "$_\t$t\n" for @{$ctg{$h[0]}} }
|
157
|
+
next unless $count_h;
|
158
|
+
my $last = 'organism';
|
159
|
+
$n[0] += $count_h;
|
160
|
+
for my $r (1 .. max(values %rank)){
|
161
|
+
if($rank{$h[1]} >= $r){
|
162
|
+
if($t =~ m/$rank_tag[$r]([^;]*)/){
|
163
|
+
$last = $1 if $1;
|
164
|
+
}else{
|
165
|
+
$last = $last=~/^Innominate / ? $last : "Innominate $last";
|
166
|
+
$o{I} and print OUT_I "$h[0]\t$rank_name[$r]\t$last\t$t\n";
|
167
|
+
}
|
168
|
+
$out[$r]->{$last} += $count_h;
|
169
|
+
$n[$r] += $count_h;
|
170
|
+
}else{
|
171
|
+
$out[$r]->{"Unknown $last"} += $count_h if $o{u};
|
172
|
+
}
|
173
|
+
}
|
174
|
+
if($o{K}){
|
175
|
+
my $ln = $count_h;
|
176
|
+
for my $r (@K){ $ln.= "\t".($t=~m/<$r>([^;]+)/?$1:'') }
|
177
|
+
print OUT_K "$ln\n";
|
178
|
+
}
|
179
|
+
$Nreads_class+= $count_h;
|
180
|
+
}
|
181
|
+
print OUT_K "".($Nreads-$Nreads_class)."\n" if $o{K} and $Nreads>$Nreads_class;
|
182
|
+
close METAXA;
|
183
|
+
$o{I} and close OUT_I;
|
184
|
+
$o{K} and close OUT_K;
|
185
|
+
$o{G} and close OUT_G;
|
186
|
+
print " Found $n[0] reads.\n" unless $o{q};
|
187
|
+
print " Couldn't find counts for $Nno_read_ctg contigs.\n" if $Nno_read_ctg;
|
188
|
+
unless($o{q}){ print " Found $n[$_] classified reads at ".$rank_name[$_]." level.\n" for (1 .. max(values %rank)) }
|
189
|
+
|
190
|
+
print STDERR "Generating output.\n" unless $o{q};
|
191
|
+
for my $rank (1 .. max(values %rank)){
|
192
|
+
open OUT, ">", "$o{O}.".$rank_name[$rank].".txt" or die "Cannot create file: $o{O}.".$rank_name[$rank].".txt: $!\n";
|
193
|
+
for my $class (keys %{$out[$rank]}){
|
194
|
+
printf OUT "%s\t%.20f\n", $class, ($out[$rank]->{$class}*($o{r}?1:1000/$n[$rank]));
|
195
|
+
}
|
196
|
+
close OUT;
|
197
|
+
}
|
198
|
+
|
@@ -0,0 +1,35 @@
|
|
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
|
+
|
8
|
+
use warnings;
|
9
|
+
use strict;
|
10
|
+
|
11
|
+
my($file,$tax,$rank) = @ARGV;
|
12
|
+
($file and $tax) or die "
|
13
|
+
.Usage:
|
14
|
+
$0 file.txt taxon[ rank]
|
15
|
+
|
16
|
+
file.txt MyTaxa output.
|
17
|
+
taxon Taxon to look for.
|
18
|
+
rank Rank of taxon (optional). By default: any rank.
|
19
|
+
|
20
|
+
";
|
21
|
+
$rank ||= ".*";
|
22
|
+
$rank = lc $rank;
|
23
|
+
|
24
|
+
open MT, "<", $file or die "Cannot read file: $file: $!\n";
|
25
|
+
my $last = '';
|
26
|
+
while(my $ln=<MT>){
|
27
|
+
chomp $ln;
|
28
|
+
if($ln =~ /<$rank>$tax(;|$)/){
|
29
|
+
$last =~ s/\t.*//;
|
30
|
+
print $last, "\n";
|
31
|
+
}
|
32
|
+
$last = $ln;
|
33
|
+
}
|
34
|
+
close MT;
|
35
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @update: Feb-06-2015
|
6
|
+
# @license artistic license 2.0
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'optparse'
|
10
|
+
|
11
|
+
opts = {:rank=>'genus', :quiet=>FALSE}
|
12
|
+
ARGV << '-h' if ARGV.size==0
|
13
|
+
OptionParser.new do |opt|
|
14
|
+
opt.separator "Generates a simple tabular file with the classification of each sequence at a given taxonomic rank from a MyTaxa output."
|
15
|
+
opt.separator ""
|
16
|
+
opt.on("-i", "--mytaxa FILE", "Input MyTaxa file."){ |v| opts[:mytaxa]=v }
|
17
|
+
opt.on("-r", "--rank STR", "Taxonomic rank. By default: #{opts[:rank]}."){ |v| opts[:rank] = v.downcase }
|
18
|
+
opt.on("-q","--quiet","Run quietly.") { opts[:quiet]=TRUE }
|
19
|
+
opt.on("-h","--help","Display this screen.") do
|
20
|
+
puts opt
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
opt.separator ""
|
24
|
+
end.parse!
|
25
|
+
abort "-i/--mytaxa is mandatory." if opts[:mytaxa].nil?
|
26
|
+
abort "-i/--mytaxa must exist." unless File.exists? opts[:mytaxa]
|
27
|
+
|
28
|
+
begin
|
29
|
+
f = File.open(opts[:mytaxa], "r")
|
30
|
+
ctg = nil;
|
31
|
+
while(ln = f.gets)
|
32
|
+
m = /^(.+)(\t.+){3}/.match(ln)
|
33
|
+
if m
|
34
|
+
raise "Couldn't find classification for contig #{ctg}" unless ctg.nil?
|
35
|
+
ctg = m[1]
|
36
|
+
else
|
37
|
+
raise "Couldn't find the contig name at line #{$.}" if ctg.nil?
|
38
|
+
m = /<#{opts[:rank]}>([^;]+)/.match(ln)
|
39
|
+
puts "#{ctg}\t#{m ? m[1] : "Unclassified"}"
|
40
|
+
ctg = nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
f.close
|
44
|
+
rescue => err
|
45
|
+
$stderr.puts "Exception: #{err}\n\n"
|
46
|
+
err.backtrace.each { |l| $stderr.puts l + "\n" }
|
47
|
+
err
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @license artistic license 2.0
|
6
|
+
#
|
7
|
+
|
8
|
+
$:.push File.expand_path(File.dirname(__FILE__) + "/lib")
|
9
|
+
require "enveomics_rb/remote_data"
|
10
|
+
use "nokogiri"
|
11
|
+
|
12
|
+
#================================[ Options parsing ]
|
13
|
+
o = {
|
14
|
+
:q=>false, :accs=>[], :dbfrom=>"nuccore", :header=>true,
|
15
|
+
:no_nil=>false, :ret=>"ScientificName",
|
16
|
+
:ranks=>%w(superkingdom phylum class order family genus species)}
|
17
|
+
OptionParser.new do |opt|
|
18
|
+
opt.banner = "
|
19
|
+
Maps a list of NCBI accessions to their corresponding taxonomy using the NCBI
|
20
|
+
EUtilities. Avoid using this script on millions of entries at a time, since
|
21
|
+
each entry elicits two requests to NCBI's servers.
|
22
|
+
|
23
|
+
Usage: #{$0} [options]".gsub(/^ +/,"")
|
24
|
+
opt.separator ""
|
25
|
+
opt.on("-a", "--acc acc1,acc2.ver,...", Array,
|
26
|
+
"Comma-separated list of accessions. Required unless -i is passed."
|
27
|
+
){ |v| o[:accs]=v }
|
28
|
+
opt.on("-i", "--infile FILE",
|
29
|
+
"Raw text file containing the list of accessions, one per line.",
|
30
|
+
"Required unless -g is passed."){ |v| o[:infile]=v }
|
31
|
+
opt.on("-p", "--protein",
|
32
|
+
"Use if the accessions are proteins. Otherwise, accessions are assumed " +
|
33
|
+
"to be from the Nuccore Database."){ o[:dbfrom]="protein" }
|
34
|
+
opt.on("-r", "--ranks RANK1,RANK2,...", Array,
|
35
|
+
"Taxonomic ranks to report. By default: #{o[:ranks].join(",")}."
|
36
|
+
){ |v| o[:ranks]=v }
|
37
|
+
opt.on("-n", "--noheader",
|
38
|
+
"Do not include a header in the output."){ o[:header]=false }
|
39
|
+
opt.on("-t", "--taxids",
|
40
|
+
"Return Taxonomy IDs instead of scientific names."){ o[:ret]="TaxId" }
|
41
|
+
opt.on("--ignore-missing",
|
42
|
+
"Does not report missing accessions in the output file.",
|
43
|
+
"By default, it reports accessions and empty values for all other columns."
|
44
|
+
){ |v| o[:no_nil]=v }
|
45
|
+
opt.on("-q", "--quiet", "Run quietly."){ |v| o[:q]=true }
|
46
|
+
opt.on("-h", "--help","Display this screen") do
|
47
|
+
puts opt
|
48
|
+
exit
|
49
|
+
end
|
50
|
+
opt.separator ""
|
51
|
+
end.parse!
|
52
|
+
|
53
|
+
#================================[ Functions ]
|
54
|
+
def acc2taxid(db, acc)
|
55
|
+
doc = Nokogiri::XML( RemoteData.elink({:dbfrom=>db,
|
56
|
+
:db=>"taxonomy", :id=>acc, :idtype=>"acc"}) )
|
57
|
+
doc.at_xpath("/eLinkResult/LinkSet/LinkSetDb/Link/Id")
|
58
|
+
end
|
59
|
+
#================================[ Main ]
|
60
|
+
begin
|
61
|
+
o[:accs] += File.readlines(o[:infile]).map{ |l| l.chomp } unless
|
62
|
+
o[:infile].nil?
|
63
|
+
o[:ranks].map!{ |r| r.downcase }
|
64
|
+
puts (["Acc", "TaxId"] + o[:ranks].map{ |r| r.capitalize }).join("\t") if
|
65
|
+
o[:header]
|
66
|
+
o[:accs].each do |acc|
|
67
|
+
taxid = acc2taxid(o[:dbfrom], acc)
|
68
|
+
status = ""
|
69
|
+
if taxid.nil?
|
70
|
+
warn "Cannot find link to taxonomy: #{acc} #{status}"
|
71
|
+
puts ([acc, ""] + o[:ranks].map{ |i| "" }).join("\t") unless o[:no_nil]
|
72
|
+
next
|
73
|
+
end
|
74
|
+
taxonomy = {}
|
75
|
+
unless taxid.nil?
|
76
|
+
doc = Nokogiri::XML( RemoteData.efetch({:db=>"taxonomy",
|
77
|
+
:id=>taxid.content}) )
|
78
|
+
taxonomy[ doc.at_xpath("/TaxaSet/Taxon/Rank").content ] =
|
79
|
+
doc.at_xpath("/TaxaSet/Taxon/#{o[:ret]}").content
|
80
|
+
doc.xpath("/TaxaSet/Taxon/LineageEx/Taxon").each do |taxon|
|
81
|
+
taxonomy[ taxon.at_xpath("./Rank").content ] =
|
82
|
+
taxon.at_xpath("./#{o[:ret]}").content
|
83
|
+
end
|
84
|
+
end
|
85
|
+
puts ([acc, taxid.content] +
|
86
|
+
o[:ranks].map{ |rank| taxonomy[ rank ] ||= "" }).join("\t")
|
87
|
+
end
|
88
|
+
rescue => err
|
89
|
+
$stderr.puts "Exception: #{err}\n\n"
|
90
|
+
err.backtrace.each { |l| $stderr.puts l + "\n" }
|
91
|
+
err
|
92
|
+
end
|