tangledupinperl has asked for the wisdom of the Perl Monks concerning the following question:

Im running a script where it should read a 4 line txt which will point it to the input files. But its not. Im getting the:
WARNING there is no vector and splice information in the assignment file for the library
error as is at the bottom, but was confused by the way its checking the assignment file. Its definitely reading the .txt in the first place, and the paths in the .txt are correct, but im not perl-skilled enough (yet!) to be certain the script is right. so here we go!
Its got loads of $'s all through the 2100 line script and cant really paste all that but its the reading the $assignments (which is the .txt as defined earlier) that im concerned with
The script:
# Now we can run lucy several times, one for each library my $lib;my $in_s; my $in_q; my $vec; my $spli; my $out_s; my $ +out_q; for ($i=0;$i<$num_libraries;$i++){ if ($success){ # if something went wrong we should st +op $lib=$libraries[$i]; $in_s=$in_seq."$separator".$libraries[$i]; $in_q=$in_qual."$separator".$libraries[$i]; my $num_lib=position1(@{$$assignments{librarie +s}},$lib); $out_s=$out_seq."$separator".$libraries[$i]; $out_q=$out_qual."$separator".$libraries[$i]; #it could be libraries without vector and spli +ce site information, in that case we just copy #the input file to the output file if ($num_lib){ $vec=${$$assignments{vector_files}}[$n +um_lib-1]; $spli=${$$assignments{splice_files}}[$ +num_lib-1]; $success=run_lucy($config,$lib,$in_s,$ +in_q,$vec,$spli,$out_s,$out_q,$log,$bin_lucy); }else{ print localtime().": WARNING there is +no vector and splice information in the assignment file for the libra +ry $lib\n"; system ("ln -sf $in_s $out_s\n"); system ("ln -sf $in_q $out_q\n"); system ('echo "'.$lib.'" >> '.$not_luc +y); } } }

The assignments.txt (I have a definitive structure to adhere to and this is definitely right):
assignment library: gammarus vector file: /home/sbi6dap/est2uni/data/vector.fasta vector splice site file: /home/sbi6dap/est2uni/data/splice.fasta

Thanks for looking guys n galls

Replies are listed 'Best First'.
Re: why is my pm not finding the correct files
by roboticus (Chancellor) on Feb 20, 2009 at 13:17 UTC
    tangledupinperl:

    Based on the code and message you printed, it looks like your position1 function returns 0 when it fails. I'd suggest you use the debugger to set a breakpoint in your loop and/or in position1 and find out what values you're passing in.

    If the debugger is too intimidating right now, add a few print statements to the code to print variable values. I'd suggest printing the arguments to position1 and the return value, so you can see what's happening. Note: Data::Dumper is quite useful for this!

    ...roboticus
Re: why is my pm not finding the correct files
by Bloodnok (Vicar) on Feb 20, 2009 at 12:58 UTC
    You need to include more context, there is no evidence of the assignments file being opened, nor of the how the file gets parsed...or, put another way, I'm afraid you've omitted the very details that might enable us to help you:-(

    A user level that continues to overstate my experience :-))
Re: why is my pm not finding the correct files
by u671296 (Sexton) on Feb 20, 2009 at 15:19 UTC
    These statements
    $vec=${$$assignments{vector_files}}[$num_lib-1]; $spli=${$$assignments{splice_files}}[$num_lib-1];
    Look like they could be a problem. If $assignments{vector_files} is a reference to an array it may not be working as you expect. Do $vec and $spli contain the values you expect ?

    I usually code like this
    my $ref = $assignments{vector_files}; $vec=$$ref[$num_lib-1];
      I think that the arrays might be something to do with it. by filling the script with prints, it shows that the $vec and $spli are pointing correctly, and is giving arrays ie:
      libraries=ARRAY(0x8e04720) vector_files=/home/sbi6dap/est2uni/data/vector.fasta vector_info=ARRAY(0x8eefff4) splice_files=/home/sbi6dap/est2uni/data/splice.fasta splice_info=ARRAY(0x8e363c0)

      But im not entirely (or slightly) sure where that leaves me. Also, for the record, the vec and splice files are definately in the right format and what the program is expecting.
      Im going to get on the debugging asap, but if i dont go home and have some dinner first im going to starve to death or get locked in the building! neither of which sound fun on a friday night.
      Thanks
      Dan