NAME

Proch::N50 is a small module to calculate N50 (total size, and total number of sequences) for a FASTA or FASTQ file. It's small and without dependencies.

SYNOPSIS

use Proch::N50 qw(getStats getN50);
my $filepath = '/path/to/assembly.fasta';

# Get N50 only
say "N50 only:\t" ,getN50($filepath);

# Full stats
my $seq_stats = getStats($filepath);
say Data::Dumper->Dump( [ $seq_stats ], [ qw(*FASTA_stats) ] );

METHODS

getN50(filepath)

This function returns the N50 for a FASTA/FASTQ file given, or 0 in case of error(s).

getStats(filepath, alsoJSON)

Calculates N50 and basic stats for <filepath>. Returns also JSON if invoked with a second parameter. This function return a hash reporting:

size

total number of bp in the files

N50

the actual N50

seqs

total number of sequences in the files

filename

file basename of the input file

dirname

name of the directory containing the input file

json

JSON string of the object (only if JSON is installed)

Dependencies

JSON (optional)

AUTHOR

Andrea Telatin <andrea@telatin.com>

COPYRIGHT AND LICENSE

This free software under MIT licence. No warranty, explicit or implicit, is provided.