ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/cdbfasta/perltest.pl
Revision: 8
Committed: Mon Mar 22 22:11:25 2010 UTC (12 years, 6 months ago) by gpertea
File size: 742 byte(s)
Log Message:
added cdbfasta source files

Line File contents
1 #!/usr/bin/perl
2 use strict;
3 my $usage=q/.\/perltest.pl <fasta.cidx> <key>
4 Will test the -P option of cdbyank to use the retrieved
5 offset and show the fasta record at that position
6 /;
7 my ($cidx, $key)=@ARGV;
8 die($usage."\n") unless $key && -f $cidx;
9 my $file=$cidx;
10 $file=~s/\.cidx$//;
11 open(BIGFILE, $file)
12 || die "Cannot open data file $file (for index $cidx)!\n";
13
14 my $ofs=`cdbyank -P -a '$key' $cidx`;
15 chomp($ofs);
16 die("Error: key $key not found in $cidx\n") unless length($ofs)>0;
17 $ofs=int($ofs);
18
19 seek(BIGFILE, 0, 2);
20
21 my $len=tell(BIGFILE);
22
23 print "--> File size is $len\n";
24 print "--> Record at position $ofs:\n";
25 seek(BIGFILE, $ofs, 0);
26 my $rec;
27 while (<BIGFILE>) {
28 last if (/^>/ && $rec);
29 $rec=$_;
30 print $_;
31 }
32
33 close(BIGFILE);

Properties

Name Value
svn:executable *