-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc
359 lines (326 loc) · 11.3 KB
/
bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
#############################################
### SETUP
# shopt -s autocd checkjobs
shopt -s histverify histreedit histappend
export HISTCONTROL=erasedups
export HISTIGNORE="?:??"
export HISTSIZE=100000
export HISTFILESIZE=100000
export HISTTIMEFORMAT="[%Y-%m-%d %H:%M:%S] "
export PROMPT_COMMAND="history -a; history -n"
export LESSOPEN="| /ifs/scratch/c2b2/rr_lab/shares/src-highlite/bin/src-hilite-lesspipe.sh %s"
export LESS=' -R '
if [[ $(hostname) == *login* ]] ## titan login node
then PS1='\[\033[1;34m\]\h \t \[\033[1;33m\]\w\n\[\033[0m\] ' ## blue
else
PS1='\[\033[1;32m\]\h \t \[\033[1;33m\]\w\n\[\033[0m\] ' ## green
# attempt at altscreen
export TERM=xterm
# export LESS=' -R '
# export LESSOPEN="| /ifs/scratch/c2b2/rr_lab/shares/src-highlite/bin/src-hilite-lesspipe.sh %s"
fi
export EDITOR='/usr/bin/emacs -nw'
export VISUAL='/usr/bin/emacs -nw'
export WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
export SETUP=bash_profile
### FOR CORRECT TIME ON THE CLUSTER
unset TZ
#############################################
### PATHS
export sshares=/ifs/scratch/c2b2/rr_lab/shares
export shares=/ifs/home/c2b2/rr_lab/shares
export scratch=/ifs/scratch/c2b2/rr_lab/$USER
export scripts=$scratch/scripts
export logs=$scratch/submit/logs
export data=/ifs/data/c2b2/rr_lab/$USER
export results=$scratch/Cancer/201211_mds_ng/dna/results
export TMP=$scratch/tmp
export TMPDIR=$scratch/tmp
### AWK
PATH=$sshares/bioawk:$PATH
export AWKPATH=${shares}/awk_scripts
### PERL
PATH=/nfs/apps/perl/5.16.2/bin:$PATH
PATH=$PATH:$sshares/perl_modules/bin
export PERL_MM_USE_DEFAULT=1
PERL5LIB=$PERL5LIB:$sshares/perl_modules
PERL5LIB=$PERL5LIB:$sshares/perl_modules/lib/perl5
PERL5LIB=$PERL5LIB:$sshares/perl_modules/lib/perl5/x86_64-linux-thread-multi
PERL5LIB=$PERL5LIB:~/perl5
PERL5LIB=$PERL5LIB:~/perl5/lib/perl5:
PERL5LIB=$PERL5LIB:~/perl5/lib/perl5/x86_64-linux-thread-multi
PERL5LIB=$PERL5LIB:$sshares/vcftools/perl
PERL5LIB="$(printf "%s" "${PERL5LIB}" | /usr/bin/awk -v RS=: -v ORS=: '!($0 in a) {a[$0]; print}')"
PERL5LIB="${PERL5LIB%:}" # remove trailing colon
export PERL5LIB
#eval $(perl -I/ifs/scratch/c2b2/rr_lab/shares/perl_modules/lib/perl5 -Mlocal::lib=/ifs/scratch/c2b2/rr_lab/shares/perl_modules)
### PYTHON
# PATH=/ifs/scratch/c2b2/rr_lab/shares/python/bin:$PATH
PATH=/ifs/scratch/c2b2/rr_lab/shares/python/bin:$PATH
PATH=/nfs/apps/python/2.6.5/bin:$PATH
LD_LIBRARY_PATH=/nfs/apps/python/2.6.5/lib:$LD_LIBRARY_PATH
###RSeQC
PATH=$PATH:/ifs/scratch/c2b2/rr_lab/shares/RSeQC/bin
export PYTHONPATH=/ifs/scratch/c2b2/rr_lab/shares/RSeQC/lib/python2.7/site-packages:$PYTHONPATH
export PYTHONSTARTUP=~/.pystartup.py
### MATLAB
PATH=$PATH:/nfs/apps/matlab/current/bin
export MATLABROOT=/nfs/apps/matlab/current
export MATLABPATH=$scratch/scripts
### R
PATH=$PATH:/nfs/apps/R/2.15.1/bin
export R_HISTFILE=~/.Rhistory
PATH=$PATH:$scratch/scripts
PATH=$PATH:${shares}/scripts
#PATH=$PATH:${shares}/scripts/savi
PATH=$PATH:${shares}/ncbi-blast-2.2.25+/bin
PATH=$PATH:${shares}/fastx_toolkit/bin
PATH=$PATH:${shares}/bin
#PATH=$PATH:${shares}/bin/BEDTools-Version-2.16.2/bin
#PATH=$PATH:${shares}/bin/Quake/bin
PATH=$PATH:${shares}/bin/blat34
PATH=$PATH:${shares}/bin/bowtie2-2.0.2
#PATH=$PATH:${shares}/bin/velvet_1.2.03
PATH=$PATH:${shares}/bin/bwa-0.5.9
#PATH=$PATH:${shares}/bin/abyss_program/bin
#PATH=$PATH:${shares}/bin/trans-ABySS-v1.3.2/bin
#PATH=$PATH:${shares}/bin/samtools-0.1.16/bin
PATH=$PATH:${shares}/bin/FastQC
#PATH=$PATH:${shares}/bin/picard-tools-1.71
#PATH=$PATH:${shares}/bin/cufflinks-2.0.2
#PATH=$PATH:${shares}/bin/Ray-v2.1.0_program
PATH=$PATH:${shares}/HTSeq-0.5.3p9/scripts/
PATH=$PATH:$sshares/bedtools/bin
PATH=$PATH:$sshares/samtools
PATH=$PATH:$sshares/tabix
PATH=$PATH:$sshares/seqtk
PATH=$PATH:$sshares/pv-1.4.6/bin
# PATH=$PATH:$sshares/circos-0.63-4/bin
PATH=$PATH:$sshares/src-highlite/bin
PATH=$PATH:$sshares/variant_tools-1.0.5
### remove duplicates in PATH, but keep the order
PATH="$(printf "%s" "${PATH}" | /usr/bin/awk -v RS=: -v ORS=: '!($0 in a) {a[$0]; print}')"
PATH="${PATH%:}" # remove trailing colon
export PATH
#############################################
### DISPLAY
JOB_ID=$( ps -fp $PPID | grep shep | cut -d"-" -f2 )
if [ "${nodeid}" != "" ]; then
export DISPLAY=$( qstat -j $nodeid | grep DISPLAY | cut -d"=" -f2 | cut -d"," -f1 )
fi
# if [[ $(hostname) == *login* ]]
# then echo $DISPLAY > ~/display.dat
# else export DISPLAY=$(<~/display.dat)
# fi
#############################################
### FUNCTIONS
alias pt="perl -F'\t' -lane"
alias js="j --stat" ###autojump
alias remake="make clean; make"
function cur {
curl $1 -o $(basename $1)
}
alias e='emacs -nw '
#alias e='clear; emacs -nw '
function es {
touch $1
chmod +x $1
clear; emacs -nw $1
}
function ew {
emacs -nw $(which $1)
}
alias matlab='$MATLABROOT/bin/matlab -singleCompThread -nodesktop -nosplash'
alias b="e ~/.bashrc; exec bash"
alias bk="cd -"
function r {
for i in $*; do
echo -n $(readlink -e $i)" "
done
echo
}
alias ct="column -t"
alias ctt="column -ts$'\t'"
alias tf='screen -X title "$(basename $(pwd))"'
function newest {
shopt -os noglob
ls -t1 $* | head -n ${2-1} ## second arg defaults to one
shopt -ou noglob
}
function qs {
mem=$1; shift
hours=$1; shift
message=$(qsub -l mem=${mem}G,time=${hours}:: "$@")
echo $message
jid=$( echo $message | cut -f3 -d" " )
}
function bs {
mem=$1; shift
hours=$1; shift
message=$(qsub -b y -j n -l mem=${mem}G,time=${hours}:: "$@")
echo $message
jid=$( echo $message | cut -f3 -d" " )
}
function qsm {
mem=$1; shift
hours=$1; shift
message=$(qsub -m ea -l mem=${mem}G,time=${hours}:: "$@")
echo $message
echo "Email will be sent"
jid=$( echo $message | cut -f3 -d" " )
}
function bsm {
mem=$1; shift
hours=$1; shift
message=$(qsub -m ea -b y -j n -l mem=${mem}G,time=${hours}:: "$@")
echo $message
echo "Email will be sent"
jid=$( echo $message | cut -f3 -d" " )
}
function q {
## send mail on abort
# if [[ -n $STY ]]; then screen -X title "qrsh"; fi
qrsh -l mem=${1-2}G,time=${2-8}::
}
function node {
while true; do
q "$@"
sleep 300
done
}
function left {
qstatj=$(qstat -j $JOB_ID)
echo "$qstatj"
start=$(echo "$qstatj" | grep submission_time | cut -c28- | xargs -I{} date --utc -d {} +%s)
echo start $start
duration=$(echo "$qstatj" | grep -oP 'h_rt=\d+' | cut -d= -f2)
echo duration $duration
now=$(date --utc +%s)
echo now $now
date --utc -d "@"$(( $now - $start )) +%T
remain=$(( start + duration - now ))
echo remain $remain
date --utc -d "@"$remain +%T
}
function ljoin {
local OLDIFS=$IFS
IFS=${1:?"Missing separator"}; shift
echo "$*"
IFS=$OLDIFS
}
alias qst='qstat | tail -n +3 | grep -v QLOGIN | grep -v QRLOGIN'
alias qls='for i in $(qst | cut -c1-7); do jobids=(${jobids[@]} $i); done; export jobids; echo ${jobids[@]}'
alias qlsc='for i in $(qst | cut -c1-7); do echo -n $i,; done; echo'
function w {
if [[ -n $STY ]]; then screen -X title "watch"; fi
watch "echo -ne 'Njobs:\t\t'; qstat | tail -n +3 | grep -v QLOGIN | grep -v QRLOGIN | wc -l; \
echo -ne 'Running:\t'; qstat | tail -n +3 | grep -v QLOGIN | grep -v QRLOGIN | grep ' r ' | wc -l; \
qstat | tail -n +3"
}
### email
function em {
mail -s "$*" $USER < /dev/null > /dev/null
}
alias qm="qalter -m ea"
alias qsdel='cut -c1-7 | xargs qdel'
alias qsj='cut -c1-7 | xargs -I{} qstat -j {}'
alias sc='echo $DISPLAY>~/display.dat; screen -ADR main_screen'
alias d='export DISPLAY=$(cat ~/display.dat)'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
alias lsn='ls -Gh --color=never'
alias ls='ls -h --color'
alias ll='ls -l'
alias lt='ls -ltr'
alias llu="ll;'du' -sh"
# function tr {
# tree --dirsfirst -ChFupDaLg ${1-1}
# }
function ex {
### https://coderwall.com/p/agmblq
for i in "$@"; do
if [ -f $i ] ; then
case $i in
*.tar.bz2)
tar xvjf $i
;;
*.tar.gz)
tar xvzf $i
;;
*.bz2)
bunzip2 $i
;;
*.rar)
unrar x $i
;;
*.gz)
gunzip $i
;;
*.tar)
tar xvf $i
;;
*.tbz2)
tar xvjf $i
;;
*.tgz)
tar xvzf $i
;;
*.zip)
unzip $i
;;
*.Z)
uncompress $i
;;
*.7z)
7z x $i
;;
*)
echo "'$i' cannot be extracted via extract"
;;
esac
else
echo "'$i' is not a valid file"
fi
done
}
function big {
#http://www.earthinfo.org/linux-disk-usage-sorted-by-size-and-human-readable/
for i in $*
do du -sk $i
done | sort -n | while read size fname
do for unit in k M G T P E Z Y
do if [ $size -lt 1024 ]
then echo -e "${size}${unit}\\t${fname}"
break
fi
size=$((size/1024))
done
done
}
function ediff {
emacs -nw --eval '(ediff-files "'$1'" "'$2'")'
}
# function calc {
# bc << EOF
# scale=4
# $@
# quit
# EOF
# }
# alias calc='noglob calc'
#############################################
## REFERENCES
export ref_bwa_genome=$sshares/ref/hg19/bwa/genome/hg19.fa
export ref_bowtie_genome=$sshares/ref/hg19/bowtie2/genome/hg19
export ref_bwa_transcriptome=$sshares/ref/hg19/bwa/transcriptome/transcriptome_fasta.fa
export ref_bowtie_transcriptome=$sshares/ref/hg19/bowtie2/transcriptome/transcriptome_fasta
export ref_samtools_genome=$sshares/ref/hg19/samtools_faidx/hg19.fa
export ref_blast_human=$sshares/ref/hg19/blast_plus/genome/db
export ref_blast_nt=$sshares/ref/blastdb/nt/nt
#for vfs
#export PATH=/nfs/apps/perl/5.16.2/bin:/nfs/apps/blast/2.2.20/bin:/nfs/apps/python/2.6.5/bin:/nfs/apps/perl/5.10.0/bin:/opt/gridengine/bin/lx24-amd64:/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/lib64/ccache:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/OFED/1.5.2/bin:/opt/OFED/1.5.2/sbin:/nfs/apps/matlab/current/bin:/nfs/apps/R/2.15.1/bin:/ifs/scratch/c2b2/rr_lab/avp2106/scripts:/ifs/home/c2b2/rr_lab/shares/scripts:/ifs/home/c2b2/rr_lab/shares/scripts/savi:/ifs/home/c2b2/rr_lab/shares/ncbi-blast-2.2.25+/bin:/ifs/home/c2b2/rr_lab/shares/fastx_toolkit/bin:/ifs/home/c2b2/rr_lab/shares/bin:/ifs/home/c2b2/rr_lab/shares/bin/BEDTools-Version-2.16.2/bin:/ifs/home/c2b2/rr_lab/shares/bin/Quake/bin:/ifs/home/c2b2/rr_lab/shares/bin/blat34:/ifs/home/c2b2/rr_lab/shares/bin/bowtie2-2.0.2:/ifs/home/c2b2/rr_lab/shares/bin/velvet_1.2.03:/ifs/home/c2b2/rr_lab/shares/bin/bwa-0.5.9:/ifs/home/c2b2/rr_lab/shares/bin/abyss_program/bin:/ifs/home/c2b2/rr_lab/shares/bin/trans-ABySS-v1.3.2/bin:/ifs/home/c2b2/rr_lab/shares/bin/samtools-0.1.16/bin:/ifs/home/c2b2/rr_lab/shares/bin/FastQC:/ifs/home/c2b2/rr_lab/shares/bin/picard-tools-1.71:/ifs/home/c2b2/rr_lab/shares/bin/cufflinks-2.0.2:/ifs/home/c2b2/rr_lab/shares/bin/Ray-v2.1.0_program:/ifs/scratch/c2b2/rr_lab/shares/perl_modules/bin:/ifs/scratch/c2b2/rr_lab/shares/ssake_v3-8:/ifs/scratch/c2b2/rr_lab/shares/CAP3
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh