Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: How to make a hash to evaluate columns between large datasets

by FreeBeerReekingMonk (Deacon)
on Aug 25, 2018 at 00:30 UTC ( [id://1221067]=note: print w/replies, xml ) Need Help??


in reply to Re^4: How to make a hash to evaluate columns between large datasets
in thread How to make a hash to evaluate columns between large datasets

If you are still implementing threads: Don't forget to use flock while writing to file inside the threads, something like this:

use threads; use Fcntl qw(:flock SEEK_END); if ($end >= $ref->{start} && $end <= $ref->{end}) { lock($out_fh); say $out_fh join("\t", $ID, $strand, $chr, $start, $end, $sequence +, $numPositions, $mismatches||"", $ref->{info}); unlock($out_fh); } sub lock { my ($fh) = @_; flock($fh, LOCK_EX) or die $!; seek($fh, 0, SEEK_END) or die $!; } sub unlock { my ($fh) = @_; flock($fh, LOCK_UN) or die $!; }

Alternatively, use shared objects (collect it in an array or hash) and write it down later.

  • Comment on Re^5: How to make a hash to evaluate columns between large datasets
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1221067]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found