annotate w4mjoinpn.sh @ 1:dcfaffec48c8 draft default tip

planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit 919fba0dbfcdb553bbb6e1c765c3a8c9f26a47f9
author eschen42
date Wed, 08 Aug 2018 19:40:57 -0400
parents 948bac693947
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
1 #!/bin/bash
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
2 # join positive and negative ionization-mode XCMS datasets for a common set of samples
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
3 # summary:
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
4 # - parse and validate arguments (or abort)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
5 # - check that the same samples are present in the same order in both the positive and negative mode data matrices (or abort)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
6
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
7 # Parse arguments
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
8 # ref: https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash/14203146#14203146
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
9 POSITIONAL=()
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
10 while [[ $# -gt 0 ]]; do
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
11 key="$1"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
12 case $key in
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
13 dmpos)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
14 DMPOS="$2"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
15 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
16 shift # past value
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
17 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
18 dmneg)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
19 DMNEG="$2"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
20 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
21 shift # past value
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
22 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
23 dmout)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
24 DMOUT="$2"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
25 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
26 shift # past value
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
27 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
28 smpos)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
29 SMPOS="$2"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
30 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
31 shift # past value
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
32 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
33 smneg)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
34 SMNEG="$2"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
35 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
36 shift # past value
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
37 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
38 smout)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
39 SMOUT="$2"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
40 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
41 shift # past value
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
42 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
43 vmpos)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
44 VMPOS="$2"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
45 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
46 shift # past value
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
47 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
48 vmneg)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
49 VMNEG="$2"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
50 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
51 shift # past value
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
52 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
53 vmout)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
54 VMOUT="$2"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
55 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
56 shift # past value
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
57 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
58 *) # unknown option
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
59 POSITIONAL+=("$1") # save it in an array for later
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
60 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
61 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
62 esac
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
63 done
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
64 set -- "${POSITIONAL[@]}" # restore positional parameters
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
65 if [[ -n $1 ]]; then
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
66 echo "unexpected argument $1"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
67 echo "arguments supplied: $@"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
68 exit 1
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
69 fi
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
70
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
71 # Validate that we got the expected args
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
72 set -- ${DMPOS} ${DMNEG} ${DMOUT} ${SMPOS} ${SMNEG} ${SMOUT} ${VMPOS} ${VMNEG} ${VMOUT}
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
73 if [[ ! -n $9 ]]; then
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
74 echo "expecting nine arguments"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
75 echo "parsed arguments: $@"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
76 exit 1
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
77 fi
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
78
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
79 # Show them what we got
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
80 echo "dataMatrix positive_mode ${DMPOS}"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
81 echo "dataMatrix negative_mode ${DMNEG}"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
82 echo "dataMatrix joined_modes ${DMOUT}"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
83 echo "sampleMetadata positive_mode ${SMPOS}"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
84 echo "sampleMetadata negative_mode ${SMNEG}"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
85 echo "sampleMetadata joined_modes ${SMOUT}"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
86 echo "variableMetadata positive_mode ${VMPOS}"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
87 echo "variableMetadata negative_mode ${VMNEG}"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
88 echo "variableMetadata joined_modes ${VMOUT}"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
89
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
90 # Check that sample names are the same, in the same order, for the dataMatrix in both datasets
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
91 if [ "$( head -n 1 ${DMPOS} )" != "$( head -n 1 ${DMNEG} )" ]; then echo sample names in dataMatrix files differ; exit 1; fi
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
92 # Check that sample names are the same, in the same order, for the sampleMetadata in both datasets
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
93 if [ "$( cut -f 1 ${SMPOS} )" != "$( cut -f 1 ${SMNEG} )" ]; then echo sample names in sampleMetadata files differ; exit 1; fi
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
94
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
95 # Concatenate variableMetadata datasets to respective output file
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
96 cat <( head -n 1 ${VMNEG} ) <( sed -n -e '1 d; s/^/N/; p;' ${VMNEG} ) <( sed -n -e '1 d; s/^/P/; p;' ${VMPOS} ) > ${VMOUT}
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
97
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
98 # Concatenate dataMatrix datasets to respective output file
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
99 cat <( head -n 1 ${DMNEG} ) <( sed -n -e '1 d; s/^/N/; p;' ${DMNEG} ) <( sed -n -e '1 d; s/^/P/; p;' ${DMPOS} ) > ${DMOUT}
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
100
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
101 # Determine whether negative ionization-mode sampleMetadata file's column three is titled "polarity"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
102
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
103 # find the ordinal number of the first column named "polarity" of the negative ionization-mode sampleMetadata file, if any
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
104 set -- `head -n 1 ${SMNEG}`
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
105 POLARITY=0
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
106 MAXCOUNT=0
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
107 while [[ $# -gt 0 ]]; do
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
108 MAXCOUNT=$(( MAXCOUNT + 1 ))
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
109 key="$1"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
110 case $key in
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
111 polarity)
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
112 if [ $POLARITY -eq 0 ]; then POLARITY=${MAXCOUNT}; fi
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
113 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
114 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
115 *) # unknown option
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
116 shift # past argument
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
117 ;;
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
118 esac
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
119 done
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
120 echo "Polarity is in column $POLARITY of ${SMNEG}"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
121 echo "There are $MAXCOUNT columns in ${SMNEG}"
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
122
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
123 # Copy sampleMetadata from negative ionization-mode to output file, replacing polarity if possible
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
124 if [ ${POLARITY} -gt 1 ]; then
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
125 COLBEFORE=$(( POLARITY - 1 ))
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
126 COLAFTER=$(( POLARITY + 1 ))
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
127 # Replace all entries in column three of negative ionization-mode sampleMetadata file with "posneg" in respective output file
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
128 if [ ${POLARITY} -lt ${MAXCOUNT} ]; then
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
129 # Handle the case where polarity is not in the last column
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
130 paste <( cut -f 1-${COLBEFORE} ${SMNEG} ) <( cut -f ${POLARITY} ${SMNEG} | sed -n -e '2,$ s/.*/posneg/; p;' ) <( cut -f ${COLAFTER}- ${SMNEG} ) > ${SMOUT}
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
131 else
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
132 # Handle the case where polarity is in the last column
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
133 paste <( cut -f 1-${COLBEFORE} ${SMNEG} ) <( cut -f ${POLARITY} ${SMNEG} | sed -n -e '2,$ s/.*/posneg/; p;' ) > ${SMOUT}
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
134 fi
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
135 else
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
136 # Handle the case where polarity was not found: Copy negative ionization-mode sampleMetadata file to the respective output file
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
137 cp ${SMNEG} ${SMOUT}
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
138 fi
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
139
948bac693947 planemo upload for repository https://github.com/HegemanLab/w4mjoinpn_galaxy_wrapper/tree/master commit cedf2e01903099ef5f1bbe624afe4c2845d6bf23
eschen42
parents:
diff changeset
140 exit 0