extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/scripts/fix_cufflinks_tracking_id.sh

Code
Comments
Other
Rev Date Author Line
6675 13 Apr 22 nicklas 1 #!/bin/sh
6675 13 Apr 22 nicklas 2
6675 13 Apr 22 nicklas 3 # $Id$
6675 13 Apr 22 nicklas 4
6675 13 Apr 22 nicklas 5 # Nicklas Nordborg, 2014
6675 13 Apr 22 nicklas 6 #
6675 13 Apr 22 nicklas 7 # Replaces tracking_id and gene_id values in Cufflinks
6675 13 Apr 22 nicklas 8 # *.fpkm_tracking files
6675 13 Apr 22 nicklas 9 #
6675 13 Apr 22 nicklas 10 # The values to search for and their replacement values must
6675 13 Apr 22 nicklas 11 # be defined in the file given as a parameter to this script.
6675 13 Apr 22 nicklas 12 # This file must have at least two columns. The second column
6675 13 Apr 22 nicklas 13 # contain the values to look for and the first column is the 
6675 13 Apr 22 nicklas 14 # replacement values.
6675 13 Apr 22 nicklas 15 #
6675 13 Apr 22 nicklas 16 # The script then read stdin, perform the replacement and
6675 13 Apr 22 nicklas 17 # write the result to stdout
6675 13 Apr 22 nicklas 18 #
6675 13 Apr 22 nicklas 19 # Script inspired by post on http://www.unix.com/302448486-post6.html
6675 13 Apr 22 nicklas 20 #
6675 13 Apr 22 nicklas 21 # run ./fix_cufflinks_tracking_id.sh path/to/map-file < infile > outfile
6675 13 Apr 22 nicklas 22 #
6675 13 Apr 22 nicklas 23
6675 13 Apr 22 nicklas 24 awk 'NR==FNR {a[$2]=$1;next} {for (i in a) gsub(i,a[i])}1' $1 /dev/stdin