forked from meier-rene/MSConvertGUI-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert_bruker_2mzxml.sh
executable file
·82 lines (69 loc) · 1.96 KB
/
convert_bruker_2mzxml.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
#!/bin/bash
# found this several years ago on the internet
# maybe gnu parallel will also be interesting
# start script with:
# ./convert_bruker_2mzxml.sh 1 2
# 1: will contain the input folder containing the Bruker Daltonic .d folders
# 2: will contain the output folder for the mzXML files, does not need to be full path. in relation to 1
# check if the correct number of arguments are supplied
E_BADARGS=85
if [ ! $# -eq 2 ]
then
echo "Usage: `basename $0` <folder containing baf files> <output folder>"
echo " e.g. ./convert_bruker_2mzxml.sh /Projects/MyProject/Data/Sequence1 ./mzxml"
#echo " If you want to use wildcards place double quotes around the path name."
exit $E_BADARGS
fi
# retrieve the bruker folder names .d
LINES="$( ls -d $1/*.d/ )"
# retrieve only samples
#LINES="$( ls -d $1/Sample_*/ )"
# retrieve only qcpool
#LINES="$( ls -d $1/QCpool_*/ )"
# do not set higher then number of cores available
MAXJOBS=6
function spawnjob()
{
echo "$1" | bash
}
function clearToSpawn
{
local JOBCOUNT="$( jobs -r | grep -c . )"
if [ $JOBCOUNT -lt $MAXJOBS ]; then
echo 1;
return 1;
fi
echo 0;
return 0;
}
JOBLIST=""
IFS="
"
# get the output location
output="$2"
for LINE in $LINES; do
# get the input file (in the case of Bruker this is a folder)
input="$(basename $LINE)"
# Run the command on a linux machine
# is this smart to do, it will run x number of docker containers?
# there is also an option -f
# make sure to run docker with --rm option, to remove container when finished
COMMANDLIST+="docker run --rm -v $1:/data chambm/pwiz-skyline-i-agree-to-the-vendor-licenses wine msconvert $input -o $output --mzXML --64 --zlib --filter \"peakPicking true 1-\" --filter \"msLevel 1-\"
"
done
IFS="
"
for COMMAND in $COMMANDLIST; do
while [ `clearToSpawn` -ne 1 ]; do
sleep 1
done
spawnjob $COMMAND &
LASTJOB=$!
JOBLIST="$JOBLIST $LASTJOB"
done
IFS=" "
for JOB in $JOBLIST; do
wait $JOB
echo "Job $JOB exited with status $?"
done
echo "Done."