forked from soccin/CMOMerge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.sh
executable file
·121 lines (108 loc) · 2.4 KB
/
App.sh
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
#!/bin/bash
SDIR="$( cd "$( dirname "$0" )" && pwd )"
PYTHON=/opt/common/CentOS_6/python/python-2.7.8/bin/python2.7
REPO=/ifs/res/socci/Work/CMO/CMOMerge/bic-mskcc
usage() {
echo "CMOMerge/App.sh -p projectTag -b baseProject -r repository -s python_path"
echo " projectTag = string to grep for to find projects to merge"
echo " baseProject = full project ID for the base project of merge"
echo
$PYTHON $SDIR/MergePortal -h 2>1 | egrep -v Version
}
if [ "$#" == "0" ]; then
usage
exit
fi
LABARG=""
TUMORARG=""
MERGEARG=""
FORCEARG=""
rm -f merge_exclude
while getopts ":b:p:l:t:n:r:s:e:hf" opt; do
case $opt in
b)
BASETAG=$OPTARG
;;
p)
PROJECTTAG=$OPTARG
;;
l)
LABARG="-l "$OPTARG
;;
t)
TUMORARG="-t "$OPTARG
;;
n)
MERGEARG="-n "${OPTARG/-/_}
;;
r)
REPO=$OPTARG
;;
s)
PYTHON=$OPTARG
;;
e)
echo "/"$OPTARG"$" >>merge_exclude
;;
f)
FORCEARG="--force"
;;
h)
usage
exit
;;
esac
done
shift $((OPTIND-1))
if [ "$PROJECTTAG" != "" ]; then
echo PROJECTTAG=$PROJECTTAG
PROJECTS=$(find -L $REPO -name '*meta_study.txt' \
| fgrep $PROJECTTAG \
| fgrep -v cbe \
| sed 's/.meta.*//' \
| sort -r)
fi
if [ -e merge_exclude ]; then
echo "Need to exclude"
cat merge_exclude
PROJECTS=$(echo $PROJECTS | tr ' ' '\n' | egrep -vf merge_exclude)
fi
BASEPROJECT=""
OTHERPROJECTS=""
if [ "$BASETAG" != "" ]; then
i=1
for pi in $PROJECTS; do
if [[ $pi =~ "${BASETAG}" ]]; then
BASEPROJECT=$pi
else
OTHERPROJECTS="--project "$pi" "$OTHERPROJECTS
fi
done
echo BASEPROJECT=$BASEPROJECT
else
i=1
echo "Need to set baseProject"
echo
for pi in $PROJECTS; do
echo $pi | perl -pe "s|${REPO}.||" | awk -v i=$i '{print i":\t"$1}'
i=$((i+1))
done
exit
fi
echo "-----"
echo "Pulling and updating repository"
pushd .
cd $REPO
hg pull
hg update
popd
echo $PWD
echo "done"
echo "--"
echo
ARGS="$LABARG $TUMORARG $MERGEARG $FORCEARG"
echo ARGS=$ARGS
$PYTHON $SDIR/MergePortal --project $BASEPROJECT \
--root $REPO \
$OTHERPROJECTS \
$ARGS