0

I am a Perl beginner. I have this Perl snippet

$normal_pileup = "samtools mpileup -q 1 -f XXXX YYYYY";
$tumor_pileup = "samtools mpileup -q 1 -f XXXX ZZZZZ";

bash -c \"java -jar ttt.jar  <\($normal_pileup\) <\($tumor_pileup\) output

They try to issue a system call that pipes input from these commands into a Java program. I couldn't make it work. Can anybody please tell me how to do it?

1
  • Is the line 'bash -c...' part of the perl script? It doesn't look like valid perl to me. Commented Aug 29, 2012 at 9:04

2 Answers 2

2

You cannot call bash directly from Perl. If you use system, though, /bin/sh will be called which probably does not support the process substitution.

One of possible workarounds is

system qq(echo 'java -jar ttt.jar  <($normal_pileup) <($tumor_pileup) output' | bash);
Sign up to request clarification or add additional context in comments.

Comments

1
$normal_pileup = "samtools mpileup -q 1 -f XXXX YYYYY";

will not execute any command but will just store samtools mpileup -q 1 -f XXXX YYYYY as a string. The same for $tumor_pileup.

If you want to execute the command use

$normal_pileup = `samtools mpileup -q 1 -f XXXX YYYYY`;

bash is not a Perl command.

`java -jar ttt.jar  ...`

You "java" is also most likely wrong

  • with < you specify where STDIN is read. Is supposed to be a file but in your case you are specifying the output of a previous command. This will only work if the output of samtool is a file name.

  • if you want your java program to process the output of another command you will need a pipe

    mycommand | java
    

Summarizing I suppose you want

` ( samtools mpileup -q 1 -f XXXX YYYYY; samtools mpileup -q 1 -f XXXX ZZZZZ ) | java -jar ttt.jar output `

3 Comments

thanks very much for your reply. My intention is to run two bash commands "samtools mpileup -q 1 -f XXXX YYYYY" and samtools mpileup -q 1 -f XXXX YYYYY. their output will be directly piped into java program as two parameters.
@user1632530 so both will not generate a stream of data but just a string? Could you give us an example output?
the problem is from usage of varscan. the original url is varscan.sourceforge.net/somatic-calling.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.