This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to use multiple command in one line with using the output of last command to the next

I want to use several command in linux, and for second command I want to use the output of first and etc. I have tried this but im not sure that use the out put of first command for the second!

Thanks in advance!

bed file:

2       1376    1477    4
2       1477    1516    2
2       1516    1520    4
2       1520    1521    2

Command:

awk '$4 >=20 {print}' *.bed bedtools multiinter -i *.bed > output.bed
bedtools linux bed

... > file.ext - this syntax means you explicitly want to gather the information in to a file.

Instead, you want to pipe (|) the output to the next program.

Important to note:

  1. This directs the STDOUT, so ensure the information you want is in the STDOUT (it usually is)
  2. The program that comes next must accept STDOUT as input. If it expects a file, you need to do extra work.

I dont know using the "file.ext", is the good idea. There are several files *.bed. so this files at first shoud be filtered and then would use for the beedtools. the output of bedtools would be one file: out.bed. I used this command but it not work, it needs to be modified.

awk '$4 >=20  {print$0}'  *.bed  | bedtools multiinter -i  echo > output.bed

You don't need to use echo. The content will be printed to STDOUT anyway.

Suggest you spend some time learning the basics of Bash piping.

As it stands this question isn't really bioinformatics related and may be considered off-topic.

please, explain what you're trying to do with this/those(?) bed files.

At first i want to have a filter with column 4 and keep the data that (4 >=20), at second I want to use this files that filters for input of bedtools to finding overlapped sections.

something like ?

 bedtools multiinter -i *.bed | bedtools intersect -a - -b <( awk '$4 >=20' *.bed | cut -f1-3 | sort -t $'\t' -k1,1 -k2,2n | bedtools merge) 

Thanks so much dear Pierre I seems it works, I have a ouput as I expected, First can you tell me why you use both "multiinter and intersect"?

First can you tell me why you use both "multiinter and intersect"

please, read the manuals to understand the difference.

0 answers

No answers yet.

Log in to answer this question.