The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Need Emergency PERL help!

surrealitychecksurrealitycheck lonely, but not unloveddreaming of faulty keys and latchesRegistered User regular
Sorry for the title, but this is for my dissertation and is a matter of some urgency. I am using a PERL script to look for repeat sequences in various pathogenic and nonpathogenic bacteria, and it is throwing out errors at me. This script has worked for others, but also others have had this error (although I do not know how they resolved it). The error is

print() on closed filehandle OUT at 1-DirectRepeatfinder.pl line 344

The line in question is

print OUT "FT repeat_unit ", "$START", "..", "$STOP", "\n", "FT

This line is also causing issues:

print OUT "$WORD\t$START\n";

Anybody have any ideas what is going on?

3fpohw4n01yj.png
surrealitycheck on

Posts

  • Apothe0sisApothe0sis Have you ever questioned the nature of your reality? Registered User regular
    edited May 2010
    I think we'd need more information - sample data and the script in question?

    The issue is that the handle OUT is being closed somewhere, but it's hard to see how or why without more context.

    Apothe0sis on
  • surrealitychecksurrealitycheck lonely, but not unloved dreaming of faulty keys and latchesRegistered User regular
    edited May 2010
    One sec, let me upload them somewhere.

    http://www.megaupload.com/?d=RONKLTMT

    To run this script you'll need:

    Activeperl 5.10 - http://www.activestate.com/activeperl/

    BioPerl - http://bioperl.open-bio.org/wiki/Installing_Bioperl_on_Windows (follow the "GUI Installation" further down the page)

    I googled around and some people have had this problem before, but no solutions.

    surrealitycheck on
    3fpohw4n01yj.png
  • surrealitychecksurrealitycheck lonely, but not unloved dreaming of faulty keys and latchesRegistered User regular
    edited May 2010
    That file is a truncated fasta sequence, should take 30 secs to 1 minute to run. The genomes I'm running this on take 1-2 hours per genome then at the end refuse to dump the output files, it's driving me insane. In theory it should produce 2 output files.

    surrealitycheck on
    3fpohw4n01yj.png
  • Apothe0sisApothe0sis Have you ever questioned the nature of your reality? Registered User regular
    edited May 2010
    It sounds a lot like the format of the files are confusing it somewhat and it's falling into a big loop or group of loops and then crashing and burning. I'll take a look now.

    I'm not the best perl guy there is though, a few of the guys in the Programming thread are probably greatly my superior.

    Apothe0sis on
  • Apothe0sisApothe0sis Have you ever questioned the nature of your reality? Registered User regular
    edited May 2010
    I haven't had a chance to try this yet as I've not had a chance to much around in my environment but I'd add

    unless ( open( OUT, ">>$REPEAT_FT" ) ) {
    die "Could not open out file "$REPEAT_FT"\n";
    }

    or add an "or die "Could not open out file "$REPEAT_FT"\n";" etc etc at the end of the lines in question. Take a look at what they're saying. From the way it works it shouldn't be able to get to the printing lines without first trying to open the OUT handle so it should only appear closed when that fails. I think. If I had to put money on it, now that I've seen it, I'd probably check out whether the arguments you're passing are appropriately formed. There doesn't seem to be a lot of error checking on the args.

    Apothe0sis on
  • surrealitychecksurrealitycheck lonely, but not unloved dreaming of faulty keys and latchesRegistered User regular
    edited May 2010
    Any help would be hugely appreciated, I'm running on a brutally tight schedule here and the bioperl website is down, so I'm having difficulty running the scripts on other pcs.

    surrealitycheck on
    3fpohw4n01yj.png
  • dmitdmit Registered User regular
    edited May 2010
    The script takes the first 15 characters of the input file and uses them in the filenames for output files, that's why it failed - '|' is not a valid filename character.

    To fix this, change line 127 from
    $HANDLE =~ s/\s/_/g;
    
    to
    $HANDLE =~ s/\W/_/g;
    

    dmit on
  • surrealitychecksurrealitycheck lonely, but not unloved dreaming of faulty keys and latchesRegistered User regular
    edited May 2010
    dmit you are a GOD

    I thank you

    You have 3 internet points. Spend them wisely.

    EDIT: Out of interest what does that change actually do, explicitly?

    surrealitycheck on
    3fpohw4n01yj.png
  • GdiguyGdiguy San Diego, CARegistered User regular
    edited May 2010
    dmit wrote: »
    The script takes the first 15 characters of the input file and uses them in the filenames for output files, that's why it failed - '|' is not a valid filename character.

    To fix this, change line 127 from
    $HANDLE =~ s/\s/_/g;
    
    to
    $HANDLE =~ s/\W/_/g;
    

    Perl regular expressions: http://perldoc.perl.org/perlretut.html
    \d matches a digit, not just [0-9] but also digits from non-roman scripts
    \s matches a whitespace character, the set [\ \t\r\n\f] and others
    \w matches a word character (alphanumeric or _), not just [0-9a-zA-Z_] but also digits and characters from non-roman scripts
    \D is a negated \d; it represents any other character than a digit, or [^\d]
    \S is a negated \s; it represents any non-whitespace character [^\s]
    \W is a negated \w; it represents any non-word character [^\w]

    So when you use \s in the first one, you're deleting anything that's a space; that leaves all sorts of weird characters (| \ / ; : etc etc)... if you match \W instead, you'll delete anything that's not a digit or character

    Gdiguy on
  • surrealitychecksurrealitycheck lonely, but not unloved dreaming of faulty keys and latchesRegistered User regular
    edited May 2010
    Thank you, handy to know.

    surrealitycheck on
    3fpohw4n01yj.png
Sign In or Register to comment.