| 1 |
=head1 LICENSE |
| 2 |
|
| 3 |
Copyright [2015-2024] EMBL-European Bioinformatics Institute |
| 4 |
|
| 5 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
you may not use this file except in compliance with the License. |
| 7 |
You may obtain a copy of the License at |
| 8 |
|
| 9 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
|
| 11 |
Unless required by applicable law or agreed to in writing, software |
| 12 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
See the License for the specific language governing permissions and |
| 15 |
limitations under the License. |
| 16 |
|
| 17 |
=head1 NAME |
| 18 |
|
| 19 |
Faidx -- Perl extension for accessing bgzip compressed and indexed FASTA using htslib |
| 20 |
|
| 21 |
=head1 SYNOPSIS |
| 22 |
|
| 23 |
#include the module |
| 24 |
use Bio::DB::HTS::Faidx; |
| 25 |
|
| 26 |
#create the index object |
| 27 |
my $fasta = "$Bin/data/Saccharomyces_cerevisiae.R64-1-1.dna.chromosome.I.fa.gz" ; |
| 28 |
my $location = "I:1-100" ; |
| 29 |
my $seq_id = "I" ; |
| 30 |
my $index = Bio::DB::HTS::Faidx->new($fasta); |
| 31 |
|
| 32 |
#get sequence using the location |
| 33 |
my $seq = "" ; |
| 34 |
my $length = 0 ; |
| 35 |
($seq, $length) = $index->get_sequence($location); |
| 36 |
|
| 37 |
$seq = $index->get_sequence_no_length($location); |
| 38 |
$length = $index->length($seq_id); |
| 39 |
|
| 40 |
#get sequence using the separate parameters. |
| 41 |
#Note here that the sequence start and end points are zero indexed, so code accordingly. |
| 42 |
($seq, $length) = $index->get_sequence2("I",1,99); |
| 43 |
$seq = $index->get_sequence2_no_length("I",1,99); |
| 44 |
|
| 45 |
my @seq_ids = $index->get_all_sequence_ids(); |
| 46 |
|
| 47 |
#returns 1 if sequence ID is present, 0 if not |
| 48 |
my $has_seq = $index->has_sequence('I'); |
| 49 |
|
| 50 |
=head1 AUTHOR |
| 51 |
|
| 52 |
Rishi Nag |
| 53 |
|
| 54 |
=cut |
| 55 |
|
| 56 |
|
| 57 |
package Bio::DB::HTS::Faidx; |
| 58 |
|
| 59 |
use strict; |
| 60 |
use warnings; |
| 61 |
|
| 62 |
require Exporter; |
| 63 |
|
| 64 |
our @ISA = qw(Exporter); |
| 65 |
|
| 66 |
# Items to export into callers namespace by default. Note: do not export |
| 67 |
# names by default without a very good reason. Use EXPORT_OK instead. |
| 68 |
# Do not simply export all your public functions/methods/constants. |
| 69 |
|
| 70 |
# This allows declaration use Faidx ':all'; |
| 71 |
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
| 72 |
# will save memory. |
| 73 |
our %EXPORT_TAGS = ( 'all' => [ qw( |
| 74 |
|
| 75 |
) ] ); |
| 76 |
|
| 77 |
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
| 78 |
|
| 79 |
our @EXPORT = qw( |
| 80 |
|
| 81 |
); |
| 82 |
|
| 83 |
our $VERSION = '3.02'; |
| 84 |
|
| 85 |
require XSLoader; |
| 86 |
XSLoader::load('Bio::DB::HTS::Faidx', $VERSION); |
| 87 |
|
| 88 |
# Preloaded methods go here. |
| 89 |
1; |
| 90 |
__END__ |