Bio-Palantir

 view release on metacpan or  search on metacpan

bin/extract_bgc_sequences.pl  view on Meta::CPAN

#!/usr/bin/env perl
# PODNAME: extract_bgc_sequences.pl
# ABSTRACT: Extracts protein sequences for different BGC scales into a FASTA file
# CONTRIBUTOR: Denis BAURAIN <denis.baurain@uliege.be>

use Modern::Perl '2011';
use autodie;

use Smart::Comments;

use Carp;
use Getopt::Euclid qw(:vars);

use aliased 'Bio::Palantir::Parser';
use aliased 'Bio::Palantir::Refiner::ClusterPlus';

# check BGC type
if (@ARGV_types) {
    Parser->is_cluster_type_ok(@ARGV_types);
}

# report parsing
my $report = Parser->new(
    file => $ARGV_report_file,
    module_delineation => $ARGV_module_delineation,
);

my $root = $report->root;

my $prefix = $ARGV_prefix ? $ARGV_prefix . '@' : '';

my @clusters
    = $ARGV_annotation eq 'palantir'
    ? map { ClusterPlus->new(
        _cluster => $_,
        module_delineation => $ARGV_module_delineation) } $root->all_clusters
    : $root->all_clusters
;

open my $out, '>', $ARGV_outfile;

CLUSTER:
for my $cluster (@clusters) {

    if (@ARGV_types) {
        next CLUSTER unless 
            grep { $cluster->type =~ m/$_/xmsi } @ARGV_types;
    }

    if ($ARGV_scale eq 'cluster') {

        my @genes = sort { $a->rank <=> $b->rank } $cluster->all_genes;
    
        say {$out} '>' . $prefix . 'Cluster' . $cluster->rank;
        say {$out} join '', map { $_->protein_sequence } @genes;

    }

    elsif ($ARGV_scale eq 'gene' || $ARGV_scale eq 'domain') {

        for my $gene ( sort { $a->rank <=> $b->rank } $cluster->all_genes) {
            
            my @domains;
            for my $domain (sort { $a->rank <=> $b->rank } $gene->all_domains) {

                if ($ARGV_scale eq 'domain') {



( run in 1.384 second using v1.01-cache-2.11-cpan-b16cb0d3907 )