Bio::D...::Faidx(3pm)

πŸ’– LICENSE πŸ’–

okay bestie, legal moment, we gotta do it, no skipping πŸŽ€

Copyright [2015-2018] EMBL-European Bioinformatics Institute Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

that's it, that's the whole thing, Apache 2.0, iconic behavior, read it, respect it πŸ’…


✨ NAME ✨

Faidx β€” it's a Perl extension for accessing bgzip compressed and indexed FASTA using htslib. yes, bgzip, not plain gzip. yes, indexed. iykyk 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

first things first, bestie, you gotta include the module:

#include the module
use Bio::DB::HTS::Faidx;

#create the index object
my $fasta = "$Bin/data/Saccharomyces_cerevisiae.R64-1-1.dna.chromosome.I.fa.gz" ;
my $location = "I:1-100" ;
my $seq_id = "I" ;
my $index = Bio::DB::HTS::Faidx->new($fasta);

so we're pointing it at a bgzipped yeast chromosome I FASTA, and we hand new the file path and it gives us back an index object. main character energy, honestly πŸ‘‘


now the actual fetching, using a location string:

#get sequence using the location
my $seq = "" ;
my $length = 0 ;
($seq, $length) = $index->get_sequence($location);

$seq = $index->get_sequence_no_length($location);
$length = $index->length($seq_id);

see how there's a version that gives you back both the sequence and its length, and a _no_length version when you literally only want the sequence? and then length will hand you the length on its own if you just pass a seq id. pick your fighter 🫢


and here's the other flavor, where you pass the pieces separately instead of one "I:1-100" string:

#get sequence using the separate parameters.
#Note here that the sequence start and end points are zero indexed, so code accordingly.
($seq, $length) = $index->get_sequence2("I",1,99);
$seq = $index->get_sequence2_no_length("I",1,99);

my @seq_ids = $index->get_all_sequence_ids();

#returns 1 if sequence ID is present, 0 if not
my $has_seq = $index->has_sequence('I');
⚠️ okay this part is important, do NOT sleep on it: the sequence start and end points in get_sequence2 and get_sequence2_no_length are zero indexed. so code accordingly, fr fr. that ("I",1,99) is not what your brain thinks it is at first glance 😭

also, get_all_sequence_ids will drop every sequence id it's got into @seq_ids β€” all of them, the whole roster ✨

and has_sequence('I') is your vibe check: returns 1 if that sequence ID is present, 0 if it is not. simple, clean, we love a boolean πŸ’–


🧚 AUTHOR 🧚

Rishi Nag β€” thank you for your service, king πŸ‘‘


and that's a wrap, bestie πŸŽ€ this page came to you from perl v5.40.0, dated 2024-10-31, living under the name Bio::D...::Faidx(3pm) in the User Contributed Perl Documentation. go index something, periodt πŸ’…πŸŒˆ

πŸ“¦ where this page comes from