Bio-Lite
view release on metacpan or search on metacpan
lib/Bio/Lite.pm view on Meta::CPAN
Convert strand from '+/-' standard to '1/-1' standard and the opposite.
Example:
say "Forward a: ",convertStrand('+');
say "Forward b: ",convertStrand(1);
say "Reverse a: ",convertStrand('-');
say "Reverss b: ",convertStrand(-1);
will print
Forward a: 1
Forward b: +
Reverse a: -1
Reverse b: -
=head1 PARSING
This are some tools that aim to read (bio) files like
=over
=item Sequence files : FASTA, FASTQ
=item Annotation files : GFF3, GTF2, BED6, BED12, ...
=item Alignement files : SAM, BAM
=back
=head2 seqFileIterator
Open Fasta, or Fastq files (can be gziped).
seqFileIterator has an automatic file extension detection but you can force it
using a second parameter with the format : 'fasta' or 'fastq'.
Example:
my $it = seqFileIterator('file.fastq','fastq');
while(my $entry = $it->()) {
print "Sequence name : $entry->{name}
Sequence : $entry->{seq}
Sequence quality: $entry->{qual}","\n";
}
Return: HashRef
{ name => 'sequence_identifier',
seq => 'sequence_value',
qual => 'sequence_quality', # only defined for FASTQ files
}
seqFileIterator is more than B<50x faster than Bio-Perl> Bio::SeqIO for FASTQ files
seqFileIterator is 4x faster than Bio-Perl Bio::SeqIO for FASTA files
=head2 pairedEndSeqFileIterator
Open Paired-End Sequence files using seqFileIterator()
Paird-End files are generated by Next Generation Sequencing technologies (like Illumina) where two
reads are sequenced from the same DNA fragment and saved in separated files.
Example:
my $it = pairedEndSeqFileIterator($file);
while (my $entry = $it->()) {
print "Read_1 : $entry->{read1}->{seq}
Read_2 : $entry->{read2}->{seq}";
}
Return: HashRef
{ read1 => 'see seqFileIterator() return',
read2 => 'see seqFileIterator() return'
}
pairedEndSeqFileIterator has no equivalent in Bio-Perl
=head2 gffFileIterator
manage GFF3 and GTF2 file format
Example:
my $it = gffFileIterator($file);
while (my $annot = $it->()) {
print "chr : $annot->{chr}
start : $annot->{start}
end : $annot->{end}";
}
Return a hashref with the annotation parsed:
{ chr => 'field_1',
source => 'field_2',
feature => 'field_3',
start => 'field_4',
end => 'field_5',
score => 'field_6',
strand => 'field_7',
frame => 'field_8'
attributes => { 'attribute_id' => 'attribute_value', ...}
}
gffFileIterator is B<5x faster than Bio-Perl> Bio::Tools::GFF
=head1 FILES IO
=head2 getReadingFileHandle
Return a file handle for the file in argument.
Display errors if file cannot be oppenned and manage gzipped files (based on .gz file extension)
Example:
my $fh = getReadingFileHandle('file.txt.gz');
while(<$fh>) {
print $_;
}
close $fh;
( run in 3.503 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )