-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.functions
85 lines (74 loc) · 2.1 KB
/
.functions
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
### Mount with sshfs
connect () {
$HOME/.dotfiles/.connect
}
### Make and cd into directory
mcd () {
mkdir -p $1
cd $1
}
### Decompress from any format
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.tar.xz) tar Jxvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
### Show numbered column names
getcols() {
if [ -f $1 ]; then
grep -v '^#' $1 | awk 'NR==1{for (i=1; i<=NF; i++) print i"|"$i}'
else
echo "'$1' is not a valid file!"
fi
}
# Readlink
function readlink() {
DIR=$(echo "${1%/*}")
(cd "$DIR" && echo "$(pwd -P)")
}
### Open Facets PNG from cluster
open_facets() {
SSTRING=$1
FLIST=$(ls -t /ifs/res/taylorlab/impact_facets/facets_0.5.14/manifests/impact_facets_manifest*txt | cut -f1 | head -1)
MATCHES=$(grep "$SSTRING" $FLIST | cut -f2 | sort | uniq | wc -l)
if [ "$MATCHES" -gt 1 ]
then
echo "More than one match, specify sample"
return 1
fi
if [ "$MATCHES" -eq 0 ]
then
echo "No matches"
return 1
fi
SPATH=$(grep "$SSTRING" $FLIST | head -1)
SAMPLE=$(echo $SPATH | tr " " "\t" | cut -f2)
echo "Opening $SAMPLE"
SPATH=$(ls $(echo $SPATH | tr " " "\t" | cut -f8)*purity.CNCF.png)
echo "Path: $SPATH"
open $SPATH
}
# Get url to 12-245 bam file
bam_url() {
BASE=$1
grep $BASE ~/luna/keys/key.txt | \
cut -f1,2 -d"," | \
sed -e 's:,: /ifs/dmpshare/share/irb12_245/:g' \
-e 's/$/.bam/g'
}