Bio-Grep
view release on metacpan or search on metacpan
t/50.synopsis.t view on Meta::CPAN
}
# for retrieving up- and downstream regions,
# Vmatch internal sequence ids are required
# (no showdesc possible)
$sbe->search({
query => 'AGAGCCCT',
reverse_complement => 1,
mismatches => 1,
upstream => 30,
downstream => 30,
});
my @internal_ids;
while ( my $res = $sbe->next_res ) {
# vsubseqselect is called now for every result ...
push @internal_ids, $res->sequence_id;
}
# ... but one can retrieve all complete sequences with
# just one call of vseqselect
my $seq_io = $sbe->get_sequences(\@internal_ids);
EOT
;
eval $code;
ok(!code_eval($code),"Vmatch SYNOPSIS compiles") || diag $@;
$code =<<'EOT'
use Bio::Grep;
use Bio::SeqIO;
my $sbe = Bio::Grep->new('Vmatch');
my $out = Bio::SeqIO->new( -format => 'Fasta',
-file => '>motifs.fasta',
);
# you have an array with DNA sequences
my @motifs = ( 'aaaaaa', 'gggggg' );
for my $i (0 .. $#motifs ) {
my $seq = Bio::Seq->new(
-id => $i,
-seq => $motifs[$i],
);
$out->write_seq($seq);
}
$sbe->search({
datapath => 't/data',
database => 'ATH1.cdna',
query_file => 'motifs.fasta',
complete => 1,
});
EOT
;
ok(!code_eval($code),"Cookbook recipe motifs solution a compiles") || diag $@;
unlink 'motifs.fasta';
}
# Agrep
$backendname = 'Agrep';
SKIP:{
skip 'Agrep binary not in path', 1 if
BioGrepSkip::find_binary_in_path( lc($backendname) ) eq '';
delete_files;
mkdir 't/data';
my $code =<<'EOT'
use Bio::Grep;
my $sbe = Bio::Grep->new('Agrep');
# generate a database. you have to do this only once.
$sbe->generate_database({
file => 't/Test_DB_RevCom.fasta',
description => 'AGI Transcripts',
datapath => 'data',
});
# search for the reverse complement and allow 2 mismatches
# Don't calculate Alignments with EMBOSS
$sbe->search({
query => 'GAGCCCTT',
reverse_complement => 1,
mismatches => 2,
no_alignments => 1,
database => 'ATH1.cdna',
});
my @internal_ids;
# output the searchresults with nice alignments
while ( my $res = $sbe->next_res) {
print $res->sequence->id . "\n";
# print $res->alignment_string() . "\n\n";
push @internal_ids, $res->sequence_id;
}
# get the complete sequences as Bio::SeqIO object
my $seq_io = $sbe->get_sequences(\@internal_ids);
EOT
;
ok(!code_eval($code),"Agrep SYNOPSIS compiles") || diag $@;
}
# GUUGle
$backendname = 'GUUGle';
SKIP:{
t/50.synopsis.t view on Meta::CPAN
my $sbe = Bio::Grep->new('RE');
$sbe->settings->datapath('data');
# generate a database. you have to do this only once.
$sbe->generate_database({
file => 't/Test_DB_RevCom.fasta',
description => 'AGI Transcripts',
datapath => 'data',
});
# search on both strands
# retrieve up- and downstream regions of size 30
$sbe->search({
query => 'GAGCCCTT',
direct_and_rev_com => 1,
upstream => 30,
downstream => 30,
database => 'ATH1.cdna',
});
my @internal_ids;
# output the searchresults with nice alignments
while ( my $res = $sbe->next_res) {
print $res->sequence->id . "\n";
print $res->mark_subject_uppercase() . "\n";
print $res->alignment_string() . "\n\n";
push @internal_ids, $res->sequence_id;
}
# get the complete sequences as Bio::SeqIO object
my $seq_io = $sbe->get_sequences(\@internal_ids);
# sequences with at least 10 As
$sbe->search({ query => '[A]{10,}' });
# some SNPs
$sbe->search({query => '[CG]TGC[AT]CTCTTCT[CG]TCA'});
EOT
;
ok(!code_eval($code),"RE SYNOPSIS compiles") || diag $@;
$code =<<'EOT'
use Bio::Grep;
my $sbe = Bio::Grep->new('RE');
my $motif = '[AC]{4}TAAAA[AGCT]GG';
$sbe->search({
datapath => 't/data',
database => 'Test_DB_RevCom.fasta',
query => $motif,
});
EOT
;
eval $code;
ok(!$@,"Cookbook recipe motifs solution b compiles") || diag $@;
$code = 'bllll';
eval $code;
ok(code_eval($code),"bllll not compiles");
delete_files;
rmdir('t/tmp');
rmdir('t/data');
rmdir('t/data2');
sub code_eval {
my ( $code ) = @_;
$code =~ s/ATH1.cdna/Test_DB_RevCom.fasta/g;
$code =~ s{'data'}{'t/data'}g;
$code =~ s{generate_database\('T}{generate_database('t/T}g;
# diag $code;
eval $code;
return $@;
}
1;
# vim: ft=perl sw=4 ts=4 expandtab
( run in 0.551 second using v1.01-cache-2.11-cpan-e1769b4cff6 )