[Bioperl-l] Bioperl add_object_condition

montalent montalen at moulon.inra.fr
Thu Apr 9 06:49:22 EDT 2009


Dear colleague,
I try to use add_object_condition() function, to get a subset of
sequences.
I try this :

# 1. STORE SELECTED BAC IN AN HASH TABLE : key = bac_name, value =
sequence
# 1.1 STORE SELECTED BAC NAME IN AN ARRAY
my @selected_bac_list=();
open (SELECTION, $bac_selection_file) or die "can not open
$bac_selection_file :$!\n";
while (my $line=<SELECTION>){
	my ($bac_name)=($line =~ /^(.+?);.+/);
#	print $bac_name."\n";
	push @selected_bac_list, $bac_name;
}

# 1.2 READ FASTA FILE WITH BIOPERL TO STORE IN AN HASH TABLE
my $bac_fasta= Bio::SeqIO->new(-file=>$maize_sequence_bac_file,
'-format'=>"Fasta");
my $builder = $bac_fasta->sequence_builder();

if ($builder->add_object_condition(sub {
	print " check \n";
	my $seq_ref=shift;
	if ($ref_seq->{'-length'} > 5000;){ return 0;}
	else {return 1;}
})){ print "add_object_condition renvoie true\n";}
else{ print "add_object_condition renvoie false\n";}

# for each sequence in fasta file, check if it is a selected bac
while(my $seq=$bac_fasta->next_seq()){
	print $seq->id."\n";			# PB : IT PRINTS ALL THE
SEQUENCE NOT THE SUBSET....
}

I can't get the sequences subset but all the sequences. So I make a
print() in the closure of add_object_condition, but nothing is printed.
It seems like it does not execute the sub in add_object_condition(), but
add_object_conditions return true value.


I try to use add_object_condition who seems to be a powerfull method,
but I do not succeed.

May I ask you some advice how to use add_object_condition() ? Do I
forget something ?


Best regards

Pierre Montalent
INRA - Ferme du moulon
France





More information about the Bioperl-l mailing list