ngs_server 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ngs_server +72 -50
- data/ext/bamtools/extconf.rb +3 -3
- data/ext/vcftools/Makefile +28 -0
- data/ext/vcftools/README.txt +36 -0
- data/ext/vcftools/cpp/.svn/all-wcprops +125 -0
- data/ext/vcftools/cpp/.svn/dir-prop-base +6 -0
- data/ext/vcftools/cpp/.svn/entries +708 -0
- data/ext/vcftools/cpp/.svn/text-base/Makefile.svn-base +46 -0
- data/ext/vcftools/cpp/.svn/text-base/dgeev.cpp.svn-base +146 -0
- data/ext/vcftools/cpp/.svn/text-base/dgeev.h.svn-base +43 -0
- data/ext/vcftools/cpp/.svn/text-base/output_log.cpp.svn-base +79 -0
- data/ext/vcftools/cpp/.svn/text-base/output_log.h.svn-base +34 -0
- data/ext/vcftools/cpp/.svn/text-base/parameters.cpp.svn-base +535 -0
- data/ext/vcftools/cpp/.svn/text-base/parameters.h.svn-base +154 -0
- data/ext/vcftools/cpp/.svn/text-base/vcf_entry.cpp.svn-base +497 -0
- data/ext/vcftools/cpp/.svn/text-base/vcf_entry.h.svn-base +190 -0
- data/ext/vcftools/cpp/.svn/text-base/vcf_entry_getters.cpp.svn-base +421 -0
- data/ext/vcftools/cpp/.svn/text-base/vcf_entry_setters.cpp.svn-base +482 -0
- data/ext/vcftools/cpp/.svn/text-base/vcf_file.cpp.svn-base +495 -0
- data/ext/vcftools/cpp/.svn/text-base/vcf_file.h.svn-base +184 -0
- data/ext/vcftools/cpp/.svn/text-base/vcf_file_diff.cpp.svn-base +1282 -0
- data/ext/vcftools/cpp/.svn/text-base/vcf_file_filters.cpp.svn-base +1215 -0
- data/ext/vcftools/cpp/.svn/text-base/vcf_file_format_convert.cpp.svn-base +1138 -0
- data/ext/vcftools/cpp/.svn/text-base/vcf_file_index.cpp.svn-base +171 -0
- data/ext/vcftools/cpp/.svn/text-base/vcf_file_output.cpp.svn-base +3012 -0
- data/ext/vcftools/cpp/.svn/text-base/vcftools.cpp.svn-base +107 -0
- data/ext/vcftools/cpp/.svn/text-base/vcftools.h.svn-base +25 -0
- data/ext/vcftools/cpp/Makefile +46 -0
- data/ext/vcftools/cpp/dgeev.cpp +146 -0
- data/ext/vcftools/cpp/dgeev.h +43 -0
- data/ext/vcftools/cpp/output_log.cpp +79 -0
- data/ext/vcftools/cpp/output_log.h +34 -0
- data/ext/vcftools/cpp/parameters.cpp +535 -0
- data/ext/vcftools/cpp/parameters.h +154 -0
- data/ext/vcftools/cpp/vcf_entry.cpp +497 -0
- data/ext/vcftools/cpp/vcf_entry.h +190 -0
- data/ext/vcftools/cpp/vcf_entry_getters.cpp +421 -0
- data/ext/vcftools/cpp/vcf_entry_setters.cpp +482 -0
- data/ext/vcftools/cpp/vcf_file.cpp +495 -0
- data/ext/vcftools/cpp/vcf_file.h +184 -0
- data/ext/vcftools/cpp/vcf_file_diff.cpp +1282 -0
- data/ext/vcftools/cpp/vcf_file_filters.cpp +1215 -0
- data/ext/vcftools/cpp/vcf_file_format_convert.cpp +1138 -0
- data/ext/vcftools/cpp/vcf_file_index.cpp +171 -0
- data/ext/vcftools/cpp/vcf_file_output.cpp +3012 -0
- data/ext/vcftools/cpp/vcftools.cpp +107 -0
- data/ext/vcftools/cpp/vcftools.h +25 -0
- data/ext/vcftools/examples/.svn/all-wcprops +185 -0
- data/ext/vcftools/examples/.svn/dir-prop-base +6 -0
- data/ext/vcftools/examples/.svn/entries +1048 -0
- data/ext/vcftools/examples/.svn/prop-base/perl-api-1.pl.svn-base +5 -0
- data/ext/vcftools/examples/.svn/text-base/annotate-test.vcf.svn-base +37 -0
- data/ext/vcftools/examples/.svn/text-base/annotate.out.svn-base +23 -0
- data/ext/vcftools/examples/.svn/text-base/annotate.txt.svn-base +7 -0
- data/ext/vcftools/examples/.svn/text-base/annotate2.out.svn-base +52 -0
- data/ext/vcftools/examples/.svn/text-base/annotate3.out.svn-base +23 -0
- data/ext/vcftools/examples/.svn/text-base/cmp-test-a-3.3.vcf.svn-base +12 -0
- data/ext/vcftools/examples/.svn/text-base/cmp-test-a.vcf.svn-base +12 -0
- data/ext/vcftools/examples/.svn/text-base/cmp-test-b-3.3.vcf.svn-base +12 -0
- data/ext/vcftools/examples/.svn/text-base/cmp-test-b.vcf.svn-base +12 -0
- data/ext/vcftools/examples/.svn/text-base/cmp-test.out.svn-base +53 -0
- data/ext/vcftools/examples/.svn/text-base/concat-a.vcf.svn-base +21 -0
- data/ext/vcftools/examples/.svn/text-base/concat-b.vcf.svn-base +13 -0
- data/ext/vcftools/examples/.svn/text-base/concat-c.vcf.svn-base +19 -0
- data/ext/vcftools/examples/.svn/text-base/concat.out.svn-base +39 -0
- data/ext/vcftools/examples/.svn/text-base/invalid-4.0.vcf.svn-base +31 -0
- data/ext/vcftools/examples/.svn/text-base/isec-n2-test.vcf.out.svn-base +19 -0
- data/ext/vcftools/examples/.svn/text-base/merge-test-a.vcf.svn-base +17 -0
- data/ext/vcftools/examples/.svn/text-base/merge-test-b.vcf.svn-base +17 -0
- data/ext/vcftools/examples/.svn/text-base/merge-test-c.vcf.svn-base +15 -0
- data/ext/vcftools/examples/.svn/text-base/merge-test.vcf.out.svn-base +31 -0
- data/ext/vcftools/examples/.svn/text-base/perl-api-1.pl.svn-base +46 -0
- data/ext/vcftools/examples/.svn/text-base/query-test.out.svn-base +6 -0
- data/ext/vcftools/examples/.svn/text-base/shuffle-test.vcf.svn-base +12 -0
- data/ext/vcftools/examples/.svn/text-base/subset.SNPs.out.svn-base +10 -0
- data/ext/vcftools/examples/.svn/text-base/subset.indels.out.svn-base +18 -0
- data/ext/vcftools/examples/.svn/text-base/subset.vcf.svn-base +21 -0
- data/ext/vcftools/examples/.svn/text-base/valid-3.3.vcf.svn-base +30 -0
- data/ext/vcftools/examples/.svn/text-base/valid-4.0.vcf.stats.svn-base +104 -0
- data/ext/vcftools/examples/.svn/text-base/valid-4.0.vcf.svn-base +34 -0
- data/ext/vcftools/examples/.svn/text-base/valid-4.1.vcf.svn-base +37 -0
- data/ext/vcftools/examples/annotate-test.vcf +37 -0
- data/ext/vcftools/examples/annotate.out +23 -0
- data/ext/vcftools/examples/annotate.txt +7 -0
- data/ext/vcftools/examples/annotate2.out +52 -0
- data/ext/vcftools/examples/annotate3.out +23 -0
- data/ext/vcftools/examples/cmp-test-a-3.3.vcf +12 -0
- data/ext/vcftools/examples/cmp-test-a.vcf +12 -0
- data/ext/vcftools/examples/cmp-test-b-3.3.vcf +12 -0
- data/ext/vcftools/examples/cmp-test-b.vcf +12 -0
- data/ext/vcftools/examples/cmp-test.out +53 -0
- data/ext/vcftools/examples/concat-a.vcf +21 -0
- data/ext/vcftools/examples/concat-b.vcf +13 -0
- data/ext/vcftools/examples/concat-c.vcf +19 -0
- data/ext/vcftools/examples/concat.out +39 -0
- data/ext/vcftools/examples/invalid-4.0.vcf +31 -0
- data/ext/vcftools/examples/isec-n2-test.vcf.out +19 -0
- data/ext/vcftools/examples/merge-test-a.vcf +17 -0
- data/ext/vcftools/examples/merge-test-b.vcf +17 -0
- data/ext/vcftools/examples/merge-test-c.vcf +15 -0
- data/ext/vcftools/examples/merge-test.vcf.out +31 -0
- data/ext/vcftools/examples/perl-api-1.pl +46 -0
- data/ext/vcftools/examples/query-test.out +6 -0
- data/ext/vcftools/examples/shuffle-test.vcf +12 -0
- data/ext/vcftools/examples/subset.SNPs.out +10 -0
- data/ext/vcftools/examples/subset.indels.out +18 -0
- data/ext/vcftools/examples/subset.vcf +21 -0
- data/ext/vcftools/examples/valid-3.3.vcf +30 -0
- data/ext/vcftools/examples/valid-4.0.vcf +34 -0
- data/ext/vcftools/examples/valid-4.0.vcf.stats +104 -0
- data/ext/vcftools/examples/valid-4.1.vcf +37 -0
- data/ext/vcftools/extconf.rb +2 -0
- data/ext/vcftools/perl/.svn/all-wcprops +149 -0
- data/ext/vcftools/perl/.svn/entries +844 -0
- data/ext/vcftools/perl/.svn/prop-base/fill-aa.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/fill-an-ac.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/fill-ref-md5.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/tab-to-vcf.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/test.t.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-annotate.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-compare.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-concat.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-convert.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-fix-newlines.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-isec.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-merge.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-query.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-shuffle-cols.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-sort.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-stats.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-subset.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-to-tab.svn-base +5 -0
- data/ext/vcftools/perl/.svn/prop-base/vcf-validator.svn-base +5 -0
- data/ext/vcftools/perl/.svn/text-base/ChangeLog.svn-base +84 -0
- data/ext/vcftools/perl/.svn/text-base/FaSlice.pm.svn-base +214 -0
- data/ext/vcftools/perl/.svn/text-base/Makefile.svn-base +12 -0
- data/ext/vcftools/perl/.svn/text-base/Vcf.pm.svn-base +2853 -0
- data/ext/vcftools/perl/.svn/text-base/VcfStats.pm.svn-base +681 -0
- data/ext/vcftools/perl/.svn/text-base/fill-aa.svn-base +103 -0
- data/ext/vcftools/perl/.svn/text-base/fill-an-ac.svn-base +56 -0
- data/ext/vcftools/perl/.svn/text-base/fill-ref-md5.svn-base +204 -0
- data/ext/vcftools/perl/.svn/text-base/tab-to-vcf.svn-base +92 -0
- data/ext/vcftools/perl/.svn/text-base/test.t.svn-base +376 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-annotate.svn-base +1099 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-compare.svn-base +1193 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-concat.svn-base +310 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-convert.svn-base +180 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-fix-newlines.svn-base +97 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-isec.svn-base +660 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-merge.svn-base +577 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-query.svn-base +272 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-shuffle-cols.svn-base +89 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-sort.svn-base +79 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-stats.svn-base +160 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-subset.svn-base +206 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-to-tab.svn-base +112 -0
- data/ext/vcftools/perl/.svn/text-base/vcf-validator.svn-base +145 -0
- data/ext/vcftools/perl/ChangeLog +84 -0
- data/ext/vcftools/perl/FaSlice.pm +214 -0
- data/ext/vcftools/perl/Makefile +12 -0
- data/ext/vcftools/perl/Vcf.pm +2853 -0
- data/ext/vcftools/perl/VcfStats.pm +681 -0
- data/ext/vcftools/perl/fill-aa +103 -0
- data/ext/vcftools/perl/fill-an-ac +56 -0
- data/ext/vcftools/perl/fill-ref-md5 +204 -0
- data/ext/vcftools/perl/tab-to-vcf +92 -0
- data/ext/vcftools/perl/test.t +376 -0
- data/ext/vcftools/perl/vcf-annotate +1099 -0
- data/ext/vcftools/perl/vcf-compare +1193 -0
- data/ext/vcftools/perl/vcf-concat +310 -0
- data/ext/vcftools/perl/vcf-convert +180 -0
- data/ext/vcftools/perl/vcf-fix-newlines +97 -0
- data/ext/vcftools/perl/vcf-isec +660 -0
- data/ext/vcftools/perl/vcf-merge +577 -0
- data/ext/vcftools/perl/vcf-query +286 -0
- data/ext/vcftools/perl/vcf-shuffle-cols +89 -0
- data/ext/vcftools/perl/vcf-sort +79 -0
- data/ext/vcftools/perl/vcf-stats +160 -0
- data/ext/vcftools/perl/vcf-subset +206 -0
- data/ext/vcftools/perl/vcf-to-tab +112 -0
- data/ext/vcftools/perl/vcf-validator +145 -0
- data/ext/vcftools/website/.svn/all-wcprops +41 -0
- data/ext/vcftools/website/.svn/entries +238 -0
- data/ext/vcftools/website/.svn/prop-base/VCF-poster.pdf.svn-base +5 -0
- data/ext/vcftools/website/.svn/prop-base/favicon.ico.svn-base +5 -0
- data/ext/vcftools/website/.svn/prop-base/favicon.png.svn-base +5 -0
- data/ext/vcftools/website/.svn/text-base/Makefile.svn-base +6 -0
- data/ext/vcftools/website/.svn/text-base/README.svn-base +2 -0
- data/ext/vcftools/website/.svn/text-base/VCF-poster.pdf.svn-base +0 -0
- data/ext/vcftools/website/.svn/text-base/default.css.svn-base +250 -0
- data/ext/vcftools/website/.svn/text-base/favicon.ico.svn-base +0 -0
- data/ext/vcftools/website/.svn/text-base/favicon.png.svn-base +0 -0
- data/ext/vcftools/website/Makefile +6 -0
- data/ext/vcftools/website/README +2 -0
- data/ext/vcftools/website/VCF-poster.pdf +0 -0
- data/ext/vcftools/website/default.css +250 -0
- data/ext/vcftools/website/favicon.ico +0 -0
- data/ext/vcftools/website/favicon.png +0 -0
- data/ext/vcftools/website/img/.svn/all-wcprops +53 -0
- data/ext/vcftools/website/img/.svn/entries +300 -0
- data/ext/vcftools/website/img/.svn/prop-base/bg.gif.svn-base +5 -0
- data/ext/vcftools/website/img/.svn/prop-base/bgcode.gif.svn-base +5 -0
- data/ext/vcftools/website/img/.svn/prop-base/bgcontainer.gif.svn-base +5 -0
- data/ext/vcftools/website/img/.svn/prop-base/bgul.gif.svn-base +5 -0
- data/ext/vcftools/website/img/.svn/prop-base/header.gif.svn-base +5 -0
- data/ext/vcftools/website/img/.svn/prop-base/li.gif.svn-base +5 -0
- data/ext/vcftools/website/img/.svn/prop-base/quote.gif.svn-base +5 -0
- data/ext/vcftools/website/img/.svn/prop-base/search.gif.svn-base +5 -0
- data/ext/vcftools/website/img/.svn/text-base/bg.gif.svn-base +0 -0
- data/ext/vcftools/website/img/.svn/text-base/bgcode.gif.svn-base +0 -0
- data/ext/vcftools/website/img/.svn/text-base/bgcontainer.gif.svn-base +0 -0
- data/ext/vcftools/website/img/.svn/text-base/bgul.gif.svn-base +0 -0
- data/ext/vcftools/website/img/.svn/text-base/header.gif.svn-base +0 -0
- data/ext/vcftools/website/img/.svn/text-base/li.gif.svn-base +0 -0
- data/ext/vcftools/website/img/.svn/text-base/quote.gif.svn-base +0 -0
- data/ext/vcftools/website/img/.svn/text-base/search.gif.svn-base +0 -0
- data/ext/vcftools/website/img/bg.gif +0 -0
- data/ext/vcftools/website/img/bgcode.gif +0 -0
- data/ext/vcftools/website/img/bgcontainer.gif +0 -0
- data/ext/vcftools/website/img/bgul.gif +0 -0
- data/ext/vcftools/website/img/header.gif +0 -0
- data/ext/vcftools/website/img/li.gif +0 -0
- data/ext/vcftools/website/img/quote.gif +0 -0
- data/ext/vcftools/website/img/search.gif +0 -0
- data/ext/vcftools/website/src/.svn/all-wcprops +53 -0
- data/ext/vcftools/website/src/.svn/entries +300 -0
- data/ext/vcftools/website/src/.svn/text-base/docs.inc.svn-base +202 -0
- data/ext/vcftools/website/src/.svn/text-base/index.inc.svn-base +52 -0
- data/ext/vcftools/website/src/.svn/text-base/index.php.svn-base +80 -0
- data/ext/vcftools/website/src/.svn/text-base/license.inc.svn-base +27 -0
- data/ext/vcftools/website/src/.svn/text-base/links.inc.svn-base +13 -0
- data/ext/vcftools/website/src/.svn/text-base/options.inc.svn-base +654 -0
- data/ext/vcftools/website/src/.svn/text-base/perl_module.inc.svn-base +249 -0
- data/ext/vcftools/website/src/.svn/text-base/specs.inc.svn-base +18 -0
- data/ext/vcftools/website/src/docs.inc +202 -0
- data/ext/vcftools/website/src/index.inc +52 -0
- data/ext/vcftools/website/src/index.php +80 -0
- data/ext/vcftools/website/src/license.inc +27 -0
- data/ext/vcftools/website/src/links.inc +13 -0
- data/ext/vcftools/website/src/options.inc +654 -0
- data/ext/vcftools/website/src/perl_module.inc +249 -0
- data/ext/vcftools/website/src/specs.inc +18 -0
- data/lib/config.ru +9 -0
- data/lib/ngs_server/add.rb +9 -0
- data/lib/ngs_server/version.rb +1 -1
- data/lib/ngs_server.rb +55 -3
- data/ngs_server.gemspec +5 -2
- metadata +296 -6
@@ -0,0 +1,206 @@
|
|
1
|
+
#!/usr/bin/env perl
|
2
|
+
#
|
3
|
+
# Author: petr.danecek@sanger
|
4
|
+
#
|
5
|
+
|
6
|
+
use strict;
|
7
|
+
use warnings;
|
8
|
+
use Carp;
|
9
|
+
use Vcf;
|
10
|
+
|
11
|
+
my $opts = parse_params();
|
12
|
+
vcf_subset($opts);
|
13
|
+
|
14
|
+
exit;
|
15
|
+
|
16
|
+
#--------------------------------
|
17
|
+
|
18
|
+
sub error
|
19
|
+
{
|
20
|
+
my (@msg) = @_;
|
21
|
+
if ( scalar @msg )
|
22
|
+
{
|
23
|
+
croak @msg;
|
24
|
+
}
|
25
|
+
die
|
26
|
+
"Usage: vcf-subset [OPTIONS] in.vcf.gz > out.vcf\n",
|
27
|
+
"Options:\n",
|
28
|
+
" -c, --columns <string> File or comma-separated list of columns to keep in the vcf file. If file, one column per row\n",
|
29
|
+
" -e, --exclude-ref Exclude rows not containing variants.\n",
|
30
|
+
" -f, --force Proceed anyway even if VCF does not contain some of the samples.\n",
|
31
|
+
" -p, --private Print only rows where only the subset columns carry an alternate allele.\n",
|
32
|
+
" -r, --replace-with-ref Replace the excluded types with reference allele instead of dot.\n",
|
33
|
+
" -t, --type <list> Comma-separated list of variant types to include: SNPs,indels.\n",
|
34
|
+
" -u, --keep-uncalled Do not exclude rows without calls.\n",
|
35
|
+
" -h, -?, --help This help message.\n",
|
36
|
+
"Examples:\n",
|
37
|
+
" cat in.vcf | vcf-subset -r -t indels -e -c SAMPLE1 > out.vcf\n",
|
38
|
+
"\n";
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
sub parse_params
|
43
|
+
{
|
44
|
+
my $opts = { exclude_ref=>0, keep_uncalled=>0, replace_with_ref=>0, private=>0, args=>[$0, @ARGV] };
|
45
|
+
while (my $arg=shift(@ARGV))
|
46
|
+
{
|
47
|
+
if ( $arg eq '-t' || $arg eq '--type' )
|
48
|
+
{
|
49
|
+
my %known = ( SNPs=>'s', indels=>'i' );
|
50
|
+
my $types = shift(@ARGV);
|
51
|
+
for my $t (split(/,/,$types))
|
52
|
+
{
|
53
|
+
if ( !(exists($known{$t})) ) { error("Unknown type [$t] with -t [$types]\n"); }
|
54
|
+
$$opts{types}{$known{$t}} = 1;
|
55
|
+
}
|
56
|
+
next;
|
57
|
+
}
|
58
|
+
if ( $arg eq '-e' || $arg eq '--exclude-ref' ) { $$opts{'exclude_ref'} = 1; next }
|
59
|
+
if ( $arg eq '-f' || $arg eq '--force' ) { $$opts{'force'} = 1; next }
|
60
|
+
if ( $arg eq '-p' || $arg eq '--private' ) { $$opts{'private'} = 1; next }
|
61
|
+
if ( $arg eq '-r' || $arg eq '--replace-with-ref' ) { $$opts{'replace_with_ref'} = 1; next }
|
62
|
+
if ( $arg eq '-u' || $arg eq '--keep-uncalled' ) { $$opts{'keep_uncalled'} = 1; next }
|
63
|
+
if ( $arg eq '-c' || $arg eq '--columns' ) { $$opts{'columns_file'} = shift(@ARGV); next }
|
64
|
+
if ( $arg eq '-?' || $arg eq '-h' || $arg eq '--help' ) { error(); }
|
65
|
+
if ( -e $arg ) { $$opts{file} = $arg; next }
|
66
|
+
if ( -e $arg or $arg=~m{^(?:ftp|http)://} ) { $$opts{file}=$arg; next; }
|
67
|
+
error("Unknown parameter \"$arg\". Run -h for help.\n");
|
68
|
+
}
|
69
|
+
if ( !$$opts{exclude_ref} && !$$opts{'columns_file'} && !exists($$opts{'types'}) ) { error("Missing the -c or -t or -r option.\n") }
|
70
|
+
if ( exists($$opts{types}) ) { $$opts{types}{r}=1; }
|
71
|
+
return $opts;
|
72
|
+
}
|
73
|
+
|
74
|
+
|
75
|
+
sub read_columns
|
76
|
+
{
|
77
|
+
my ($fname) = @_;
|
78
|
+
my @columns;
|
79
|
+
if ( !-e $fname )
|
80
|
+
{
|
81
|
+
@columns = split(/,/,$fname);
|
82
|
+
return \@columns;
|
83
|
+
}
|
84
|
+
open(my $fh,'<',$fname) or error("$fname: $!");
|
85
|
+
while (my $line=<$fh>)
|
86
|
+
{
|
87
|
+
chomp($line);
|
88
|
+
$line=~s/\s+//g;
|
89
|
+
push @columns, $line;
|
90
|
+
}
|
91
|
+
close($fh);
|
92
|
+
return \@columns;
|
93
|
+
}
|
94
|
+
|
95
|
+
sub check_columns
|
96
|
+
{
|
97
|
+
my ($opts,$vcf,$columns) = @_;
|
98
|
+
my @out;
|
99
|
+
for my $col (@$columns)
|
100
|
+
{
|
101
|
+
if ( exists($$vcf{has_column}{$col}) )
|
102
|
+
{
|
103
|
+
push @out, $col;
|
104
|
+
next;
|
105
|
+
}
|
106
|
+
|
107
|
+
my $msg = qq[No such column in the VCF file: "$col"\n];
|
108
|
+
if ( $$opts{force} ) { warn($msg); }
|
109
|
+
else { error($msg); }
|
110
|
+
}
|
111
|
+
return \@out;
|
112
|
+
}
|
113
|
+
|
114
|
+
sub vcf_subset
|
115
|
+
{
|
116
|
+
my ($opts) = @_;
|
117
|
+
|
118
|
+
my $vcf = $$opts{file} ? Vcf->new(file=>$$opts{file}) : Vcf->new(fh=>\*STDIN);
|
119
|
+
$vcf->parse_header();
|
120
|
+
|
121
|
+
# Init requested column info. If not present, include all columns.
|
122
|
+
my $columns = exists($$opts{columns_file}) ? read_columns($$opts{columns_file}) : [];
|
123
|
+
$columns = check_columns($opts,$vcf,$columns);
|
124
|
+
if ( !@$columns && (my $ncols=@{$$vcf{columns}})>9 )
|
125
|
+
{
|
126
|
+
push @$columns, @{$$vcf{columns}}[9..($ncols-1)];
|
127
|
+
}
|
128
|
+
my %has_col = map { $_ => 1 } @$columns;
|
129
|
+
|
130
|
+
$vcf->add_header_line({key=>'source',value=>join(' ',@{$$opts{args}})},append=>'timestamp');
|
131
|
+
$vcf->set_samples(include=>$columns) unless $$opts{private};
|
132
|
+
print $vcf->format_header($columns);
|
133
|
+
|
134
|
+
my $check_private = $$opts{private};
|
135
|
+
while (my $x=$vcf->next_data_hash())
|
136
|
+
{
|
137
|
+
my $site_has_call = 0;
|
138
|
+
my $site_has_nonref = 0;
|
139
|
+
my $site_is_private = 1;
|
140
|
+
my $ref = $$x{REF};
|
141
|
+
|
142
|
+
for my $col (keys %{$$x{gtypes}})
|
143
|
+
{
|
144
|
+
if ( !$has_col{$col} && ($site_is_private==0 || !$check_private) )
|
145
|
+
{
|
146
|
+
# This column is not to be printed
|
147
|
+
delete($$x{gtypes}{$col});
|
148
|
+
next;
|
149
|
+
}
|
150
|
+
|
151
|
+
my ($alleles,$seps,$is_phased,$is_empty) = $vcf->parse_haplotype($x,$col);
|
152
|
+
my $sample_has_call = 0;
|
153
|
+
my $sample_has_nonref = 0;
|
154
|
+
my @out_alleles;
|
155
|
+
|
156
|
+
for (my $i=0; $i<@$alleles; $i++)
|
157
|
+
{
|
158
|
+
my ($type,$len,$ht) = $vcf->event_type($ref,$$alleles[$i]);
|
159
|
+
$out_alleles[$i] = $$alleles[$i];
|
160
|
+
|
161
|
+
# Exclude unwanted variant types if requested
|
162
|
+
if ( exists($$opts{types}) )
|
163
|
+
{
|
164
|
+
if ( !exists($$opts{types}{$type}) )
|
165
|
+
{
|
166
|
+
$out_alleles[$i] = $$opts{replace_with_ref} ? $ref : '.';
|
167
|
+
next;
|
168
|
+
}
|
169
|
+
$sample_has_call = 1;
|
170
|
+
}
|
171
|
+
elsif ( !$is_empty ) { $sample_has_call = 1; }
|
172
|
+
if ( $type ne 'r' ) { $site_has_nonref = 1; $sample_has_nonref = 1; }
|
173
|
+
}
|
174
|
+
if ( $check_private && !$has_col{$col} )
|
175
|
+
{
|
176
|
+
if ( $sample_has_nonref ) { $site_is_private=0; }
|
177
|
+
delete($$x{gtypes}{$col});
|
178
|
+
next;
|
179
|
+
}
|
180
|
+
if ( !$sample_has_call )
|
181
|
+
{
|
182
|
+
if ( $$opts{replace_with_ref} )
|
183
|
+
{
|
184
|
+
for (my $i=0; $i<@$alleles; $i++) { $out_alleles[$i] = $ref; }
|
185
|
+
}
|
186
|
+
else
|
187
|
+
{
|
188
|
+
for (my $i=0; $i<@$alleles; $i++) { $out_alleles[$i] = '.'; }
|
189
|
+
}
|
190
|
+
}
|
191
|
+
else
|
192
|
+
{
|
193
|
+
$site_has_call = 1;
|
194
|
+
}
|
195
|
+
$$x{gtypes}{$col}{GT} = $vcf->format_haplotype(\@out_alleles,$seps);
|
196
|
+
}
|
197
|
+
|
198
|
+
if ( !$site_has_call && !$$opts{keep_uncalled} ) { next; }
|
199
|
+
if ( !$site_has_nonref && $$opts{exclude_ref} ) { next; }
|
200
|
+
if ( $check_private && (!$site_is_private || !$site_has_nonref) ) { next; }
|
201
|
+
|
202
|
+
$vcf->format_genotype_strings($x);
|
203
|
+
print $vcf->format_line($x,$columns);
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env perl
|
2
|
+
|
3
|
+
use strict;
|
4
|
+
use warnings;
|
5
|
+
use Carp;
|
6
|
+
use Vcf;
|
7
|
+
|
8
|
+
my $opts = parse_params();
|
9
|
+
convert_to_tab($opts);
|
10
|
+
|
11
|
+
exit;
|
12
|
+
|
13
|
+
#--------------------------------
|
14
|
+
|
15
|
+
sub error
|
16
|
+
{
|
17
|
+
my (@msg) = @_;
|
18
|
+
if ( scalar @msg )
|
19
|
+
{
|
20
|
+
croak @msg;
|
21
|
+
}
|
22
|
+
die
|
23
|
+
"Usage: vcf-to-tab [OPTIONS] < in.vcf > out.tab\n",
|
24
|
+
"Options:\n",
|
25
|
+
" -h, -?, --help This help message.\n",
|
26
|
+
" -i, --iupac Use one-letter IUPAC codes\n",
|
27
|
+
"\n";
|
28
|
+
}
|
29
|
+
|
30
|
+
|
31
|
+
sub parse_params
|
32
|
+
{
|
33
|
+
my $opts = { iupac=>0 };
|
34
|
+
while (my $arg=shift(@ARGV))
|
35
|
+
{
|
36
|
+
if ( $arg eq '-?' || $arg eq '-h' || $arg eq '--help' ) { error(); }
|
37
|
+
if ( $arg eq '-i' || $arg eq '--iupac' ) { $$opts{iupac}=1; next; }
|
38
|
+
error("Unknown parameter \"$arg\". Run -h for help.\n");
|
39
|
+
}
|
40
|
+
|
41
|
+
if ( $$opts{iupac} )
|
42
|
+
{
|
43
|
+
$$opts{iupac} =
|
44
|
+
{
|
45
|
+
'GG' => 'G',
|
46
|
+
'CC' => 'C',
|
47
|
+
'TT' => 'T',
|
48
|
+
'AA' => 'A',
|
49
|
+
|
50
|
+
'GT' => 'K',
|
51
|
+
'TG' => 'K',
|
52
|
+
'AC' => 'M',
|
53
|
+
'CA' => 'M',
|
54
|
+
'CG' => 'S',
|
55
|
+
'GC' => 'S',
|
56
|
+
'AG' => 'R',
|
57
|
+
'GA' => 'R',
|
58
|
+
'AT' => 'W',
|
59
|
+
'TA' => 'W',
|
60
|
+
'CT' => 'Y',
|
61
|
+
'TC' => 'Y',
|
62
|
+
|
63
|
+
'..' => '.',
|
64
|
+
};
|
65
|
+
}
|
66
|
+
|
67
|
+
return $opts;
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
sub convert_to_tab
|
72
|
+
{
|
73
|
+
my ($opts) = @_;
|
74
|
+
|
75
|
+
my $iupac;
|
76
|
+
if ( $$opts{iupac} ) { $iupac=$$opts{iupac}; }
|
77
|
+
|
78
|
+
my $vcf = Vcf->new(fh=>\*STDIN);
|
79
|
+
$vcf->parse_header();
|
80
|
+
|
81
|
+
my $header_printed=0;
|
82
|
+
|
83
|
+
while (my $x=$vcf->next_data_hash())
|
84
|
+
{
|
85
|
+
if ( !$header_printed )
|
86
|
+
{
|
87
|
+
print "#CHROM\tPOS\tREF";
|
88
|
+
for my $col (sort keys %{$$x{gtypes}})
|
89
|
+
{
|
90
|
+
print "\t$col";
|
91
|
+
}
|
92
|
+
print "\n";
|
93
|
+
|
94
|
+
$header_printed = 1;
|
95
|
+
}
|
96
|
+
|
97
|
+
print "$$x{CHROM}\t$$x{POS}\t$$x{REF}";
|
98
|
+
for my $col (sort keys %{$$x{gtypes}})
|
99
|
+
{
|
100
|
+
my ($al1,$sep,$al2) = exists($$x{gtypes}{$col}{GT}) ? $vcf->parse_alleles($x,$col) : ('.','/','.');
|
101
|
+
my $gt = $al1.'/'.$al2;
|
102
|
+
if ( $iupac )
|
103
|
+
{
|
104
|
+
if ( !exists($$iupac{$gt}) ) { error(qq[Unknown IUPAC code for "$al1$sep$al2" .. $$x{CHROM}:$$x{POS} $col\n]); }
|
105
|
+
$gt = $$iupac{$gt};
|
106
|
+
}
|
107
|
+
print "\t".$gt;
|
108
|
+
}
|
109
|
+
print "\n";
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
@@ -0,0 +1,145 @@
|
|
1
|
+
#!/usr/bin/env perl
|
2
|
+
#
|
3
|
+
# Author: petr.danecek@sanger
|
4
|
+
#
|
5
|
+
|
6
|
+
use strict;
|
7
|
+
use warnings;
|
8
|
+
use Carp;
|
9
|
+
use Vcf;
|
10
|
+
use IPC::Open3 'open3';
|
11
|
+
use IO::Select;
|
12
|
+
|
13
|
+
my $opts = parse_params();
|
14
|
+
do_validation($opts);
|
15
|
+
|
16
|
+
exit;
|
17
|
+
|
18
|
+
#--------------------------------
|
19
|
+
|
20
|
+
sub error
|
21
|
+
{
|
22
|
+
my (@msg) = @_;
|
23
|
+
if ( scalar @msg )
|
24
|
+
{
|
25
|
+
croak @msg;
|
26
|
+
}
|
27
|
+
die
|
28
|
+
"Usage: vcf-validator [OPTIONS] file.vcf.gz\n",
|
29
|
+
"Options:\n",
|
30
|
+
" -d, --duplicates Warn about duplicate positions.\n",
|
31
|
+
" -u, --unique-messages Output all messages only once.\n",
|
32
|
+
" -h, -?, --help This help message.\n",
|
33
|
+
"\n";
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
sub parse_params
|
38
|
+
{
|
39
|
+
my $opts = { unique=>0, duplicates=>0 };
|
40
|
+
while (my $arg=shift(@ARGV))
|
41
|
+
{
|
42
|
+
if ( $arg eq '-d' || $arg eq '--duplicates' ) { $$opts{duplicates}=1; next; }
|
43
|
+
if ( $arg eq '-u' || $arg eq '--unique-messages' ) { $$opts{unique}=1; next; }
|
44
|
+
if ( $arg eq '-?' || $arg eq '-h' || $arg eq '--help' ) { error(); }
|
45
|
+
if ( -e $arg && !exists($$opts{file}) ) { $$opts{file}=$arg; next; }
|
46
|
+
error("Unknown parameter or non-existent file: \"$arg\". Run -h for help.\n");
|
47
|
+
}
|
48
|
+
return $opts;
|
49
|
+
}
|
50
|
+
|
51
|
+
sub do_validation
|
52
|
+
{
|
53
|
+
my ($opts) = @_;
|
54
|
+
|
55
|
+
my %opts = $$opts{file} ? (file=>$$opts{file}) : (fh=>\*STDIN);
|
56
|
+
my $vcf = Vcf->new(%opts, warn_duplicates=>$$opts{duplicates});
|
57
|
+
|
58
|
+
if ( !$$opts{unique} )
|
59
|
+
{
|
60
|
+
$vcf->run_validation();
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
|
64
|
+
my ($kid_in,$kid_out,$kid_err);
|
65
|
+
|
66
|
+
my $pid = open3($kid_in,$kid_out,$kid_err,'-');
|
67
|
+
if ( !defined $pid ) { error("Cannot fork: $!"); }
|
68
|
+
|
69
|
+
if ($pid)
|
70
|
+
{
|
71
|
+
$$opts{known_lines} = [];
|
72
|
+
|
73
|
+
my $sel = new IO::Select;
|
74
|
+
$sel->add($kid_out,$kid_err);
|
75
|
+
|
76
|
+
while(my @ready = $sel->can_read)
|
77
|
+
{
|
78
|
+
foreach my $fh (@ready)
|
79
|
+
{
|
80
|
+
my $line = <$fh>;
|
81
|
+
if (not defined $line)
|
82
|
+
{
|
83
|
+
$sel->remove($fh);
|
84
|
+
next;
|
85
|
+
}
|
86
|
+
print_or_discard_line($opts,$line);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
print_summary($opts);
|
90
|
+
}
|
91
|
+
else
|
92
|
+
{
|
93
|
+
$vcf->run_validation();
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
sub print_or_discard_line
|
99
|
+
{
|
100
|
+
my ($opts,$line) = @_;
|
101
|
+
|
102
|
+
my @items = split(/\s+/,$line);
|
103
|
+
my $nitems = scalar @items;
|
104
|
+
|
105
|
+
for my $known (@{$$opts{known_lines}})
|
106
|
+
{
|
107
|
+
if ( @items != @{$$known{line}} ) { next; }
|
108
|
+
|
109
|
+
my $nmatches = 0;
|
110
|
+
for (my $i=0; $i<$nitems; $i++)
|
111
|
+
{
|
112
|
+
if ( $items[$i] eq $$known{line}[$i] ) { $nmatches++ }
|
113
|
+
}
|
114
|
+
|
115
|
+
if ( $nitems-$nmatches<3 )
|
116
|
+
{
|
117
|
+
$$known{n}++;
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
push @{$$opts{known_lines}}, { line=>\@items, n=>1 };
|
123
|
+
print $line;
|
124
|
+
}
|
125
|
+
|
126
|
+
sub print_summary
|
127
|
+
{
|
128
|
+
my ($opts) = @_;
|
129
|
+
my $n = 0;
|
130
|
+
for my $error (@{$$opts{known_lines}})
|
131
|
+
{
|
132
|
+
$n += $$error{n};
|
133
|
+
}
|
134
|
+
print "\n\n------------------------\n";
|
135
|
+
print "Summary:\n";
|
136
|
+
printf "\t%d errors total \n\n", $n;
|
137
|
+
|
138
|
+
$n = 0;
|
139
|
+
for my $error (sort {$$b{n}<=>$$a{n}} @{$$opts{known_lines}})
|
140
|
+
{
|
141
|
+
if ( $n++ > 50 ) { print "\n\nand more...\n"; last; }
|
142
|
+
printf "\t%d\t..\t%s\n", $$error{n},join(' ',@{$$error{line}});
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
K 25
|
2
|
+
svn:wc:ra_dav:version-url
|
3
|
+
V 38
|
4
|
+
/svnroot/vcftools/!svn/ver/620/website
|
5
|
+
END
|
6
|
+
VCF-poster.pdf
|
7
|
+
K 25
|
8
|
+
svn:wc:ra_dav:version-url
|
9
|
+
V 53
|
10
|
+
/svnroot/vcftools/!svn/ver/285/website/VCF-poster.pdf
|
11
|
+
END
|
12
|
+
favicon.png
|
13
|
+
K 25
|
14
|
+
svn:wc:ra_dav:version-url
|
15
|
+
V 50
|
16
|
+
/svnroot/vcftools/!svn/ver/320/website/favicon.png
|
17
|
+
END
|
18
|
+
default.css
|
19
|
+
K 25
|
20
|
+
svn:wc:ra_dav:version-url
|
21
|
+
V 50
|
22
|
+
/svnroot/vcftools/!svn/ver/320/website/default.css
|
23
|
+
END
|
24
|
+
Makefile
|
25
|
+
K 25
|
26
|
+
svn:wc:ra_dav:version-url
|
27
|
+
V 47
|
28
|
+
/svnroot/vcftools/!svn/ver/429/website/Makefile
|
29
|
+
END
|
30
|
+
README
|
31
|
+
K 25
|
32
|
+
svn:wc:ra_dav:version-url
|
33
|
+
V 45
|
34
|
+
/svnroot/vcftools/!svn/ver/331/website/README
|
35
|
+
END
|
36
|
+
favicon.ico
|
37
|
+
K 25
|
38
|
+
svn:wc:ra_dav:version-url
|
39
|
+
V 50
|
40
|
+
/svnroot/vcftools/!svn/ver/320/website/favicon.ico
|
41
|
+
END
|