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,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. Number of mapped reads
|
26
|
+
4. Length of the subject sequence
|
27
|
+
|
28
|
+
Note:
|
29
|
+
The values reported by this script may differ from those of BlastTab.seqdepth.pl,
|
30
|
+
because this script uses the aligned length of the read while BlastTab.seqdepth.pl
|
31
|
+
uses the aligned length of the subject sequence.
|
32
|
+
|
33
|
+
";
|
34
|
+
|
35
|
+
my $size = {};
|
36
|
+
my $gene = {};
|
37
|
+
my $reads = {};
|
38
|
+
|
39
|
+
SIZE:{
|
40
|
+
local $/=">";
|
41
|
+
print STDERR "== Reading fasta\n";
|
42
|
+
open FNA, "<", $fna or die "Cannot read the file: $fna: $!\n";
|
43
|
+
my $i=0;
|
44
|
+
while(<FNA>){
|
45
|
+
chomp;
|
46
|
+
my @g = split /\n/, $_, 2;
|
47
|
+
next unless $g[1];
|
48
|
+
#$g[1] =~ s/[^A-Za-z]//g;
|
49
|
+
#$size->{$g[0]} = length $g[1];
|
50
|
+
$g[0] =~ s/\s.*//;
|
51
|
+
$size->{$g[0]} = ( $g[1] =~ tr/[A-Za-z]// );
|
52
|
+
print STDERR " Measuring sequence ".($i).": $g[0] \r" unless ++$i%500;
|
53
|
+
}
|
54
|
+
close FNA;
|
55
|
+
print STDERR " Found $i sequences".(" "x30)."\n";
|
56
|
+
}
|
57
|
+
|
58
|
+
MAP:{
|
59
|
+
print STDERR "== Reading mapping\n";
|
60
|
+
my $i=0;
|
61
|
+
while(<>){
|
62
|
+
my @ln = split /\t/;
|
63
|
+
$gene->{$ln[1]} ||= 0;
|
64
|
+
$gene->{$ln[1]} += abs($ln[6]-$ln[7])+1;
|
65
|
+
($reads->{$ln[1]} ||= 0)++;
|
66
|
+
print STDERR " Saving hit ".($i).": $ln[1] \r" unless ++$i%5000;
|
67
|
+
}
|
68
|
+
print STDERR " Found $i hits".(" "x30)."\n";
|
69
|
+
}
|
70
|
+
|
71
|
+
OUT:{
|
72
|
+
print STDERR "== Creating output\n";
|
73
|
+
my $i=0;
|
74
|
+
for my $g (keys %$gene){
|
75
|
+
die "Cannot find gene in $fna: $g.\n" unless exists $size->{$g};
|
76
|
+
printf "%s\t%.6f\t%d\t%d\n", $g,
|
77
|
+
$gene->{$g}/$size->{$g},
|
78
|
+
$reads->{$g},
|
79
|
+
$size->{$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,47 @@
|
|
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
|
+
|
11
|
+
my($blast, $fasta) = @ARGV;
|
12
|
+
($blast and $fasta) or die "
|
13
|
+
Description:
|
14
|
+
Filters a BLAST output including only the hits produced by
|
15
|
+
any of the given sequences as query.
|
16
|
+
|
17
|
+
Usage:
|
18
|
+
$0 blast.tab sample.fa > out.tab
|
19
|
+
|
20
|
+
blast.tab BLAST output to be filtered (tabular format).
|
21
|
+
sample.fa Sequences to use as query.
|
22
|
+
out.tab The filtered BLAST output (tabular format).
|
23
|
+
|
24
|
+
";
|
25
|
+
|
26
|
+
print STDERR "== Reading sequences\n";
|
27
|
+
my $seq = {};
|
28
|
+
open FASTA, "<", $fasta or die "Cannot read the file: $fasta: $!\n";
|
29
|
+
while(<FASTA>){
|
30
|
+
next unless /^>(\S+)/;
|
31
|
+
$seq->{$1} = 1;
|
32
|
+
}
|
33
|
+
close FASTA;
|
34
|
+
print STDERR " ".(scalar keys %$seq)." sequences to be used as query.\n";
|
35
|
+
|
36
|
+
print STDERR "== Reading BLAST\n";
|
37
|
+
my ($N,$n)=(0,0);
|
38
|
+
open BLAST, "<", $blast or die "Cannot read the file: $blast: $!\n";
|
39
|
+
while(my $ln = <BLAST>){
|
40
|
+
next if $ln=~/^#/;
|
41
|
+
$N++; my ($qry) = split /\t/, $ln;
|
42
|
+
next unless exists $seq->{$qry};
|
43
|
+
$n++; print $ln;
|
44
|
+
}
|
45
|
+
close BLAST;
|
46
|
+
print STDERR " Reported $n entries out of $N.\n";
|
47
|
+
|
@@ -0,0 +1,114 @@
|
|
1
|
+
#!/usr/bin/env perl
|
2
|
+
#
|
3
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
4
|
+
# @update Mar-23-2016
|
5
|
+
# @license artistic license 2.0
|
6
|
+
#
|
7
|
+
|
8
|
+
use warnings;
|
9
|
+
use strict;
|
10
|
+
use Getopt::Std;
|
11
|
+
|
12
|
+
sub HELP_MESSAGE {
|
13
|
+
die "
|
14
|
+
.Description
|
15
|
+
Sums the weights of all the queries hitting each subject. Often (but not
|
16
|
+
necessarily) the BLAST files contain only best matches. The weights can be
|
17
|
+
any number, but a common use of this Script is to add up counts (weights are
|
18
|
+
integers). For example, in a BLAST of predicted genes vs some annotation
|
19
|
+
source, the weights could be the number of reads recruited by each gene.
|
20
|
+
|
21
|
+
.Usage:
|
22
|
+
$0 [options] blast... > out-file
|
23
|
+
|
24
|
+
blast... * One or more BLAST files.
|
25
|
+
out-file A two-columns tab-delimited file containing the summed weights
|
26
|
+
per hit.
|
27
|
+
|
28
|
+
-w <str> Weights file: A two-columns tab-delimited file containing the
|
29
|
+
name (column 1) and the weight (column 2) of each query.
|
30
|
+
-s <float> Minimum score. By default: 0.
|
31
|
+
-i <float> Minimum identity (in percentage). By default: 0.
|
32
|
+
-m <int> Maximum number of queries. Set to 0 for all. By default: 0.
|
33
|
+
-n Normalize weights by the number of hits per query.
|
34
|
+
-z Add zero when weight is not found (by default: doesn't list
|
35
|
+
them).
|
36
|
+
-q Run quietly.
|
37
|
+
-h Display this message and exit.
|
38
|
+
|
39
|
+
* Mandatory
|
40
|
+
|
41
|
+
.Note:
|
42
|
+
The weights (-w parameter) are optional, but its use is encouraged. When
|
43
|
+
weights are not passed, the script simply assumes all queries to be equally
|
44
|
+
weighted (unity), a result that can be faster to compute with, for example:
|
45
|
+
cat blast | cut -f 2 | sort | uniq -c | awk '{print \$2\"\\t\"\$1}' > out
|
46
|
+
It is equivalent to simply count the number of times that each subject
|
47
|
+
occurs.
|
48
|
+
"
|
49
|
+
}
|
50
|
+
|
51
|
+
my %o = ();
|
52
|
+
getopts('w:s:i:m:znqh', \%o);
|
53
|
+
$o{h} and &HELP_MESSAGE;
|
54
|
+
$o{s}||=0;
|
55
|
+
$o{i}||=0;
|
56
|
+
$o{m}||=0;
|
57
|
+
|
58
|
+
my %count;
|
59
|
+
if($o{w}){
|
60
|
+
print STDERR "Reading counts.\n" unless $o{q};
|
61
|
+
open COUNT, "<", $o{w} or die "Cannot open file: $o{w}: $!\n";
|
62
|
+
%count = map {split /\t/} <COUNT>;
|
63
|
+
close COUNT;
|
64
|
+
}
|
65
|
+
|
66
|
+
print STDERR "Reading BLASTs.\n" unless $o{q};
|
67
|
+
my $qry = '';
|
68
|
+
my $hits = 0;
|
69
|
+
my @buf = ();
|
70
|
+
my $qries = 0;
|
71
|
+
my $noQry = 0;
|
72
|
+
my $ln1 = 0;
|
73
|
+
my %out = ();
|
74
|
+
BFILE: for my $blast (@ARGV){
|
75
|
+
print STDERR " o $blast\n" unless $o{q};
|
76
|
+
open BLAST, "<", $blast or die "Cannot open file: $blast: $!\n";
|
77
|
+
BLINE: while(<BLAST>){
|
78
|
+
chomp;
|
79
|
+
my @ln = split /\t/;
|
80
|
+
$ln1 ||= $#ln;
|
81
|
+
die "Bad line $.: $_\n" unless $#ln==$ln1;
|
82
|
+
next if ($o{s} and $ln[11]<$o{s}) or ($o{i} and $ln[2]<$o{i});
|
83
|
+
unless(exists $count{$ln[0]}){
|
84
|
+
$noQry++;
|
85
|
+
if(not $o{w}){
|
86
|
+
$count{$ln[0]}=1;
|
87
|
+
}elsif($o{z}){
|
88
|
+
$count{$ln[0]}=0;
|
89
|
+
}else{
|
90
|
+
next BLINE;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
if($qry ne $ln[0]){
|
95
|
+
$qries++;
|
96
|
+
($out{$_->[0]}||=0) += ($_->[1]/($o{n}?$hits:1)) for @buf;
|
97
|
+
last BFILE if $o{m} and $qries >= $o{m};
|
98
|
+
@buf = ();
|
99
|
+
$qry = $ln[0];
|
100
|
+
$hits = 0;
|
101
|
+
}
|
102
|
+
|
103
|
+
push @buf, [$ln[1], $count{$ln[0]}];
|
104
|
+
$hits++;
|
105
|
+
}
|
106
|
+
($out{$_->[0]}||=0) += ($_->[1]/($o{n}?$hits:1)) for @buf;
|
107
|
+
close BLAST;
|
108
|
+
}
|
109
|
+
print STDERR "Warning: Couldn't find $noQry queries\n" if $noQry and $o{w};
|
110
|
+
|
111
|
+
for my $h (keys %out){
|
112
|
+
print "$h\t".$out{$h}."\n";
|
113
|
+
}
|
114
|
+
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/usr/bin/env perl
|
2
|
+
#
|
3
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
4
|
+
# @license artistic 2.0
|
5
|
+
# @update Oct-13-2015
|
6
|
+
#
|
7
|
+
|
8
|
+
use warnings;
|
9
|
+
use strict;
|
10
|
+
|
11
|
+
my($blast, $nodes, $names, $rank, $bh) = @ARGV;
|
12
|
+
($blast and $nodes and $names) or die <<HELP
|
13
|
+
|
14
|
+
Takes a BLAST with NCBI Taxonomy IDs as subjects and replaces them by names at a
|
15
|
+
given taxonomic rank.
|
16
|
+
|
17
|
+
Usage:
|
18
|
+
$0 tax_blast.txt nodes.dmp names.dmp[ rank[ best-hit]] > taxrank_blast.txt
|
19
|
+
|
20
|
+
tax_blast.txt BLAST output, where subject IDs are NCBI Taxonomy IDs.
|
21
|
+
nodes.dmp Nodes file from NCBI Taxonomy*.
|
22
|
+
names.dmp Names file from NCBI Taxonomy*.
|
23
|
+
rank The rank to be reported. All the reported nodes will
|
24
|
+
have the same rank. By default, genus. To see
|
25
|
+
supported values, run:
|
26
|
+
cut -f 5 nodes.dmp | sort -u
|
27
|
+
best-hit A word (yes or no) telling the program whether or not it
|
28
|
+
should take into account the best hit per query only.
|
29
|
+
By default: yes.
|
30
|
+
taxrank_list.txt BLAST-like output, where subject IDs are Taxonomy names.
|
31
|
+
|
32
|
+
* Download from ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz
|
33
|
+
|
34
|
+
HELP
|
35
|
+
;
|
36
|
+
$rank ||= "genus";
|
37
|
+
$bh ||= "yes";
|
38
|
+
|
39
|
+
# %nodes structure:
|
40
|
+
# taxid => [parent's taxid, rank, nil, name, name type]
|
41
|
+
|
42
|
+
print STDERR "Reading $nodes.\n";
|
43
|
+
open NODES, "<", $nodes or die "Cannot read file: $nodes: $!\n";
|
44
|
+
my %nodes = map { my @a=split /\t\|\t/; ($a[0] => [$a[1], $a[2]]) } <NODES>;
|
45
|
+
close NODES;
|
46
|
+
|
47
|
+
print STDERR "Reading $names.\n";
|
48
|
+
open NAMES, "<", $names or die "Cannot read file: $names: $!\n";
|
49
|
+
while(<NAMES>){
|
50
|
+
my @a=split /\t\|\t/;
|
51
|
+
next if exists $nodes{$a[0]}->[3] and
|
52
|
+
$nodes{$a[0]}->[4] eq "scientific name";
|
53
|
+
next if exists $nodes{$a[0]}->[3] and
|
54
|
+
$a[3] ne "scientific name";
|
55
|
+
$nodes{$a[0]}->[3] = $a[1];
|
56
|
+
$nodes{$a[0]}->[4] = $a[3];
|
57
|
+
}
|
58
|
+
close NAMES;
|
59
|
+
|
60
|
+
my $i = 0;
|
61
|
+
my $nomap = 0;
|
62
|
+
my $qry = "";
|
63
|
+
open BLAST, "<", $blast or die "Cannot read file: $blast: $!\n";
|
64
|
+
HIT:while(<BLAST>){
|
65
|
+
if(/^#/){
|
66
|
+
print $_;
|
67
|
+
next;
|
68
|
+
}
|
69
|
+
chomp;
|
70
|
+
my @row = split /\t/;
|
71
|
+
next if $bh eq "yes" and $row[0] eq $qry;
|
72
|
+
$i++;
|
73
|
+
print STDERR " Mapping hit $i\r" unless $i%10;
|
74
|
+
exists $nodes{$row[1]} or die "Cannot find Taxonomy node: $row[1].\n";
|
75
|
+
my $n = $nodes{$row[1]};
|
76
|
+
while($n->[1] ne $rank){
|
77
|
+
if($n->[0] eq $nodes{$n->[0]}->[0]){
|
78
|
+
$nomap++;
|
79
|
+
next HIT;
|
80
|
+
}
|
81
|
+
$n = $nodes{$n->[0]};
|
82
|
+
}
|
83
|
+
$row[1] = $n->[3];
|
84
|
+
print "".join("\t", @row)."\n";
|
85
|
+
}
|
86
|
+
close BLAST;
|
87
|
+
print STDERR " Mapped $i hits\n";
|
88
|
+
print STDERR
|
89
|
+
" WARNING: $nomap hits above rank or in a lineage without rank.\n" if $nomap;
|
90
|
+
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# @author: Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @update: Dec-11-2015
|
6
|
+
# @license: artistic license 2.0
|
7
|
+
#
|
8
|
+
|
9
|
+
require "optparse"
|
10
|
+
|
11
|
+
$opts = {n:5, sortby:"bitscore", q:false}
|
12
|
+
$cols = {"bitscore"=>11, "evalue"=>10, "identity"=>2, "length"=>3}
|
13
|
+
ARGV << "-h" if ARGV.size==0
|
14
|
+
OptionParser.new do |opts|
|
15
|
+
opts.banner = "Reports the top-N best hits of a BLAST, pre-sorted by query."
|
16
|
+
opts.separator ""
|
17
|
+
opts.separator "Mandatory"
|
18
|
+
opts.on("-i", "--blast FILE",
|
19
|
+
"Path to the BLAST file."){ |v| $opts[:blast]=v }
|
20
|
+
opts.separator ""
|
21
|
+
opts.separator "Optional"
|
22
|
+
opts.on("-n", "--top INTEGER",
|
23
|
+
"Maximum number of hits to report for each query.",
|
24
|
+
"By default: #{$opts[:n]}"){ |v| $opts[:n]=v.to_i }
|
25
|
+
opts.on("-s", "--sort-by STRING",
|
26
|
+
"Parameter used to detect the 'best' hits.",
|
27
|
+
"Any of: bitscore (default), evalue, identity, length."
|
28
|
+
){ |v| $opts[:sortby]=v }
|
29
|
+
opts.on("-q", "--quiet", "Run quietly."){ $opts[:q]=true }
|
30
|
+
opts.on("-h", "--help", "Display this screen") do
|
31
|
+
puts opts
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
opts.separator ""
|
35
|
+
end.parse!
|
36
|
+
|
37
|
+
abort "-i/--blast is mandatory." if $opts[:blast].nil?
|
38
|
+
abort "Unrecognized value for -s/--sortby: #{$opts[:sortby]}." if
|
39
|
+
$cols[ $opts[:sortby] ].nil?
|
40
|
+
|
41
|
+
class Hit
|
42
|
+
attr_reader :blast_line
|
43
|
+
def initialize(blast_line)
|
44
|
+
@blast_line = blast_line.chomp.split(/\t/)
|
45
|
+
end
|
46
|
+
def col(i)
|
47
|
+
@blast_line[i]
|
48
|
+
end
|
49
|
+
def <=>(other)
|
50
|
+
ans = self.col( $cols[ $opts[:sortby] ] ).to_f <=> other.col( $cols[ $opts[:sortby] ] ).to_f
|
51
|
+
ans = ans * -1 unless $opts[:sortby] == "evalue"
|
52
|
+
return ans
|
53
|
+
end
|
54
|
+
def to_s
|
55
|
+
@blast_line.join("\t")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class HitSet
|
60
|
+
attr_reader :query, :hits
|
61
|
+
def initialize
|
62
|
+
@hits = []
|
63
|
+
@query = nil
|
64
|
+
end
|
65
|
+
def <<(hit)
|
66
|
+
@query = hit.col(0) if @query.nil?
|
67
|
+
raise "Inconsistent query, expecting #{self.query}" unless
|
68
|
+
self.query == hit.col(0)
|
69
|
+
@hits << hit
|
70
|
+
end
|
71
|
+
def empty?
|
72
|
+
self.hits.length == 0
|
73
|
+
end
|
74
|
+
def filter!
|
75
|
+
@hits.sort!
|
76
|
+
@hits.slice!($opts[:n], @hits.length)
|
77
|
+
end
|
78
|
+
def to_s
|
79
|
+
@hits.join("\n")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
$stderr.puts "Parsing BLAST." unless $opts[:q]
|
84
|
+
fh = File.open $opts[:blast], "r"
|
85
|
+
hs = HitSet.new
|
86
|
+
while ln=fh.gets
|
87
|
+
hit = Hit.new( ln )
|
88
|
+
if hs.query != hit.col(0)
|
89
|
+
hs.filter!
|
90
|
+
puts hs unless hs.empty?
|
91
|
+
hs = HitSet.new
|
92
|
+
$stderr.print "Parsing line #{$.}... \r" unless $opts[:q]
|
93
|
+
end
|
94
|
+
hs << hit
|
95
|
+
end
|
96
|
+
$stderr.print "Parsed #{$.} lines. \n" unless $opts[:q]
|
97
|
+
fh.close
|
98
|
+
|
99
|
+
hs.filter!
|
100
|
+
puts hs unless hs.empty?
|
101
|
+
|
@@ -0,0 +1,97 @@
|
|
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 Dec-29-2015
|
6
|
+
#
|
7
|
+
|
8
|
+
use warnings;
|
9
|
+
use strict;
|
10
|
+
use Getopt::Std;
|
11
|
+
use List::Util qw/min max/;
|
12
|
+
|
13
|
+
sub VERSION_MESSAGE(){print "Home-made Chao1 (enveomics)\n"}
|
14
|
+
sub HELP_MESSAGE(){die "
|
15
|
+
Description:
|
16
|
+
Takes a table of OTU abundance in one or more samples and calculates the
|
17
|
+
chao1 index (with 95% Confidence Interval) for each sample. To use it with
|
18
|
+
Qiime OTU Tables, run it as:
|
19
|
+
$0 -i OTU_Table.txt -c 1 -h
|
20
|
+
|
21
|
+
Usage:
|
22
|
+
$0 [opts]
|
23
|
+
|
24
|
+
-i <str> * Input table (columns:samples, rows:OTUs).
|
25
|
+
-r <int> Number of rows to ignore. By default: 0.
|
26
|
+
-c <int> Number of columns to ignore. By default: 0.
|
27
|
+
-C <int> Number of columns to ignore at the end. By default: 0.
|
28
|
+
-d <str> Delimiter. Supported escaped characters are: \"\\t\"
|
29
|
+
(tabulation), and \"\\0\" (null bit). By default: \"\\t\".
|
30
|
+
-h If set, the first row is assumed to have the names of the
|
31
|
+
samples.
|
32
|
+
--help This help message.
|
33
|
+
|
34
|
+
* Mandatory.
|
35
|
+
|
36
|
+
To improve:
|
37
|
+
o Account for n1==0 and n2==0 cases. See http://www.mothur.org/wiki/Chao.
|
38
|
+
|
39
|
+
"}
|
40
|
+
|
41
|
+
my %o;
|
42
|
+
getopts('i:c:C:r:d:h', \%o);
|
43
|
+
|
44
|
+
&HELP_MESSAGE() unless $o{i};
|
45
|
+
$o{c} ||= 0;
|
46
|
+
$o{C} ||= 0;
|
47
|
+
$o{r} ||= 0;
|
48
|
+
$o{d} ||= "\\t";
|
49
|
+
|
50
|
+
$o{d}="\t" if $o{d} eq "\\t";
|
51
|
+
$o{d}="\0" if $o{d} eq "\\0";
|
52
|
+
|
53
|
+
my @names = ();
|
54
|
+
my @values = ();
|
55
|
+
open TABLE, "<", $o{i} or die "Cannot open file: ".$o{i}.": $!\n";
|
56
|
+
<TABLE> for (1 .. $o{r});
|
57
|
+
if($o{h}){
|
58
|
+
my $h = <TABLE>;
|
59
|
+
$h or die "Empty table!\n";
|
60
|
+
chomp $h;
|
61
|
+
@names = split $o{d}, $h;
|
62
|
+
shift @names for (1 .. $o{c});
|
63
|
+
pop @names for (1 .. $o{C});
|
64
|
+
}
|
65
|
+
while(<TABLE>){
|
66
|
+
chomp;
|
67
|
+
my @ln = split $o{d};
|
68
|
+
shift @ln for (1 .. $o{c});
|
69
|
+
pop @ln for (1 .. $o{C});
|
70
|
+
push @{$values[$_] ||= []}, $ln[$_] for (0 .. $#ln);
|
71
|
+
}
|
72
|
+
close TABLE;
|
73
|
+
|
74
|
+
print "Sample\tObs\tChao1\tChao1_LB\tChao1_UL\n";
|
75
|
+
for my $i (0 .. $#values){
|
76
|
+
print "".(exists $names[$i] ? $names[$i] : $i).$o{d};
|
77
|
+
my $n1=0;
|
78
|
+
my $n2=0;
|
79
|
+
my $ob=0;
|
80
|
+
for my $v (@{$values[$i]}){
|
81
|
+
$n1++ if $v==1;
|
82
|
+
$n2++ if $v==2;
|
83
|
+
$ob++ if $v>=1;
|
84
|
+
}
|
85
|
+
if($ob and $n1 and $n2){
|
86
|
+
my $m = $n1/$n2;
|
87
|
+
my $ch = $ob + (($n1**2)/(2*$n2));
|
88
|
+
my $var = ($n2*((($m**4)/4) + ($m**3) + (($m**2)/2)));
|
89
|
+
my $c = exp(1.96*sqrt(log(1+ $var/(($ch-$ob)**2))));
|
90
|
+
my $lc = max($ob + ($ch-$ob)/$c, $ob);
|
91
|
+
my $uc = $ob + $c*($ch-$ob);
|
92
|
+
print "".join($o{d}, $ob, $ch, $lc, $uc)."\n"
|
93
|
+
}else{
|
94
|
+
print "".join($o{d}, $ob, $ob, 0, 0)."\n"
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|