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,90 @@
|
|
1
|
+
#!/usr/bin/env perl
|
2
|
+
#
|
3
|
+
# @author Luis M. Rodriguez-R
|
4
|
+
# @version 2.0
|
5
|
+
# @update: Mar-23-2015
|
6
|
+
# @license artistic license 2.0
|
7
|
+
#
|
8
|
+
# Usage: FastQ.interpose.pl <output_fastq> <input_fastq_1> <input_fastq_2> [additional input files...]
|
9
|
+
|
10
|
+
use strict;
|
11
|
+
use warnings;
|
12
|
+
use Symbol;
|
13
|
+
|
14
|
+
my $HELP = <<HELP
|
15
|
+
|
16
|
+
Description:
|
17
|
+
Interposes sequences in FastQ format from two files into one output file. If more than two files are
|
18
|
+
provided, the script will interpose all the input files.
|
19
|
+
Note that this script will check for the consistency of the names (assuming a pair of related reads
|
20
|
+
contains the same name varying only in a trailing slash (/) followed by a digit. If you want to turn
|
21
|
+
this feature off just set the -T option to zero. If you want to decrease the sampling period
|
22
|
+
(to speed the script up) or increase it (to make it more sensitive to errors) just change -T option
|
23
|
+
accordingly.
|
24
|
+
|
25
|
+
Usage:
|
26
|
+
$0 [-T <int> ]<output_fastq> <input_fastq_1> <input_fastq_2> [additional input files...]
|
27
|
+
|
28
|
+
Where,
|
29
|
+
-T <int> : Optional. Integer indicating the sampling period for names evaluation (see
|
30
|
+
Description above). By default: 1000.
|
31
|
+
output_fastq : Output file
|
32
|
+
input_fastq_1 : First FastQ file
|
33
|
+
input_fastq_2 : Second FastQ file
|
34
|
+
... : Any additional FastQ files (or none)
|
35
|
+
|
36
|
+
HELP
|
37
|
+
;
|
38
|
+
my $eval_T = 1000;
|
39
|
+
if(exists $ARGV[0] and exists $ARGV[1] and $ARGV[0] eq '-T'){
|
40
|
+
$eval_T = $ARGV[1]+0;
|
41
|
+
shift @ARGV;
|
42
|
+
shift @ARGV;
|
43
|
+
}
|
44
|
+
my $out = shift @ARGV;
|
45
|
+
my @in = @ARGV;
|
46
|
+
|
47
|
+
die $HELP unless $out and $#in >= 1;
|
48
|
+
open OUT, ">", $out or die "Unable to write on $out: $!\n";
|
49
|
+
print "Output file: $out\n";
|
50
|
+
|
51
|
+
my @in_fh = ();
|
52
|
+
|
53
|
+
for my $k (0 .. $#in) {
|
54
|
+
$in_fh[$k] = gensym;
|
55
|
+
open $in_fh[$k], "<", $in[$k] or die "Unable to read $in[$k]: $!\n";
|
56
|
+
print "Input file: $in[$k]\n";
|
57
|
+
}
|
58
|
+
|
59
|
+
my $i = 0;
|
60
|
+
my $frl;
|
61
|
+
LINE: while(1){
|
62
|
+
my $name = "";
|
63
|
+
print STDERR "\rEntry: $i " unless $i % 1000;
|
64
|
+
FILE: for my $k (0 .. $#in_fh){
|
65
|
+
my @ln = ();
|
66
|
+
for my $l (0 .. 3){
|
67
|
+
$ln[$l] = readline($in_fh[$k]);
|
68
|
+
last LINE if $k==0 and $l==0 and (not defined $ln[$l]);
|
69
|
+
defined $ln[$l] or die "Impossible to read next entry (line $.) from $in[$k]: $!\n";
|
70
|
+
chomp $ln[$l];
|
71
|
+
}
|
72
|
+
if($eval_T and not $i % $eval_T){
|
73
|
+
$ln[0] =~ m/^\@(.*?)\/\d+\s*$/ or die "Impossible to evaluate names!\n offending entry:\n$ln[0]\n";
|
74
|
+
$name ||= $1;
|
75
|
+
die "Inconsistent name!\n base name is $name\n offending entry is:\n$ln[0]\n" unless $1 eq $name;
|
76
|
+
}
|
77
|
+
unless($frl){
|
78
|
+
$ln[0] =~ /^@/ or die "Unexpected format! (missing @)\n offending entry: $ln[0].\n";
|
79
|
+
$ln[2] =~ /^\+/ or die "Unexpected format! (missing +)\n offending entry: $ln[0].\n";
|
80
|
+
$frl = length $ln[1];
|
81
|
+
}
|
82
|
+
print OUT "".join("\n", @ln, "");
|
83
|
+
}
|
84
|
+
$i++;
|
85
|
+
}
|
86
|
+
print "\rNumber of entries: $i \nFirst read length: $frl\n";
|
87
|
+
close OUT;
|
88
|
+
|
89
|
+
for my $k(0..$#in_fh){print "ALERT: The file $in[$k] contains trailing entries\n" if defined readline($in_fh[$k])}
|
90
|
+
|
@@ -0,0 +1,90 @@
|
|
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 ($in, $off, $force) = @ARGV;
|
12
|
+
$in or die "
|
13
|
+
.Description:
|
14
|
+
There are several FastQ formats (see http://en.wikipedia.org/wiki/FASTQ_format).
|
15
|
+
This script takes a FastQ in any of them, identifies the type of FastQ (this is,
|
16
|
+
the offset), and generates a FastQ with the given offset. Note that Solexa+64
|
17
|
+
FastQ can cause problematic values when using the offset 33, since there is no
|
18
|
+
equivalent in Phred+33 for negative values (the range of Solexa+64 is -5 to 40).
|
19
|
+
|
20
|
+
.Usage:
|
21
|
+
$0 in.fastq[ offset[ force]] > out.fastq
|
22
|
+
|
23
|
+
in.fastq Input file in FastQ format (range is automatically detected).
|
24
|
+
offset (optional) Offset to use for the output. Use 0 (zero) to detect
|
25
|
+
the input format and exit. By default: 33.
|
26
|
+
force (optional) If true, turns errors into warnings and continues.
|
27
|
+
Out-of-range values are set to the closest range limit.
|
28
|
+
out.fastq Output file in FastQ format with the specified offset.
|
29
|
+
|
30
|
+
";
|
31
|
+
|
32
|
+
$off = 33 unless defined $off;
|
33
|
+
|
34
|
+
my $in_off = 0;
|
35
|
+
open IN, "<", $in or die "Cannot read file: $in: $!\n";
|
36
|
+
GUESS_FORMAT: while(<IN>){
|
37
|
+
unless($.%4){
|
38
|
+
chomp;
|
39
|
+
for my $chr (split //){
|
40
|
+
my $o = ord $chr;
|
41
|
+
if($o < 55){
|
42
|
+
$in_off = 33;
|
43
|
+
last GUESS_FORMAT;
|
44
|
+
}elsif($o > 80){
|
45
|
+
$in_off = 64;
|
46
|
+
last GUESS_FORMAT;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
close IN;
|
52
|
+
print STDERR "Detected input offset: Phred+$in_off\n";
|
53
|
+
exit unless $off;
|
54
|
+
|
55
|
+
my $Solexa64=0;
|
56
|
+
die "Couldn't guess input format.\n" unless $in_off;
|
57
|
+
open IN, "<", $in or die "Cannot read file: $in: $!\n";
|
58
|
+
while(<IN>){
|
59
|
+
if($in_off==$off or $.%4){
|
60
|
+
print $_;
|
61
|
+
}else{
|
62
|
+
chomp;
|
63
|
+
for my $chr (split //){
|
64
|
+
my $score = ord($chr) - $in_off;
|
65
|
+
my $err = '';
|
66
|
+
if($score < -5){
|
67
|
+
$err = "Out-of-range value $chr ($score) in line $..\n";
|
68
|
+
$score = $off==64 ? -5 : 0;
|
69
|
+
}elsif(!$Solexa64 and $score < 0){
|
70
|
+
if($in_off==64){
|
71
|
+
print STDERR "Format variant: Solexa+64\n";
|
72
|
+
$Solexa64 = 1;
|
73
|
+
}else{
|
74
|
+
$err = "Out-of-range value $chr ($score) in line $..\n";
|
75
|
+
$score = 0;
|
76
|
+
}
|
77
|
+
}elsif($score>41){
|
78
|
+
$err = "Out-of-range value $chr ($score) in line $..\n";
|
79
|
+
$score = 41;
|
80
|
+
}
|
81
|
+
if($err){
|
82
|
+
if($force){ warn $err } else { die $err }
|
83
|
+
}
|
84
|
+
print chr( $score + $off );
|
85
|
+
}
|
86
|
+
print "\n";
|
87
|
+
}
|
88
|
+
}
|
89
|
+
close IN;
|
90
|
+
|
@@ -0,0 +1,53 @@
|
|
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 Jul-05-2015
|
6
|
+
#
|
7
|
+
|
8
|
+
use warnings;
|
9
|
+
use strict;
|
10
|
+
use Symbol;
|
11
|
+
|
12
|
+
my ($file, $base, $outN) = @ARGV;
|
13
|
+
|
14
|
+
$outN ||= 2;
|
15
|
+
($file and $base) or die "
|
16
|
+
Usage
|
17
|
+
$0 in_file.fq out_base[ no_files]
|
18
|
+
|
19
|
+
in_file.fq Input file in FastA format.
|
20
|
+
out_base Prefix for the name of the output files. It will
|
21
|
+
be appended with .<i>.fastq, where <i> is a consecutive
|
22
|
+
number starting in 1.
|
23
|
+
no_files Number of files to generate. By default: 2.
|
24
|
+
|
25
|
+
";
|
26
|
+
|
27
|
+
|
28
|
+
my @outSym = ();
|
29
|
+
for my $i (1 .. $outN){
|
30
|
+
$outSym[$i-1] = gensym;
|
31
|
+
open $outSym[$i-1], ">", "$base.$i.fastq" or die "I can not create the file: $base.$i.fa: $!\n";
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
my($i, $seq) = (-1, '');
|
36
|
+
open FILE, "<", $file or die "I can not read the file: $file: $!\n";
|
37
|
+
while(my $ln=<FILE>){
|
38
|
+
if($.%4 == 1){
|
39
|
+
print { $outSym[$i % $outN] } $seq if $seq;
|
40
|
+
$i++;
|
41
|
+
$seq = '';
|
42
|
+
}
|
43
|
+
$seq.=$ln;
|
44
|
+
}
|
45
|
+
print { $outSym[$i % $outN] } $seq if $seq;
|
46
|
+
close FILE;
|
47
|
+
|
48
|
+
for(my $j=0; $j<$outN; $j++){
|
49
|
+
close $outSym[$j];
|
50
|
+
}
|
51
|
+
|
52
|
+
print STDERR "Sequences: ".($i+1)."\nFiles: $outN\n";
|
53
|
+
|
@@ -0,0 +1,63 @@
|
|
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
|
+
|
11
|
+
o = {:q=>FALSE, :p=>"", :s=>""}
|
12
|
+
ARGV << '-h' if ARGV.size==0
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.banner = "
|
15
|
+
Generates easy-to-parse tagged reads from FastQ files.
|
16
|
+
|
17
|
+
Usage: #{$0} [options]"
|
18
|
+
opts.separator ""
|
19
|
+
opts.separator "Mandatory"
|
20
|
+
opts.on("-i", "--in FILE", "Path to the FastQ file containing the sequences."){ |v| o[:in] = v }
|
21
|
+
opts.on("-o", "--out FILE", "Path to the FastQ to create."){ |v| o[:out] = v }
|
22
|
+
opts.separator ""
|
23
|
+
opts.separator "ID options"
|
24
|
+
opts.on("-p", "--prefix STR", "Prefix to use in all IDs."){ |v| o[:p] = v }
|
25
|
+
opts.on("-s", "--suffix STR", "Suffix to use in all IDs."){ |v| o[:s] = v }
|
26
|
+
opts.separator ""
|
27
|
+
opts.separator "Other Options"
|
28
|
+
opts.on("-q", "--quiet", "Run quietly (no STDERR output)"){ o[:q] = TRUE }
|
29
|
+
opts.on("-h", "--help", "Display this screen") do
|
30
|
+
puts opts
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
opts.separator ""
|
34
|
+
end.parse!
|
35
|
+
abort "-i is mandatory" if o[:in].nil?
|
36
|
+
abort "-o is mandatory" if o[:out].nil?
|
37
|
+
|
38
|
+
begin
|
39
|
+
ifh = File.open(o[:in], 'r');
|
40
|
+
ofh = File.open(o[:out], 'w');
|
41
|
+
i=0
|
42
|
+
while ln=ifh.gets
|
43
|
+
ln.chomp!
|
44
|
+
if $.%4==1 and not /^@/.match(ln).nil?
|
45
|
+
i+=1
|
46
|
+
ofh.puts "@#{o[:p]}#{i}#{o[:s]}"
|
47
|
+
elsif $.%4==2 or $.%4==0
|
48
|
+
ofh.puts ln
|
49
|
+
elsif $.%4==3 and not /^\+/.match(ln).nil?
|
50
|
+
ofh.puts "+"
|
51
|
+
else
|
52
|
+
abort "Impossible to parse line #{$.}: #{ln}.\n"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
ifh.close
|
56
|
+
ofh.close
|
57
|
+
rescue => err
|
58
|
+
$stderr.puts "Exception: #{err}\n\n"
|
59
|
+
err.backtrace.each { |l| $stderr.puts l + "\n" }
|
60
|
+
err
|
61
|
+
end
|
62
|
+
|
63
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env awk -f
|
2
|
+
#
|
3
|
+
# @author Luis M. Rodriguez-R
|
4
|
+
# @update Dec-26-2015
|
5
|
+
# @license artistic license 2.0
|
6
|
+
#
|
7
|
+
|
8
|
+
BEGIN {
|
9
|
+
for (i = 0; i < ARGC; i++) {
|
10
|
+
if(ARGV[i] == "--help"){
|
11
|
+
print "Description:\n"
|
12
|
+
print " Translates FastQ files into FastA.\n"
|
13
|
+
print "Usage:\n"
|
14
|
+
print " FastQ.toFastA.awk < in.fq > out.fa\n"
|
15
|
+
exit
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
NR%4 == 1, NR%4 == 2 {
|
21
|
+
if(NR%4 == 1){ gsub(/^@/,">") }
|
22
|
+
print $0
|
23
|
+
}
|
24
|
+
|
@@ -0,0 +1,84 @@
|
|
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
|
+
|
11
|
+
o = {:q=>FALSE, :k=>1, :split=>"#"}
|
12
|
+
ARGV << '-h' if ARGV.size==0
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.banner = "
|
15
|
+
Adds annotations to GenBank files.
|
16
|
+
|
17
|
+
Usage: #{$0} [options]"
|
18
|
+
opts.separator ""
|
19
|
+
opts.separator "Mandatory"
|
20
|
+
opts.on("-g", "--genbank FILE", "Input GenBank file."){ |v| o[:gb]=v }
|
21
|
+
opts.on("-t", "--table FILE", "Input file containing the annotations. It must be a ",
|
22
|
+
"tab-delimited raw table including a header row with ",
|
23
|
+
"the names of the fields."){ |v| o[:table]=v }
|
24
|
+
opts.on("-o", "--out FILE", "Output file containing the annotated GenBank."){ |v| o[:out]=v }
|
25
|
+
opts.separator ""
|
26
|
+
opts.separator "Other Options"
|
27
|
+
opts.on("-k", "--key NUMBER", "Key of the column to use as identifier. By default: #{o[:k]}"){ |v| o[:k] = v.to_i }
|
28
|
+
opts.on("-s", "--split STRING", "String that separates multiple entries in the annotation features. By default: \"#{o[:split]}\""){ |v| o[:k] = v.to_i }
|
29
|
+
opts.on("-q", "--quiet", "Run quietly (no STDERR output)."){ o[: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
|
+
abort "-g is mandatory" if o[:gb].nil?
|
37
|
+
abort "-t is mandatory" if o[:table].nil?
|
38
|
+
abort "-o is mandatory" if o[:out].nil?
|
39
|
+
|
40
|
+
##### MAIN:
|
41
|
+
begin
|
42
|
+
puts "Reading annotation table: #{o[:table]}." unless o[:q]
|
43
|
+
ifh = File.open(o[:table], "r")
|
44
|
+
header = ifh.gets.chomp.split(/\t/)
|
45
|
+
puts " * using #{header[ o[:k]-1 ]} column as feature identifier."
|
46
|
+
annot = {}
|
47
|
+
while ln=ifh.gets
|
48
|
+
row = ln.chomp.split(/\t/)
|
49
|
+
warn "WARNING: #{header[ o[:k]-1 ]} #{row[ o[:k]-1 ]} found more than once." unless annot[ row[ o[:k]-1 ] ].nil?
|
50
|
+
annot[ row[ o[:k]-1 ] ] = row
|
51
|
+
end
|
52
|
+
ifh.close
|
53
|
+
puts " * found #{annot.size} annotation entries with #{header.size} fields." unless o[:q]
|
54
|
+
puts "Annotating GenBank." unless o[:q]
|
55
|
+
ifh = File.open(o[:gb], "r")
|
56
|
+
ofh = File.open(o[:out], "w")
|
57
|
+
found = 0
|
58
|
+
notfound = 0
|
59
|
+
while ln=ifh.gets
|
60
|
+
ofh.print ln
|
61
|
+
m = /^(?<sp>\s+)\/#{header[ o[:k]-1 ]}="(?<id>.+)"/.match(ln)
|
62
|
+
next if m.nil?
|
63
|
+
if annot[ m[:id] ].nil?
|
64
|
+
notfound += 1
|
65
|
+
next
|
66
|
+
end
|
67
|
+
found += 1
|
68
|
+
annot[ m[:id] ].each_index do |i|
|
69
|
+
next if i == o[:k]-1 or annot[ m[:id] ][i]==""
|
70
|
+
annot[ m[:id] ][i].split(/#{o[:split]}/).each{ |v| ofh.puts "#{m[:sp]}/#{header[i]}=\"#{v}\"" }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
ofh.close
|
74
|
+
ifh.close
|
75
|
+
puts " * annotated #{found} features." unless o[:q]
|
76
|
+
puts " * couldn't find #{notfound} features in the annotation table." unless o[:q] or notfound==0
|
77
|
+
$stderr.puts "Done.\n" unless o[:q]
|
78
|
+
rescue => err
|
79
|
+
$stderr.puts "Exception: #{err}\n\n"
|
80
|
+
err.backtrace.each { |l| $stderr.puts l + "\n" }
|
81
|
+
err
|
82
|
+
end
|
83
|
+
|
84
|
+
|
@@ -0,0 +1,254 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# @author Luis M. Rodriguez-R
|
5
|
+
# @license artistic license 2.0
|
6
|
+
# @update Mar-23-2016
|
7
|
+
#
|
8
|
+
|
9
|
+
$:.push File.expand_path("../lib", __FILE__)
|
10
|
+
require "enveomics_rb/enveomics"
|
11
|
+
use "tmpdir"
|
12
|
+
use "zlib"
|
13
|
+
|
14
|
+
o = {bin:"", thr:2, q:false, stats:true, genes:true, bacteria:false,
|
15
|
+
archaea:false, genomeeq:false, metagenome:false, list:false}
|
16
|
+
OptionParser.new do |opts|
|
17
|
+
opts.banner = "
|
18
|
+
Finds and extracts a collection of essential proteins suitable for genome
|
19
|
+
completeness evaluation and phylogenetic analyses. Important note: most complete
|
20
|
+
bacterial genomes contain only 106/111 genes in this collection, therefore
|
21
|
+
producing a completeness of 95.5%, and most archaeal genomes only contain 26/111
|
22
|
+
genes, producing a completeness of 23.4%. Use the options --bacteria and/or
|
23
|
+
--archaea to ignore models often missing in one or both domains. Note that even
|
24
|
+
with these options, some complete archaeal genomes result in very low values of
|
25
|
+
completeness (e.g., Nanoarchaeum equitans returns 88.5%).
|
26
|
+
|
27
|
+
Requires HMMer 3.0+ (http://hmmer.janelia.org/software).
|
28
|
+
|
29
|
+
Usage: #{$0} [options]"
|
30
|
+
opts.separator ""
|
31
|
+
opts.separator "Mandatory"
|
32
|
+
opts.on("-i", "--in FILE",
|
33
|
+
"Path to the FastA file containing all the proteins in a genome."
|
34
|
+
){ |v| o[:in] = v }
|
35
|
+
opts.separator ""
|
36
|
+
opts.separator "Report Options"
|
37
|
+
opts.on("-o", "--out FILE",
|
38
|
+
"Path to the output FastA file with the translated essential genes.",
|
39
|
+
"By default the file is not produced."){ |v| o[:out] = v }
|
40
|
+
opts.on("-m", "--per-model STR",
|
41
|
+
"Prefix of translated genes in independent files with the name of the",
|
42
|
+
"model appended. By default files are not produced."
|
43
|
+
){ |v| o[:permodel] = v }
|
44
|
+
opts.on("-R", "--report FILE",
|
45
|
+
"Path to the report file. By default, the report is sent to the STDOUT."
|
46
|
+
){ |v| o[:report] = v }
|
47
|
+
opts.on("-B", "--bacteria",
|
48
|
+
"If set, ignores models typically missing in Bacteria."
|
49
|
+
){ |v| o[:bacteria] = v }
|
50
|
+
opts.on("-A", "--archaea",
|
51
|
+
"If set, ignores models typically missing in Archaea."
|
52
|
+
){ |v| o[:archaea] = v }
|
53
|
+
opts.on("-G", "--genome-eq",
|
54
|
+
"If set, ignores models not suitable for genome-equivalents estimations.",
|
55
|
+
"See Rodriguez-R et al, 2015, ISME J 9(9):1928-1940."
|
56
|
+
){ |v| o[:genomeeq] = v }
|
57
|
+
opts.on("-r", "--rename STR",
|
58
|
+
"If set, renames the sequences with the string provided and appends it",
|
59
|
+
"with pipe and the gene name (except in --per-model files)."
|
60
|
+
){ |v| o[:rename]=v }
|
61
|
+
opts.on("-n", "--no-stats",
|
62
|
+
"If set, no statistics are reported on genome evaluation."
|
63
|
+
){ |v| o[:stats] = v }
|
64
|
+
opts.on("-s", "--no-genes",
|
65
|
+
"If set, statistics won't include the lists of missing/multi-copy genes."
|
66
|
+
){ |v| o[:genes] = v }
|
67
|
+
opts.on("-M", "--metagenome",
|
68
|
+
"If set, it allows for multiple copies of each gene and turns on",
|
69
|
+
"metagenomic report mode."){ |v| o[:metagenome] = v }
|
70
|
+
opts.separator ""
|
71
|
+
opts.separator "Other Options"
|
72
|
+
opts.on("-L", "--list-models",
|
73
|
+
"If set, it only lists the models and exits. Compatible with -A, -B, -G,",
|
74
|
+
"and -q; ignores all other parameters."){ |v| o[:list] = v }
|
75
|
+
opts.on("-b", "--bin DIR",
|
76
|
+
"Path to the directory containing the binaries of HMMer 3.0+."
|
77
|
+
){ |v| o[:bin] = v }
|
78
|
+
opts.on("--model-file",
|
79
|
+
"External file containing models to search."){ |v| o[:model_file] = v }
|
80
|
+
opts.on("-t", "--threads INT",
|
81
|
+
"Number of parallel threads to be used. By default: #{o[:thr]}."
|
82
|
+
){ |v| o[:thr] = v.to_i }
|
83
|
+
opts.on("-q", "--quiet", "Run quietly (no STDERR output)."){ o[:q] = true }
|
84
|
+
opts.on("-h", "--help", "Display this screen.") do
|
85
|
+
puts opts
|
86
|
+
exit
|
87
|
+
end
|
88
|
+
opts.separator ""
|
89
|
+
end.parse!
|
90
|
+
abort "-i is mandatory" if o[:in].nil? and not o[:list]
|
91
|
+
o[:bin] = o[:bin]+"/" if o[:bin].size > 0
|
92
|
+
o[:rename] = nil if o[:metagenome]
|
93
|
+
|
94
|
+
not_in_archaea = %w{GrpE Methyltransf_5 TIGR00001 TIGR00002 TIGR00009 TIGR00019
|
95
|
+
TIGR00029 TIGR00043 TIGR00059 TIGR00060 TIGR00061 TIGR00062 TIGR00082 TIGR00086
|
96
|
+
TIGR00092 TIGR00115 TIGR00116 TIGR00152 TIGR00158 TIGR00165 TIGR00166 TIGR00168
|
97
|
+
TIGR00362 TIGR00388 TIGR00396 TIGR00409 TIGR00418 TIGR00420 TIGR00422 TIGR00436
|
98
|
+
TIGR00459 TIGR00460 TIGR00472 TIGR00487 TIGR00496 TIGR00575 TIGR00631 TIGR00663
|
99
|
+
TIGR00775 TIGR00810 TIGR00855 TIGR00922 TIGR00952 TIGR00959 TIGR00963 TIGR00964
|
100
|
+
TIGR00967 TIGR00981 TIGR01009 TIGR01011 TIGR01017 TIGR01021 TIGR01024 TIGR01029
|
101
|
+
TIGR01030 TIGR01031 TIGR01032 TIGR01044 TIGR01049 TIGR01050 TIGR01059 TIGR01063
|
102
|
+
TIGR01066 TIGR01067 TIGR01071 TIGR01079 TIGR01164 TIGR01169 TIGR01171 TIGR01391
|
103
|
+
TIGR01393 TIGR01632 TIGR01953 TIGR02012 TIGR02013 TIGR02027 TIGR02191 TIGR02350
|
104
|
+
TIGR02386 TIGR02387 TIGR02397 TIGR02432 TIGR02729 TIGR03263 TIGR03594}
|
105
|
+
not_in_bacteria = %w{TIGR00389 TIGR00408 TIGR00471 TIGR00775 TIGR02387}
|
106
|
+
not_as_genomeeq = %w{TIGR02386 TIGR02387 TIGR00471 TIGR00472 TIGR00408 TIGR00409
|
107
|
+
TIGR00389 TIGR00436 tRNA-synth_1d}
|
108
|
+
|
109
|
+
begin
|
110
|
+
Dir.mktmpdir do |dir|
|
111
|
+
$stderr.puts "Temporal directory: #{dir}." unless o[:q]
|
112
|
+
|
113
|
+
# Create database.
|
114
|
+
$stderr.puts "Searching models." unless o[:q]
|
115
|
+
models = {}
|
116
|
+
model_id = nil
|
117
|
+
dbh = File.open("#{dir}/essential.hmm", "w")
|
118
|
+
o[:model_file] ||= File.expand_path("../lib/data/essential.hmm.gz",
|
119
|
+
__FILE__)
|
120
|
+
mfh = (File.extname(o[:model_file])==".gz") ?
|
121
|
+
Zlib::GzipReader.open(o[:model_file]) :
|
122
|
+
File.open(o[:model_file],"r")
|
123
|
+
while ln = mfh.gets
|
124
|
+
dbh.print ln
|
125
|
+
ln.chomp!
|
126
|
+
model_id = $1 if ln =~ /^NAME\s+(.+)/
|
127
|
+
models[model_id] = $1 if ln =~ /^DESC\s+(.+)/
|
128
|
+
end
|
129
|
+
dbh.close
|
130
|
+
mfh.close
|
131
|
+
models.delete_if { |m| not_in_archaea.include? m } if o[:archaea]
|
132
|
+
models.delete_if { |m| not_in_bacteria.include? m } if o[:bacteria]
|
133
|
+
models.delete_if { |m| not_as_genomeeq.include? m } if o[:genomeeq]
|
134
|
+
if o[:list]
|
135
|
+
models.each_pair{ |id,desc| puts [id,desc].join("\t") }
|
136
|
+
exit
|
137
|
+
end
|
138
|
+
|
139
|
+
# Check HMMer version and run HMMsearch.
|
140
|
+
if `"#{o[:bin]}hmmsearch" -h`.lines[1] !~ /HMMER 3/
|
141
|
+
raise "You have provided an unsupported version of HMMER. " +
|
142
|
+
"This script requires HMMER 3.0+."
|
143
|
+
end
|
144
|
+
`"#{o[:bin]}hmmsearch" --cpu #{o[:thr]} --tblout "#{dir}/hmmsearch" \
|
145
|
+
--cut_tc --notextw "#{dir}/essential.hmm" "#{o[:in]}" \
|
146
|
+
> #{dir}/hmmsearch.log`
|
147
|
+
|
148
|
+
# Parse output
|
149
|
+
$stderr.puts "Parsing results." unless o[:q]
|
150
|
+
resh = File.open("#{dir}/hmmsearch","r")
|
151
|
+
trash = []
|
152
|
+
genes = {}
|
153
|
+
while ln = resh.gets
|
154
|
+
next if ln =~ /^#/
|
155
|
+
r = ln.split /\s+/
|
156
|
+
next unless models.include? r[2]
|
157
|
+
if o[:metagenome]
|
158
|
+
genes[ r[2] ] = [] if genes[ r[2] ].nil?
|
159
|
+
genes[ r[2] ] << r[0]
|
160
|
+
elsif genes[ r[2] ].nil?
|
161
|
+
genes[ r[2] ] = r[0]
|
162
|
+
else
|
163
|
+
trash << r[2]
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Report statistics
|
168
|
+
if o[:stats]
|
169
|
+
reph = o[:report].nil? ? $stdout : File.open(o[:report], "w")
|
170
|
+
if o[:metagenome]
|
171
|
+
reph.printf "! Essential genes found: %d/%d.\n",
|
172
|
+
genes.size, models.size
|
173
|
+
gc = [0]*(models.size - genes.size) +
|
174
|
+
genes.values.map{|g| g.length}.sort
|
175
|
+
reph.printf "! Mean number of copies per model: %.3f.\n",
|
176
|
+
gc.inject(:+).to_f/models.size
|
177
|
+
reph.printf "! Median number of copies per model: %.1f.\n",
|
178
|
+
gc.size.even? ? gc[gc.size/2,2].inject(:+).to_f/2 : gc[gc.size/2]
|
179
|
+
if o[:genes] and genes.size != models.size
|
180
|
+
reph.printf "! Missing genes: %s\n",
|
181
|
+
([""] +
|
182
|
+
models.keys.select{|m| not genes.keys.include? m
|
183
|
+
}.map{|m| "#{m}: #{models[m]}."}).join("\n! ")
|
184
|
+
end
|
185
|
+
else
|
186
|
+
reph.printf "! Essential genes found: %d/%d.\n",
|
187
|
+
genes.size, models.size
|
188
|
+
reph.printf "! Completeness: %.1f%%.\n",
|
189
|
+
100.0*genes.size/models.size
|
190
|
+
reph.printf "! Contamination: %.1f%%.\n",
|
191
|
+
100.0*trash.size/models.size
|
192
|
+
if o[:genes]
|
193
|
+
reph.printf "! Multiple copies: %s\n",
|
194
|
+
([""] +
|
195
|
+
trash.uniq.map{|m|
|
196
|
+
"#{trash.count(m)+1} #{m}: #{models[m]}."}
|
197
|
+
).join("\n! ") unless trash.empty?
|
198
|
+
reph.printf "! Missing genes: %s\n",
|
199
|
+
([""] +
|
200
|
+
models.keys.select{|m| not genes.keys.include? m
|
201
|
+
}.map{|m| "#{m}: #{models[m]}."}
|
202
|
+
).join("\n! ") unless genes.size==models.size
|
203
|
+
end
|
204
|
+
end
|
205
|
+
reph.close unless o[:report].nil?
|
206
|
+
end
|
207
|
+
|
208
|
+
# Extract sequences
|
209
|
+
unless o[:out].nil? and o[:permodel].nil?
|
210
|
+
$stderr.puts "Extracting sequences." unless o[:q]
|
211
|
+
faah = File.open(o[:in], "r")
|
212
|
+
outh = o[:out].nil? ? nil : File.open(o[:out], "w")
|
213
|
+
geneh = nil
|
214
|
+
in_gene = nil
|
215
|
+
unless o[:permodel].nil?
|
216
|
+
genes.keys.each do |m|
|
217
|
+
File.open("#{o[:permodel]}#{m}.faa", "w").close
|
218
|
+
end
|
219
|
+
end
|
220
|
+
while ln = faah.gets
|
221
|
+
if ln =~ /^>(\S+)/
|
222
|
+
if o[:metagenome]
|
223
|
+
in_gene = genes.keys.map{|k| genes[k].include?($1) ? k : nil
|
224
|
+
}.compact.first
|
225
|
+
in_gene = [in_gene, $1] unless in_gene.nil?
|
226
|
+
else
|
227
|
+
in_gene = genes.rassoc($1)
|
228
|
+
end
|
229
|
+
next if in_gene.nil?
|
230
|
+
geneh.close unless geneh.nil?
|
231
|
+
geneh = File.open("#{o[:permodel]}#{in_gene[0]}.faa",
|
232
|
+
"a+") unless o[:permodel].nil?
|
233
|
+
outh.print(o[:rename].nil? ?
|
234
|
+
ln : ">#{o[:rename]}|#{in_gene[0]}\n") unless outh.nil?
|
235
|
+
geneh.print(
|
236
|
+
o[:rename].nil? ? ln : ">#{o[:rename]}\n") unless geneh.nil?
|
237
|
+
else
|
238
|
+
next if in_gene.nil?
|
239
|
+
outh.print ln unless outh.nil?
|
240
|
+
geneh.print ln unless geneh.nil?
|
241
|
+
end
|
242
|
+
end
|
243
|
+
geneh.close unless geneh.nil?
|
244
|
+
outh.close unless outh.nil?
|
245
|
+
faah.close
|
246
|
+
end
|
247
|
+
|
248
|
+
$stderr.puts "Done." unless o[:q]
|
249
|
+
end # |dir|
|
250
|
+
rescue => err
|
251
|
+
$stderr.puts "Exception: #{err}\n\n"
|
252
|
+
err.backtrace.each { |l| $stderr.puts l + "\n" }
|
253
|
+
err
|
254
|
+
end
|