1 | #!/bin/sh
|
---|
2 |
|
---|
3 |
|
---|
4 | # SETUP
|
---|
5 |
|
---|
6 | # directory where the sequence files are stored
|
---|
7 | sequencedir=/magic/sequences
|
---|
8 | callistodir=/magic/data/callisto
|
---|
9 | stardir=/magic/data/star
|
---|
10 | # access to the sql database
|
---|
11 | alias mymysql='mysql -s -u MAGIC -h vela --password=d99swMT!'
|
---|
12 | # database name
|
---|
13 | db=MyMagic
|
---|
14 |
|
---|
15 |
|
---|
16 | # TODO
|
---|
17 |
|
---|
18 | # Spped up with SQL: FIELD(25123, 1, 2, 3, 4, 5, ..., 1000200);
|
---|
19 | # Cross check sequences in Sequence and other databases
|
---|
20 | # added switch which allows to correct for the problems immediatly
|
---|
21 | # unify the checks (especially 1b and 1c)
|
---|
22 | # for the sequences better use 0* instead of 0+ ?
|
---|
23 |
|
---|
24 |
|
---|
25 | # CHECK 1
|
---|
26 | echo Checking if all sequence files have a corresponding entry in Sequences
|
---|
27 | files=`find $sequencedir -type f`
|
---|
28 | for file in $files
|
---|
29 | do
|
---|
30 | sequence=`echo $file | sed -e "s/^.*\/sequence0\+\([0-9]\+\)\.txt$/\1/"`
|
---|
31 | if [ "$sequence" = "" ]
|
---|
32 | then
|
---|
33 | echo No sequence file: $file
|
---|
34 | continue
|
---|
35 | fi
|
---|
36 |
|
---|
37 | var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`
|
---|
38 | if ! [ "$sequence" = "$var" ]
|
---|
39 | then
|
---|
40 | echo Sequence-File $sequence exist but it is not in Sequences.
|
---|
41 | continue
|
---|
42 | fi
|
---|
43 | done
|
---|
44 |
|
---|
45 | # CHECK 1b (callisto)
|
---|
46 | echo Checking if all sequences in $callistodir have a corresponding sequence in Sequence
|
---|
47 | dirs=`find $callistodir -type d`
|
---|
48 | for dir in $dirs
|
---|
49 | do
|
---|
50 | sequence=`echo $file | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`
|
---|
51 | if [ "$sequence" = "" ]
|
---|
52 | then
|
---|
53 | echo Invalid directory: $dir
|
---|
54 | continue
|
---|
55 | fi
|
---|
56 |
|
---|
57 | var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`
|
---|
58 | if ! [ "$sequence" = "$var" ]
|
---|
59 | then
|
---|
60 | echo $dir exists but no corresponding sequence in Sequences.
|
---|
61 | continue
|
---|
62 | fi
|
---|
63 | done
|
---|
64 |
|
---|
65 | # CHECK 1c (star)
|
---|
66 | echo Checking if all sequences in $stardir have a corresponding sequence in Sequence
|
---|
67 | dirs=`find $stardir -type d`
|
---|
68 | for dir in $dirs
|
---|
69 | do
|
---|
70 | sequence=`echo $file | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`
|
---|
71 | if [ "$sequence" = "" ]
|
---|
72 | then
|
---|
73 | echo Invalid directory: $dir
|
---|
74 | continue
|
---|
75 | fi
|
---|
76 |
|
---|
77 | var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`
|
---|
78 | if ! [ "$sequence" = "$var" ]
|
---|
79 | then
|
---|
80 | echo $dir exists but no corresponding sequence in Sequences.
|
---|
81 | continue
|
---|
82 | fi
|
---|
83 | done
|
---|
84 |
|
---|
85 | # CHECK 2
|
---|
86 | echo Checking if all sequences in Sequences have a corresponding sequence files
|
---|
87 | sequences=`echo SELECT fSequenceFirst FROM $db.Sequences | mymysql`
|
---|
88 | for sequence in $sequences
|
---|
89 | do
|
---|
90 | var=`find $sequencedir -type f -regex .*/sequence0+${sequence}\.txt$`
|
---|
91 | if [ "$var" = "" ]
|
---|
92 | then
|
---|
93 | echo Sequence-File for $sequence not found but in db.
|
---|
94 | fi
|
---|
95 | done
|
---|
96 |
|
---|
97 | # CHECK 3
|
---|
98 | echo Checking if all sequences from Sequences exists RunData
|
---|
99 | sequences=`echo SELECT fSequenceFirst FROM $db.Sequences GROUP BY fSequenceFirst | mymysql`
|
---|
100 | for sequence in $sequences
|
---|
101 | do
|
---|
102 | res=`echo SELECT fSequenceFirst FROM $db.RunData WHERE fSequenceFirst=$sequence GROUP BY fSequenceFirst | mymysql`
|
---|
103 | if ! [ "$sequence" = "$res" ]
|
---|
104 | then
|
---|
105 | echo Sequence $sequence exists in Sequences but not in RunData.
|
---|
106 | continue
|
---|
107 | fi
|
---|
108 | done
|
---|
109 |
|
---|
110 | # CHECK 4
|
---|
111 | echo Checking if all sequences from RunData exists in Sequences
|
---|
112 | sequences=`echo SELECT fSequenceFirst FROM $db.RunData WHERE not fSequenceFirst=0 GROUP BY fSequenceFirst | mymysql`
|
---|
113 | for sequence in $sequences
|
---|
114 | do
|
---|
115 | var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`
|
---|
116 | if ! [ "$sequence" = "$var" ]
|
---|
117 | then
|
---|
118 | echo Sequence $sequence exists in RunData but not in Sequences.
|
---|
119 | continue
|
---|
120 | fi
|
---|
121 | done
|
---|
122 |
|
---|