NCBI-Hackathons / NovoGraph

NovoGraph: building whole genome graphs from long-read-based de novo assemblies
MIT License
44 stars 8 forks source link

added parameter specifying max. number processes run #25

Closed evanbiederstedt closed 4 years ago

evanbiederstedt commented 4 years ago

Related to this issue: https://github.com/NCBI-Hackathons/NovoGraph/issues/23

I added an optional parameter to use, as opposed to the default value of 10 in the line while(scalar(keys %still_running) >= 10)

I set the default value to 2---please feel free to use a larger value of course!

Previously, the script had the following code:

https://github.com/NCBI-Hackathons/NovoGraph/blob/master/scripts/launch_CRAM2VCF_C%2B%2B.pl#L102-L116

my %still_running;

if($totalCommands == 0)
{
    print "\nAll done.\n\n";
}
else
{
    foreach my $iI (@indices)
    {
        my $command = $commands[$iI];
        while(scalar(keys %still_running) >= 10)
        {
            sleep 10;
        }

        my $pid = fork;
        die "fork failed" unless defined $pid;
        if ($pid == 0) {
            system($command) and die "Could not execute command: $command";
            exit;
        }       
        $still_running{$pid} = 1;           
    }

    print "\n\nProcesses launched.\n";
}

I also added a check to make sure it's a positive integer.

There's probably a better name for this parameter---please come up with something!

TDIL: I'm also fascinated that apparently the colon : in GetOptions specifies an optional argument: https://stackoverflow.com/questions/6555644/how-to-use-getoptions-utility-to-handle-optional-command-line-arguments-in-per

evanbiederstedt commented 4 years ago

I'll merge away