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,214 @@
|
|
1
|
+
# Author: petr.danecek@sanger
|
2
|
+
#
|
3
|
+
|
4
|
+
=head1 NAME
|
5
|
+
|
6
|
+
FaSlice.pm. Module for cached access to fasta sequences, employs samtools faidx.
|
7
|
+
|
8
|
+
=head1 SYNOPSIS
|
9
|
+
|
10
|
+
use FaSlice;
|
11
|
+
|
12
|
+
my $fa = FaSlice->new(file=>'ref.fa');
|
13
|
+
$fa->get_base(1,12345);
|
14
|
+
$fa->get_slice(1,12345,54321);
|
15
|
+
|
16
|
+
=cut
|
17
|
+
|
18
|
+
|
19
|
+
package FaSlice;
|
20
|
+
|
21
|
+
use strict;
|
22
|
+
use warnings;
|
23
|
+
use Carp;
|
24
|
+
|
25
|
+
=head2 new
|
26
|
+
|
27
|
+
About : Creates new FaSlice object.
|
28
|
+
Usage : my $fa = FaSlice->new(file=>'ref.fa');
|
29
|
+
Args : file .. the fasta file
|
30
|
+
oob .. out-of-bounds requests: one of 'throw' (throws), 'N' (fills the missing bases by Ns), or '' (returns empty string, default)
|
31
|
+
size .. size of the cached chunk read by samtools faidx (1_000_000)
|
32
|
+
|
33
|
+
=cut
|
34
|
+
|
35
|
+
sub new
|
36
|
+
{
|
37
|
+
my ($class,@args) = @_;
|
38
|
+
my $self = @args ? {@args} : {};
|
39
|
+
bless $self, ref($class) || $class;
|
40
|
+
if ( !$$self{file} ) { $self->throw("Missing the parameter file\n"); }
|
41
|
+
$$self{chr} = undef;
|
42
|
+
$$self{from} = undef;
|
43
|
+
$$self{to} = undef;
|
44
|
+
if ( !$$self{size} ) { $$self{size}=1_000_000; }
|
45
|
+
$$self{ncache_missed} = 0;
|
46
|
+
$$self{nqueries} = 0;
|
47
|
+
if ( !exists($$self{oob}) ) { $$self{oob}=''; }
|
48
|
+
if ( $$self{oob} ne '' && $$self{oob} ne 'throw' && $$self{oob} ne 'N' ) { $self->throw("The value of oob not recognised: [$$self{oob}]"); }
|
49
|
+
$self->chromosome_naming($$self{file});
|
50
|
+
return $self;
|
51
|
+
}
|
52
|
+
|
53
|
+
sub throw
|
54
|
+
{
|
55
|
+
my ($self,@msg) = @_;
|
56
|
+
confess(@msg);
|
57
|
+
}
|
58
|
+
|
59
|
+
sub cmd
|
60
|
+
{
|
61
|
+
my ($self,$cmd) = @_;
|
62
|
+
my @out = `$cmd`;
|
63
|
+
if ( $? )
|
64
|
+
{
|
65
|
+
my @msg = ();
|
66
|
+
push @msg, qq[The command "$cmd" returned non-zero status $?];
|
67
|
+
if ( $! )
|
68
|
+
{
|
69
|
+
push @msg, ": $!\n";
|
70
|
+
}
|
71
|
+
else
|
72
|
+
{
|
73
|
+
push @msg, ".\n";
|
74
|
+
}
|
75
|
+
if ( scalar @out )
|
76
|
+
{
|
77
|
+
push @msg, @out;
|
78
|
+
}
|
79
|
+
$self->throw(@msg);
|
80
|
+
}
|
81
|
+
return (@out);
|
82
|
+
}
|
83
|
+
|
84
|
+
# Read the first file of the fasta file and make a guess: Are all chromosomes
|
85
|
+
# names as 'chr1','chr2',etc or just '1','2',...?
|
86
|
+
# Future TODO: more robust chromosome name mapping?
|
87
|
+
sub chromosome_naming
|
88
|
+
{
|
89
|
+
my ($self,$fa_file) = @_;
|
90
|
+
open(my $fh,'<',"$fa_file.fai") or $self->throw("$fa_file.fai: $!");
|
91
|
+
my $line=<$fh>;
|
92
|
+
if ( !($line=~/^(chr)?\S+\t/) ) { chomp($line); $self->throw("FIXME: the sequence names not in '>(chr)?\\S+' format [$line] ... $fa_file.fai\n"); }
|
93
|
+
close($fh);
|
94
|
+
$$self{chr_naming} = defined $1 ? $1 : '';
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
sub read_chunk
|
99
|
+
{
|
100
|
+
my ($self,$chr,$pos) = @_;
|
101
|
+
$$self{chr} = $chr;
|
102
|
+
$chr =~ s/^chr//;
|
103
|
+
$chr = $$self{chr_naming}.$chr;
|
104
|
+
my $to = $pos + $$self{size};
|
105
|
+
my $cmd = "samtools faidx $$self{file} $chr:$pos-$to";
|
106
|
+
my @out = $self->cmd($cmd) or $self->throw("$cmd: $!");
|
107
|
+
my $line = shift(@out);
|
108
|
+
if ( !($line=~/^>$chr:(\d+)-(\d+)/) ) { $self->throw("Could not parse: $line"); }
|
109
|
+
$$self{from} = $1;
|
110
|
+
my $chunk = '';
|
111
|
+
while ($line=shift(@out))
|
112
|
+
{
|
113
|
+
chomp($line);
|
114
|
+
$chunk .= $line;
|
115
|
+
}
|
116
|
+
$$self{to} = $$self{from} + length($chunk) - 1;
|
117
|
+
$$self{chunk} = $chunk;
|
118
|
+
$$self{ncache_missed}++;
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
|
122
|
+
=head2 get_base
|
123
|
+
|
124
|
+
About : Retrieves base at the given chromosome and position
|
125
|
+
Usage : my $fa = FaSlice->new(file=>'ref.fa'); $fa->get_base(1,12345);
|
126
|
+
Args : chromosome
|
127
|
+
1-based coordinate
|
128
|
+
|
129
|
+
=cut
|
130
|
+
|
131
|
+
sub get_base
|
132
|
+
{
|
133
|
+
my ($self,$chr,$pos) = @_;
|
134
|
+
if ( !$$self{chr} || $chr ne $$self{chr} || $pos<$$self{from} || $pos>$$self{to} )
|
135
|
+
{
|
136
|
+
$self->read_chunk($chr,$pos);
|
137
|
+
}
|
138
|
+
$$self{nqueries}++;
|
139
|
+
my $idx = $pos - $$self{from};
|
140
|
+
if ( $$self{from}>$$self{to} )
|
141
|
+
{
|
142
|
+
if ( $$self{oob} eq '' ) { return ''; }
|
143
|
+
elsif ( $$self{oob} eq 'N' ) { return 'N'; }
|
144
|
+
$self->throw("No such site $chr:$pos in $$self{file}\n");
|
145
|
+
}
|
146
|
+
return substr($$self{chunk},$idx,1);
|
147
|
+
}
|
148
|
+
|
149
|
+
|
150
|
+
=head2 get_slice
|
151
|
+
|
152
|
+
About : Retrieves region
|
153
|
+
Usage : my $fa = FaSlice->new(file=>'ref.fa'); $fa->get_base(1,12345,54321);
|
154
|
+
Args : chromosome
|
155
|
+
1-based coordinate
|
156
|
+
|
157
|
+
=cut
|
158
|
+
|
159
|
+
sub get_slice
|
160
|
+
{
|
161
|
+
my ($self,$chr,$from,$to) = @_;
|
162
|
+
if ( $to-$from >= $$self{size} ) { $self->throw("Too big region requested, $from-$to >= $$self{size}\n"); }
|
163
|
+
if ( $from>$to ) { $self->throw("Expected $from>$to\n"); }
|
164
|
+
if ( !$$self{chr} || $chr ne $$self{chr} || $from<$$self{from} || $to>$$self{to} )
|
165
|
+
{
|
166
|
+
$self->read_chunk($chr,$from);
|
167
|
+
}
|
168
|
+
$$self{nqueries}++;
|
169
|
+
|
170
|
+
if ( $$self{from}>$$self{to} || $$self{from}>$from || $$self{to}<$to )
|
171
|
+
{
|
172
|
+
if ( $$self{oob} eq 'throw' ) { $self->throw("The region out of bounds $chr:$from-$to in $$self{file}\n"); }
|
173
|
+
elsif ( $$self{oob} eq '' ) { return ''; }
|
174
|
+
|
175
|
+
if ( $$self{from}>$$self{to} ) { return 'N' x ($to-$from+1); }
|
176
|
+
if ( $$self{from}>$to ) { $self->throw("FIXME: this shouldn't happen $chr:$from-$to .. $$self{from},$$self{to} .. $$self{file}"); }
|
177
|
+
|
178
|
+
my $lfill = '';
|
179
|
+
my $rfill = '';
|
180
|
+
if ( $$self{from}>$from ) { $lfill = 'N' x ($$self{from}-$from); $from=$$self{from}; }
|
181
|
+
if ( $$self{to}<$to ) { $rfill = 'N' x ($to-$$self{to}); $to=$$self{to}; }
|
182
|
+
return $lfill . substr($$self{chunk},$from-$$self{from},$to-$from+1) . $rfill;
|
183
|
+
}
|
184
|
+
return substr($$self{chunk},$from-$$self{from},$to-$from+1);
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
# http://www.illumina.com/documents/products/technotes/technote_topbot.pdf
|
189
|
+
sub illumina_alleles_TOP_to_ref
|
190
|
+
{
|
191
|
+
my ($self,$a1,$a2,$chr,$pos,$ref) = @_;
|
192
|
+
my %map = (A=>'T', C=>'G', G=>'C', T=>'A');
|
193
|
+
my %top = (
|
194
|
+
A=>{A=>-2,C=> 1,G=> 1,T=>-1},
|
195
|
+
C=>{A=> 1,C=>-2,G=>-1,T=> 0},
|
196
|
+
G=>{A=> 1,C=>-1,G=>-2,T=> 0},
|
197
|
+
T=>{A=>-1,C=> 0,G=> 0,T=>-2} );
|
198
|
+
|
199
|
+
my $stat = $top{$a1}{$a2};
|
200
|
+
if ( $stat==-2 ) { $self->throw("Expected two different bases, got $a1 and $a2.\n"); }
|
201
|
+
if ( $stat==-1 )
|
202
|
+
{
|
203
|
+
# Now we should do the sequence walking to see if the reference is TOP or BOT,
|
204
|
+
# but we do not this in ill-to-vcf: C/G would become G/C and A/T would become T/A.
|
205
|
+
return ($a1,$a2);
|
206
|
+
}
|
207
|
+
if ( $stat==0 ) { $self->throw("Expected Illumina TOP, got $a1 and $a2.\n"); }
|
208
|
+
if ( $ref eq $a1 or $ref eq $a2 ) { return ($a1,$a2); }
|
209
|
+
return ($map{$a1},$map{$a2});
|
210
|
+
}
|
211
|
+
|
212
|
+
|
213
|
+
1;
|
214
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
BIN = vcf-compare fill-aa vcf-annotate vcf-merge vcf-isec vcf-stats vcf-to-tab fill-an-ac \
|
3
|
+
vcf-query vcf-convert vcf-subset vcf-validator vcf-concat vcf-sort
|
4
|
+
MOD = FaSlice.pm Vcf.pm
|
5
|
+
|
6
|
+
install:
|
7
|
+
@for i in $(BIN); do cp $(CURDIR)/$$i $(BINDIR)/$$i; done; \
|
8
|
+
for i in $(MOD); do cp $(CURDIR)/$$i $(MODDIR)/$$i; done;
|
9
|
+
|
10
|
+
clean:
|
11
|
+
@for i in $(BIN); do rm -f $(BINDIR)/$$i; done; \
|
12
|
+
for i in $(MOD); do rm -f $(MODDIR)/$$i; done;
|