File: runner.sh

package info (click to toggle)
salmon 1.10.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,088 kB
  • sloc: cpp: 200,707; ansic: 171,082; sh: 859; python: 792; makefile: 238
file content (24 lines) | stat: -rw-r--r-- 737 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

cmd="$@"
interleaved_file=`echo $cmd | sed -n 's/.*--interleaved\s\+\(\S\+\)\s\+.*/\1/p'`

if [ -z "$interleaved_file" ]
then
    #Run normally in this branch
    ${@}
else
   new_cmd=`echo $cmd | sed 's/--interleaved\s\+\S\+\s\+//'`
   tmpdir=$(mktemp -d)
   # Cleanup on exit
   trap 'rm -rf "$tmpdir"' EXIT INT TERM HUP
   p1="$tmpdir/p1.fq"
   p2="$tmpdir/p2.fq"
    mkfifo $p1
    mkfifo $p2
    # The following interleaved to split conversion is courtesy of
    # https://gist.github.com/nathanhaigh/3521724
    (paste - - - - - - - - | tee >(cut -f 1-4 | tr '\t' '\n' > $p1) | cut -f 5-8 | tr '\t' '\n' > $p2) < $interleaved_file &
    echo "Running command [${new_cmd} -1 $p1 -2 $p2]"
    ${new_cmd} -1 $p1 -2 $p2
fi