App-Fasops

 view release on metacpan or  search on metacpan

lib/App/Fasops/Command/refine.pm  view on Meta::CPAN

    # There're no indels at all
    # Leave $info_ary untouched
    return if $indel_set->is_empty;

    {    # head indel(s) to be trimmed
        my $head_set = AlignDB::IntSpan->new;
        $head_set->add_pair( 1, $chop_length );
        my $head_indel_set = $indel_set->find_islands($head_set);

        # head indels
        if ( $head_indel_set->is_not_empty ) {
            for ( 1 .. $head_indel_set->max ) {
                for my $info ( @{$info_ary} ) {
                    my $base = substr( $info->{seq}, 0, 1, '' );
                    if ( $base ne '-' ) {
                        if ( $info->{strand} eq "+" ) {
                            $info->{start}++;
                        }
                        else {
                            $info->{end}--;
                        }

lib/App/Fasops/Command/refine.pm  view on Meta::CPAN

            }
        }
    }

    {    # tail indel(s) to be trimmed
        my $tail_set = AlignDB::IntSpan->new;
        $tail_set->add_range( $align_length - $chop_length + 1, $align_length );
        my $tail_indel_set = $indel_set->find_islands($tail_set);

        # tail indels
        if ( $tail_indel_set->is_not_empty ) {
            for ( $tail_indel_set->min .. $align_length ) {
                for my $info ( @{$info_ary} ) {
                    my $base = substr( $info->{seq}, -1, 1, '' );
                    if ( $base ne '-' ) {
                        if ( $info->{strand} eq "+" ) {
                            $info->{end}--;
                        }
                        else {
                            $info->{start}++;
                        }

lib/App/Fasops/Common.pm  view on Meta::CPAN

                # this section should already be judged in previes
                # uniq_indel_seqs section, but I keep it here for safe

                # reference indel content does not contain '-' and is not equal
                # to the one of alignment
                #     AAA
                #     A-A
                # ref ACA
                $indel_type = 'C';
            }
            elsif ( $outgroup_indel_set->intersect($indel_set)->is_not_empty ) {
                my $island = $outgroup_indel_set->find_islands($indel_set);
                if ( $island->equal($indel_set) ) {

                    #     NNNN
                    #     N--N
                    # ref N--N
                    $indel_type = 'I';
                }
                else {
                    # reference indel island is larger or smaller

t/03-names.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help names)] );
like( $result->stdout, qr{names}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(names)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(names t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(names t/example.fas -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 4, 'line count' );
like( $result->stdout, qr{S288c\s+YJM789\s+RM11\s+Spar}, 'name list' );

$result = test_app( 'App::Fasops' => [qw(names t/example.fas -c -o stdout)] );
like( $result->stdout, qr{S288c\t3.+Spar\t3}s, 'name count' );

done_testing();

t/04-subset.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help subset)] );
like( $result->stdout, qr{subset}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(subset)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(subset t/not_exists)] );
like( $result->error, qr{need two input files}, 'need infiles' );

$result = test_app( 'App::Fasops' => [qw(subset t/not_exists t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(subset t/example.fas t/example.name.list -o stdout)] );

is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 12, 'line count' );
like( ( split /\n\n/, $result->stdout )[0], qr{\>Spar.+\>YJM789}s, 'correct name order' );
unlike( ( split /\n\n/, $result->stdout )[0], qr{\>YJM789.+\>Spar}s, 'incorrect name order' );

$result
    = test_app(

t/05-covers.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help covers)] );
like( $result->stdout, qr{covers}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(covers)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(covers t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(covers t/example.fas -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 11, 'line count' );
like( $result->stdout, qr{RM11.+S288c.+Spar.+YJM789}s, 'name list' );

$result = test_app( 'App::Fasops' => [qw(covers t/example.fas -n S288c -l 50 -t 10 -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 2, 'line count' );
like( $result->stdout, qr{\-\-\-\s+I:\s+}s, 'one species' );

t/06-axt2fas.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help axt2fas)] );
like( $result->stdout, qr{axt2fas}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(axt2fas)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(axt2fas t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(axt2fas t/example.axt -t Scer-S288c)] );
like( $result->error, qr{alphanumeric}, 'check --tname' );

$result = test_app( 'App::Fasops' => [qw(axt2fas t/example.axt -q RM11-1a)] );
like( $result->error, qr{alphanumeric}, 'check --qname' );

$result = test_app( 'App::Fasops' => [qw(axt2fas t/example.axt -s t/RM11_1a.chr)] );
like( $result->error, qr{doesn't exist}, 'check --size' );

t/07-maf2fas.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help maf2fas)] );
like( $result->stdout, qr{maf2fas}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(maf2fas)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(maf2fas t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(maf2fas t/example.maf -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 16, 'line count' );
like( $result->stdout, qr{S288c\.VIII.+RM11_1a\.scaffold_12.+Spar\.gi_29362578}s, 'name list' );
like( $result->stdout, qr{42072\-42168}, 'change positions' );

$result = test_app( 'App::Fasops' => [qw(maf2fas t/example.maf -l 50 -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 8, 'line count' );

t/08-separate.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help separate)] );
like( $result->stdout, qr{separate}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(separate)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(separate t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(separate t/example.fas -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 24, 'line count' );

$result = test_app( 'App::Fasops' => [qw(separate t/example.fas --nodash --rc -o stdout)] );
unlike( $result->stdout, qr{\(\-\)}, 'strands' );
unlike( $result->stdout, qr{T\-C},   'nodash' );

done_testing();

t/09-links.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help links)] );
like( $result->stdout, qr{links}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(links)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(links t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(links t/example.fas --pair -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 18, 'line count' );
like( $result->stdout, qr{S288c.+\tYJM789}, 'name list' );

$result = test_app( 'App::Fasops' => [qw(links t/example.fas --best -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 9, 'line count' );
like( $result->stdout, qr{S288c.+\tYJM789}, 'name list' );

t/10-replace.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help replace)] );
like( $result->stdout, qr{replace}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(replace)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(replace t/not_exists)] );
like( $result->error, qr{need two input files}, 'need infiles' );

$result = test_app( 'App::Fasops' => [qw(replace t/not_exists t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(replace t/example.fas t/replace.tsv -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 32, 'line count' );
like( ( split /\n\n/, $result->stdout )[2], qr{\>S288c.+\>query}s, 'correct name order' );

$result = test_app( 'App::Fasops' => [qw(replace t/example.fas t/replace.fail.tsv -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 24, 'line count' );
unlike( $result->stdout, qr{target|query}, 'not replaced' );
like( $result->stderr, qr{multiply records}, 'error message' );

t/11-refine.t  view on Meta::CPAN

use App::Fasops;

my $result;

$result = test_app( 'App::Fasops' => [qw(help refine)] );
like( $result->stdout, qr{refine}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(refine)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(refine t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(refine t/example.fas --msa none -o stdout)] );
is( scalar( grep {/\S/} split( /\n/, $result->stdout ) ), 24, 'line count' );

$result = test_app( 'App::Fasops' => [qw(refine t/example.fas --msa none -p 2 -o stdout)] );
is( scalar( grep {/\S/} split( /\n/, $result->stdout ) ), 24, 'line count' );

$result = test_app( 'App::Fasops' => [qw(refine t/refine2.fas --msa none -o stdout)] );
is( scalar( grep {/\S/} split( /\n/, $result->stdout ) ), 6, 'line count' );

t/12-split.t  view on Meta::CPAN


use App::Fasops;
use App::Fasops::Common;

my $result = test_app( 'App::Fasops' => [qw(help split)] );
like( $result->stdout, qr{split}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(split)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(split t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(split t/example.fas -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 24, 'line count' );

$result = test_app( 'App::Fasops' => [qw(split t/example.fas -o stdout --simple)] );
like( $result->stdout, qr{^>S288c$}m, 'simple headers' );
unlike( $result->stdout, qr{I\(\+\)}, 'no positions' );

my Path::Tiny $tempdir = Path::Tiny::tempdir();

t/13-slice.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help slice)] );
like( $result->stdout, qr{slice}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(slice)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(slice t/not_exists)] );
like( $result->error, qr{need two input files}, 'need infiles' );

$result = test_app( 'App::Fasops' => [qw(slice t/not_exists t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(slice t/slice.fas t/slice.yml -n S288c -l 2 -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 6, 'line count' );
like( $result->stdout, qr{13301\-13400.+2511\-2636}s, 'sliced' );

done_testing();

t/14-join.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help join)] );
like( $result->stdout, qr{join}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(join)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(join t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app(
    'App::Fasops' => [
        qw(join t/S288cvsRM11_1a.slice.fas t/S288cvsYJM789.slice.fas t/S288cvsSpar.slice.fas -n S288c -o stdout)
    ]
);
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 8, 'line count' );
like( $result->stdout, qr{S288c.+RM11_1a.+YJM789.+Spar}s, 'name list' );

t/15-xlsx.t  view on Meta::CPAN


use App::Fasops;
use Spreadsheet::XLSX;

my $result = test_app( 'App::Fasops' => [qw(help xlsx)] );
like( $result->stdout, qr{xlsx}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(xlsx)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(xlsx t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

{    # population
    my $temp = Path::Tiny->tempfile;
    $result = test_app( 'App::Fasops' => [ qw(xlsx t/example.fas -o ), $temp->stringify ] );
    is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 3, 'line count' );
    like( $result->stdout, qr{Section \[4}, 'sections 4 writed' );

    my $xlsx  = Spreadsheet::XLSX->new( $temp->stringify );
    my $sheet = $xlsx->{Worksheet}[0];

t/16-check.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help check)] );
like( $result->stdout, qr{check}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(check)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(check t/not_exists)] );
like( $result->error, qr{need two input files}, 'need infiles' );

$result = test_app( 'App::Fasops' => [qw(check t/not_exists t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

SKIP: {
    skip "samtools not installed", 4 unless IPC::Cmd::can_run('samtools');

    $result
        = test_app(
        'App::Fasops' => [qw(check t/Arabid_thaliana.pair.fas t/NC_000932.fa -o stdout)] );
    is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 3, 'line count' );
    like( $result->stdout, qr{\tOK.+\tOK.+\tFAILED$}s, 'two OK and one FAILED' );

t/17-concat.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help concat)] );
like( $result->stdout, qr{concat}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(concat)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(concat t/not_exists)] );
like( $result->error, qr{need two input files}, 'need infiles' );

$result = test_app( 'App::Fasops' => [qw(concat t/not_exists t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(concat t/example.fas t/example.name.list -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 4, 'line count' );
is( length( ( grep {/\S/} split( /\n/, $result->stdout ) )[3] ), 239, 'line length' );
like( $result->stdout, qr{\>Spar\n.+\>YJM789\n}s, 'correct name order' );
unlike( $result->stdout, qr{\>YJM789\n.+\>Spar\n}s, 'incorrect name order' );

$result = test_app(
    'App::Fasops' => [qw(concat t/example.fas t/example.name.list --relaxed -o stdout)] );

t/18-stat.t  view on Meta::CPAN


use App::Fasops;
use Spreadsheet::XLSX;

my $result = test_app( 'App::Fasops' => [qw(help stat)] );
like( $result->stdout, qr{stat}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(stat)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(stat t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

# population
$result = test_app( 'App::Fasops' => [ qw(stat t/example.fas -o stdout) ] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 4, 'line count' );
like( $result->stdout, qr{,6\n}, 'indels without outgroup' );

$result = test_app( 'App::Fasops' => [ qw(stat t/example.fas -l 50 -o stdout) ] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 3, 'line count' );
like( $result->stdout, qr{,6\n}, 'indels without outgroup' );

t/19-mergecsv.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help mergecsv)] );
like( $result->stdout, qr{mergecsv}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(mergecsv)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(mergecsv t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result = test_app( 'App::Fasops' => [qw(mergecsv t/not_exists t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

$result
    = test_app( 'App::Fasops' => [qw(mergecsv t/links.copy.csv t/links.count.csv -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 5, 'line count' );
unlike( $result->stdout, qr{,count\n}, 'field count absents' );

$result
    = test_app( 'App::Fasops' => [qw(mergecsv t/links.copy.csv t/links.count.csv -c -o stdout)] );
is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 5, 'line count' );

t/20-consensus.t  view on Meta::CPAN

use App::Fasops;

my $result;

$result = test_app( 'App::Fasops' => [qw(help consensus)] );
like( $result->stdout, qr{consensus}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(consensus)] );
like( $result->error, qr{need .+input}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(consensus t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

SKIP: {
    skip "poa not installed", 4 unless IPC::Cmd::can_run('poa');

    $result = test_app( 'App::Fasops' => [qw(consensus t/refine.fas -o stdout)] );
    is( scalar( grep {/\S/} split( /\n/, $result->stdout ) ), 4, 'line count' );
    like( $result->stdout, qr{>consensus$}m,   'simple name' );
    like( $result->stdout, qr{>consensus\.I}m, 'fas name' );

t/21-vars.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help vars)] );
like( $result->stdout, qr{vars}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(vars)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(vars t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

# # population
# $result
#     = test_app( 'App::Fasops' => [qw(vars t/example.fas -o stdout)] );
# is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 5, 'line count' );
# unlike( $result->stdout, qr{,count\n}, 'field count absents' );

# population
$result = test_app( 'App::Fasops' => [qw(vars t/example.fas -o stdout)] );

t/22-create.t  view on Meta::CPAN

use App::Cmd::Tester;

use App::Fasops;

my $result = test_app( 'App::Fasops' => [qw(help create -g t/genome.fa)] );
like( $result->stdout, qr{create}, 'descriptions' );

$result = test_app( 'App::Fasops' => [qw(create -g t/genome.fa)] );
like( $result->error, qr{need .+input file}, 'need infile' );

$result = test_app( 'App::Fasops' => [qw(create -g t/genome.fa t/not_exists)] );
like( $result->error, qr{doesn't exist}, 'infile not exists' );

SKIP: {
    skip "samtools not installed", 4 unless IPC::Cmd::can_run('samtools');

    $result
        = test_app(
        'App::Fasops' => [qw(create t/I.connect.tsv -g t/genome.fa -o stdout)]
    );
    is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 8, 'line count' );



( run in 0.610 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )