App-Egaz

 view release on metacpan or  search on metacpan

t/02-commands.t  view on Meta::CPAN

use warnings;
use Test::More tests => 3;
use App::Cmd::Tester;

use App::Egaz;

my $result = test_app( 'App::Egaz' => [qw(commands )] );

like( $result->stdout, qr{list the application's commands}, 'default commands outputs' );

is( $result->stderr, '', 'nothing sent to sderr' );

is( $result->error, undef, 'threw no exceptions' );

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

    my $t_path = Path::Tiny::path("t/")->absolute->stringify;
    my $cwd    = Path::Tiny->cwd;

    my $tempdir = Path::Tiny->tempdir;
    chdir $tempdir;

    Path::Tiny::path($t_path, "pseudocat.fa")->copy(".");

    $result = test_app( 'App::Egaz' => [qw(partition pseudocat.fa) ] );
    is($result->stdout, '', 'nothing sent to stdout');
    is($result->stderr, '', 'nothing sent to sderr');
    ok($tempdir->child('pseudocat.fa[1,18803]')->is_file, 'partitioned file exists');

    $tempdir->child('pseudocat.fa[1,18803]')->remove;

    $result = test_app( 'App::Egaz' => [qw(partition --chunk 5000 --overlap 100 pseudocat.fa) ] );
    ok($tempdir->child('pseudocat.fa[1,5100]')->is_file, 'partitioned file exists');
    ok($tempdir->child('pseudocat.fa[5001,10100]')->is_file, 'partitioned file exists');

    chdir $cwd;    # Won't keep tempdir
}

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


SKIP: {
    skip "makeblastdb or blastn not installed", 5
        unless IPC::Cmd::can_run('makeblastdb')
        and IPC::Cmd::can_run('blastn');

    $result = test_app( 'App::Egaz' => [qw(blastn t/pig2.fa t/pseudopig.fa --verbose)] );
    is( $result->error, undef, 'threw no exceptions' );
    is( ( scalar grep { !/^#/ } grep {/\S/} split( /\n/, $result->stdout ) ), 1, 'line count' );
    ok( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ) > 1, 'line count with comments' );
    is( ( scalar grep {/\S/} split( /\n/, $result->stderr ) ), 2, 'stderr line count' );
    like( $result->stdout, qr{pig2\tpig2}, 'target exists' );
}

done_testing();

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

    my $lav    = join "", grep {/\s+l /} Path::Tiny::path("[pseudocat]vs[pseudopig].0.lav")->lines;
    is( $lav, $expect, 'matched with expect' );

    $result = test_app(
        'App::Egaz' => [
            "lastz", "$t_path/pseudocat.fa", "$t_path/pseudopig.fa", "--set", "set01", "-C", "0",
            "-v"
        ]
    );
    ok( $tempdir->child("[pseudocat]vs[pseudopig].1.lav")->is_file, 'second lav file exists' );
    like( $result->stderr, qr{set01},          '--set passed' );
    like( $result->stderr, qr{C=0},            '-C passed' );
    like( $result->stderr, qr{matrix/similar}, '-Q passed' );

    chdir $cwd;    # Won't keep tempdir
}

SKIP: {
    skip "lastz not installed", 2 unless IPC::Cmd::can_run('lastz') and IPC::Cmd::can_run('egaz');

    my $t_path = Path::Tiny::path("t/")->absolute->stringify;
    my $cwd    = Path::Tiny->cwd;

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

        and IPC::Cmd::can_run('samtools');

    my $t_path = Path::Tiny::path("t/")->absolute->stringify;
    my $cwd    = Path::Tiny->cwd;

    my $tempdir = Path::Tiny->tempdir;
    chdir $tempdir;

    $result = test_app( 'App::Egaz' => [ "prepseq", "$t_path/pseudopig.fa", "-v", ] );
    is( $result->stdout, '', 'no stdout' );
    is( ( scalar grep {/^CMD/} grep {/\S/} split( /\n/, $result->stderr ) ),
        5, '5 commands executed' );
    like( $result->stderr, qr{outdir}, 'default --outdir' );
    ok( $tempdir->child("pig1.fa")->is_file,       'pig1.fa exists' );
    ok( $tempdir->child("pig2.fa")->is_file,       'pig2.fa exists' );
    ok( $tempdir->child("chr.sizes")->is_file,     'chr.sizes exists' );
    ok( $tempdir->child("chr.2bit")->is_file,      'chr.2bit exists' );
    ok( $tempdir->child("chr.fasta")->is_file,     'chr.fasta exists' );
    ok( $tempdir->child("chr.fasta.fai")->is_file, 'chr.fasta.fai exists' );

    $tempdir->child("chr.sizes")->remove;
    $tempdir->child("chr.2bit")->remove;
    $tempdir->child("chr.fasta")->remove;
    $tempdir->child("chr.fasta.fai")->remove;

    $result = test_app( 'App::Egaz' => [ "prepseq", ".", "-v", ] );
    is( ( scalar grep {/^CMD/} grep {/\S/} split( /\n/, $result->stderr ) ),
        6, '6 commands executed' );
    ok( $tempdir->child("chr.sizes")->is_file, 'chr.sizes exists' );
    ok( $tempdir->child("chr.2bit")->is_file,  'chr.2bit exists' );

    chdir $cwd;    # Won't keep tempdir
}

SKIP: {
    skip "faops or faToTwoBit or RepeatMasker not installed", 6
        unless IPC::Cmd::can_run('faops')

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

    my $t_path = Path::Tiny::path("t/")->absolute->stringify;
    my $cwd    = Path::Tiny->cwd;

    my $tempdir = Path::Tiny->tempdir;
    chdir $tempdir;

    $result
        = test_app( 'App::Egaz' =>
            [ "lpcnam", "$t_path/pseudocat", "$t_path/pseudopig", "$t_path/default.lav", "-v", ] );
    is( $result->stdout, '', 'no stdout' );
    is( ( scalar grep {/^CMD/} grep {/\S/} split( /\n/, $result->stderr ) ),
        13, '13 commands executed' );
    ok( $tempdir->child("noClass.net")->is_file,           'noClass.net exists' );
    ok( $tempdir->child("all.chain.gz")->is_file,          'all.chain.gz exists' );
    ok( $tempdir->child("all.pre.chain.gz")->is_file,      'all.pre.chain.gz exists' );
    ok( $tempdir->child("over.chain.gz")->is_file,         'over.chain.gz exists' );
    ok( $tempdir->child("lav.tar.gz")->is_file,            'lav.tar.gz exists' );
    ok( $tempdir->child("psl.tar.gz")->is_file,            'psl.tar.gz exists' );
    ok( $tempdir->child("net.tar.gz")->is_file,            'net.tar.gz exists' );
    ok( $tempdir->child("chain.tar.gz")->is_file,          'chain.tar.gz exists' );
    ok( $tempdir->child("axtNet/cat.net.axt.gz")->is_file, 'cat.net.axt.gz exists' );

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

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

    my $t_path = Path::Tiny::path("t/")->absolute->stringify;
    my $cwd    = Path::Tiny->cwd;

    my $tempdir = Path::Tiny->tempdir;
    chdir $tempdir;

    $result = test_app( 'App::Egaz' => [ "multiz", "$t_path/Q_rubravsQ_aliena", "-o", "." ] );
    like( $result->stderr, qr{.maf.gz files: \[1\]}, 'STDERR: .maf file count' );
    like( $result->stderr, qr{too few species},      'STDERR: too few species' );
    ok( $tempdir->child("NC_020152.synNet.maf.gz")->is_file, '.maf file exists' );

    chdir $cwd;    # Won't keep tempdir
}

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

    my $t_path = Path::Tiny::path("t/")->absolute->stringify;
    my $cwd    = Path::Tiny->cwd;

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

    my $tempdir = Path::Tiny->tempdir;
    chdir $tempdir;

    $result = test_app(
        'App::Egaz' => [
            "multiz",                           "$t_path/Q_rubravsQ_aliena",
            "$t_path/Q_rubravsQ_aquifolioides", "$t_path/Q_rubravsQ_baronii", "--tree",
            "$t_path/Quercus.nwk"
        ]
    );
    like( $result->stderr, qr{Q_rubra appears 3 times},              'STDERR: find target' );
    like( $result->stderr, qr{Target chromosomes are \[NC_020152\]}, 'STDERR: target chromosomes' );
    like( $result->stderr, qr{outdir set to \[Q_rubra_n4\]},         'STDERR: set --outdir' );
    like(
        $result->stderr,
        qr{Order of stitch \[Q_aliena Q_aquifolioides Q_baronii\]},
        'STDERR: Order of stitch'
    );
    ok( $tempdir->child("Q_rubra_n4/info.yml")->is_file,         'info.yml exists' );
    ok( $tempdir->child("Q_rubra_n4/steps.csv")->is_file,        'steps.csv exists' );
    ok( $tempdir->child("Q_rubra_n4/NC_020152.maf.gz")->is_file, '.maf.gz exists' );

    my @csv_lines = grep {/\S+/} Path::Tiny::path("Q_rubra_n4/steps.csv")->lines;
    is( scalar @csv_lines, 3, 'csv line count' );
    is( $csv_lines[0], "step,spe1,spe2,maf1,maf2,out1,out2,size,per_size\n", 'csv header' );

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


    my $tempdir = Path::Tiny->tempdir;
    chdir $tempdir;

    $result = test_app(
        'App::Egaz' => [
            "multiz", "$t_path/Q_rubravsQ_aliena", "$t_path/Q_rubravsQ_aquifolioides",
            "--target", "Q_rubra"
        ]
    );
    like( $result->stderr, qr{Assigned target \[Q_rubra\] is OK}, 'STDERR: assigned target OK' );

    $result = test_app(
        'App::Egaz' => [
            "multiz",                           "$t_path/Q_rubravsQ_aliena",
            "$t_path/Q_rubravsQ_aquifolioides", "--target",
            "Q_aliena"
        ]
    );
    like( $result->error, qr{Assigned target \[Q_aliena\] isn't OK},
        'STDERR: assigned target NOK' );

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

    my $t_path = Path::Tiny::path("t/")->absolute->stringify;
    my $cwd    = Path::Tiny->cwd;

    my $tempdir = Path::Tiny->tempdir;
    chdir $tempdir;

    $result = test_app(
        'App::Egaz' => [ "repeatmasker", "$t_path/pseudocat.fa", "--gff", "--verbose", ] );

    is( $result->error, undef, 'threw no exceptions' );
    is( ( scalar grep {/\S/} split( /\n/, $result->stderr ) ), 2, 'stderr line count' );
    is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 0, 'no stdout' );
    ok( $tempdir->child("pseudocat.fa")->is_file,     'pseudocat.fa exists' );
    ok( $tempdir->child("pseudocat.rm.out")->is_file, 'pseudocat.rm.out exists' );
    ok( $tempdir->child("pseudocat.rm.gff")->is_file, 'pseudocat.rm.gff exists' );
    is( `faops size $t_path/pseudocat.fa`, `faops size pseudocat.fa`, 'same length' );

    chdir $cwd;    # Won't keep tempdir
}

done_testing();

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


    my $tempdir = Path::Tiny->tempdir;
    chdir $tempdir;

    test_app(
        'App::Egaz' => [ "blastn", "$t_path/pig2.fa", "$t_path/pseudopig.fa", "-o", "pig.blast", ]
    );
    ok( $tempdir->child("pig.blast")->is_file, 'pig.blast exists' );

    $result = test_app( 'App::Egaz' => [qw(blastmatch pig.blast)] );
    is( ( scalar grep {/\S/} split( /\n/, $result->stderr ) ), 5, 'stderr line count' );
    is( ( scalar grep { !/^#/ } grep {/\S/} split( /\n/, $result->stdout ) ), 1, 'line count' );
    like( $result->stdout, qr{pig2:1-22929}, 'target exists' );

    chdir $cwd;    # Won't keep tempdir
}

done_testing();

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

    test_app(
        'App::Egaz' => [
            "blastn",                    "$t_path/Q_rubra.multi.fas",
            "$t_path/Q_rubra.multi.fas", "-o",
            "Q_rubra.blast",
        ]
    );
    ok( $tempdir->child("Q_rubra.blast")->is_file, 'Q_rubra.blast exists' );

    $result = test_app( 'App::Egaz' => [qw(blastlink Q_rubra.blast)] );
    is( ( scalar grep {/\S/} split( /\n/, $result->stderr ) ), 2, 'stderr line count' );
    is( ( scalar grep { !/^#/ } grep {/\S/} split( /\n/, $result->stdout ) ), 2, 'line count' );
    like( $result->stdout, qr{90542-116412.+135434-161304}, 'forward match' );
    like( $result->stdout, qr{135434-161304.+90542-116412}, 'reverse match' );

    chdir $cwd;    # Won't keep tempdir
}

done_testing();

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

    my $cwd    = Path::Tiny->cwd;

    my $tempdir = Path::Tiny->tempdir;
    chdir $tempdir;

    $result = test_app(
        'App::Egaz' => [
            "fas2vcf", "$t_path/YDL184C.fas", "$t_path/S288c.chr.sizes", "-o", "YDL184C.vcf", "-v",
        ]
    );
    is( ( scalar grep {/\S/} split( /\n/, $result->stderr ) ), 3, 'stderr line count' );
    ok( $tempdir->child("YDL184C.vcf")->is_file, 'YDL184C.vcf exists' );

    $tempdir->child("name.list")->spew( map {"$_\n"} qw{S288c YJM789} );
    $result = test_app(
        'App::Egaz' => [
            "fas2vcf", "$t_path/example.fas", "$t_path/S288c.chr.sizes", "--list", "name.list",
            "-o", "example.vcf", "-v",
        ]
    );
    is( ( scalar grep {/\S/} split( /\n/, $result->stderr ) ), 3, 'stderr line count' );
    is( ( scalar grep {/^CMD/} grep {/\S/} split( /\n/, $result->stderr ) ), 2, 'CMD count' );

    # can't capture stdout
    my $content = $tempdir->child("example.vcf")->slurp;
    like( $content, qr{ID=I,length=230218}, '##contig exists' );
    unlike( $content, qr{Spar}, 'Spar gone' );
    ok( ( scalar grep { !/^#/ } grep {/\S/} split( /\n/, $content ) ) > 40, 'SNP count' );

    chdir $cwd;    # Won't keep tempdir
}

t/91-template.t  view on Meta::CPAN

            "--vcf",    "--aligndb",         "--verbose",
        ]
    );

    is( $result->error, undef, 'threw no exceptions' );
    is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 0, 'no stdout' );
    ok( $tempdir->child("1_pair.sh")->is_file,          '1_pair.sh exists' );
    ok( $tempdir->child("4_vcf.sh")->is_file,           '4_vcf.sh exists' );
    ok( $tempdir->child("6_chr_length.sh")->is_file,    '6_chr_length.sh exists' );
    ok( $tempdir->child("7_multi_aligndb.sh")->is_file, '7_multi_aligndb.sh exists' );
    like( $result->stderr, qr{name: pseudocat.+name: pseudopig}s, 'names and directories' );

    chdir $cwd;    # Won't keep tempdir
}

{
    my $t_path = Path::Tiny::path("t/")->absolute->stringify;
    my $cwd    = Path::Tiny->cwd;

    my $tempdir = Path::Tiny->tempdir;
    chdir $tempdir;

t/91-template.t  view on Meta::CPAN

            "template", "$t_path/pseudocat", "$t_path/pseudopig", "--self",
            "--circos", "--aligndb",         "--verbose",
        ]
    );

    is( $result->error, undef, 'threw no exceptions' );
    is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 0, 'no stdout' );
    ok( $tempdir->child("1_self.sh")->is_file,       '1_self.sh exists' );
    ok( $tempdir->child("4_circos.sh")->is_file,     '4_circos.sh exists' );
    ok( $tempdir->child("6_chr_length.sh")->is_file, '6_chr_length.sh exists' );
    like( $result->stderr, qr{name: pseudocat.+name: pseudopig}s, 'names and directories' );

    chdir $cwd;    # Won't keep tempdir
}

{
    my $t_path = Path::Tiny::path("t/")->absolute->stringify;
    my $cwd    = Path::Tiny->cwd;

    my $tempdir = Path::Tiny->tempdir;
    chdir $tempdir;

t/91-template.t  view on Meta::CPAN

    $result = test_app(
        'App::Egaz' => [
            "template", "$t_path", "--prep",    "--suffix", ".fa", "--verbose",
            "--suffix", ".fa",     "--exclude", "pig",
        ]
    );

    is( $result->error, undef, 'threw no exceptions' );
    is( ( scalar grep {/\S/} split( /\n/, $result->stdout ) ), 0, 'no stdout' );
    ok( $tempdir->child("0_prep.sh")->is_file, '0_prep.sh exists' );
    like( $result->stderr, qr{basename: pseudocat}s, 'basenames' );

    chdir $cwd;    # Won't keep tempdir
}

done_testing();



( run in 2.527 seconds using v1.01-cache-2.11-cpan-a9ef4e587e4 )