File: runner.sh

package info (click to toggle)
salmon 0.7.2%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,352 kB
  • ctags: 5,243
  • sloc: cpp: 42,341; ansic: 6,252; python: 228; makefile: 207; sh: 190
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