This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathClustersPloter.sh
executable file
·137 lines (123 loc) · 4.18 KB
/
ClustersPloter.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/sh
base=`dirname $(readlink -f $0)`/../
base=`readlink -f $base`
#if [ ! -f "$base/bin/env.sh" ];
##then
# echo -e "\n$(tput setaf 1)error: cannot find $base/bin/env.sh$(tput setaf 7)\n"
# exit 1
#fi
#
#. $base/bin/env.sh $base
# check env
home=$base
export PATH=$home/bin:$PATH
export PERL5LIB=$home/src:$PERL5LIB ## for perl library
#echo PERL5LIB is $PERL5LIB
#perl -e 'use Imager::Font'
#if [ $? -eq 0 ];
#then
# echo -e "\nfind Imager::Font"
#else
# echo -e "\n$(tput setaf 1)error, not find Imager::Font, maybe you should try to re-install perl package Imager::Font(https://cpan.metacpan.org/authors/id/A/AD/ADDI/Imager-0.41.tar.gz) by cpan or manually-install$(tput setaf 7)\n"
#fi
#dep="samtools sort perl"
dep="perl"
for i in $dep
do
$i --help >/dev/null
if [ "$?" != "0" ];
then
echo "error: not find $i, need add directory of $i to PATH"
exit 1
else
j=`which $i`
#echo find $j
fi
done
if [ $# -ne 4 ];
then
echo -e "\nusage:\n sh $0 $(tput setaf 3)track.list$(tput setaf 7) prefix outdir/ $(tput setaf 3)main.conf$(tput setaf 7)\n\nany question, go to https://github.com/orangeSi/ClustersPloter/issues"
exit 1
fi
#set -vex
#samtools view -h S20K.sort.bam s160:155612-178608 |samtools view - -b >S20K.s160.155612.178608.sort.bam #samtools index S20K.s160.155612.178608.sort.bam
#base=`dirname $(readlink -f $0)`/src/
#source $base/../env.sh
list=$1
prefix=$2
outdir=$3
conf=$4
for i in $list $conf
do
if [ ! -f "$i" ];
then
echo -e "\n$(tput setaf 1)error: file $i not exists$(tput setaf 7)"
exit 1
fi
done
if [ ! -d "$outdir" ];
then
mkdir -p $outdir
fi
cd $outdir
num=`cat $conf|grep -iE "^\s*hist_scatter_line\s*|^\s*reads_mapping\s*|^\s*synteny\s*"|wc -l`
error_flag=0
if [ "$num" -ge 1 ];
then
echo
date
echo -e "$(tput setaf 3)perl $base/src/prepare.data.pl --list $list --prefix $prefix --outdir . --conf $conf >$prefix.prepare.data.log 2>$prefix.prepare.data.error.tmp $(tput setaf 7)"
#echo "perl $base/src/prepare.data.pl --list $list --prefix $prefix --outdir . --conf $conf >$prefix.prepare.data.log 2>$prefix.prepare.data.error.tmp"
perl $base/src/prepare.data.pl --list $list --prefix $prefix --outdir . --conf $conf >$prefix.prepare.data.log 2>$prefix.prepare.data.error
error_flag=$?
#cat $prefix.prepare.data.error.tmp|grep -v '^+ ' > $prefix.prepare.data.error && rm $prefix.prepare.data.error.tmp
#cat $prefix.prepare.data.error.tmp > $prefix.prepare.data.error && rm $prefix.prepare.data.error.tmp
echo
else
cp $list $list.$prefix
cp $conf $conf.$prefix
fi
if [ $error_flag -ge 1 ];
then
error=`cat $prefix.prepare.data.error`
echo -e "$(tput setaf 2)$error$(tput setaf 7)\n\n$(tput setaf 1)error in file: $prefix.prepare.data.error$(tput setaf 7)\n\n"
date
exit 1
else
date
echo
echo
date
error_flag=0
echo -e "$(tput setaf 3)perl $base/src/plot.genome.featureCluster.pl --list $list.$prefix --prefix $prefix --outdir . --conf $conf.$prefix >$prefix.plot.log 2>$prefix.plot.error.tmp$(tput setaf 7)"
#echo "perl $base/src/plot.genome.featureCluster.pl --list $list.$prefix --prefix $prefix --outdir . --conf $conf.$prefix >$prefix.plot.log 2>$prefix.plot.error.tmp"
perl $base/src/plot.genome.featureCluster.pl --list $list.$prefix --prefix $prefix --outdir . --conf $conf.$prefix >$prefix.plot.log 2>$prefix.plot.error
error_flag=$?
#cat $prefix.plot.error.tmp >$prefix.plot.error && rm $prefix.plot.error.tmp
echo
fi
echo
#ls -ltrh $prefix.prepare.data.log $prefix.plot.log 2>/dev/null
#ls -ltrh $prefix.prepare.data.error $prefix.plot.error 2>/dev/null
if [ $error_flag -ge 1 ];
then
error=`cat $prefix.plot.error`
echo -e "$(tput setaf 2)$error$(tput setaf 7)\n\n$(tput setaf 1)detail error in file $prefix.plot.error, $(tput setaf 7)\n\n"
date
exit 1
else
echo -e "\n\n$(tput setaf 2)finished~$(tput setaf 7)\n\n"
fi
date
which svgcleaner 2>/dev/null >/dev/null
if [ "$?" == "0" ]:
then
echo "cleaning $prefix.svg with svgcleaner"
svgcleaner $prefix.svg $prefix.cleaned.svg 2>$prefix.cleaned.svg.log
else
echo "cleaning $prefix.svg with sed"
sed -r -e 's/\\s*<g[^>]*>.*//' -e 's/<\\/g>//' -e 's/^<tspan.*//' -e 's/^.*<\\/title>//' $prefix.svg >$prefix.cleaned.svg
fi
echo "$(tput setaf 2)output is:$(tput setaf 7)"
ls -thl $prefix.svg $prefix.cleaned.svg $prefix.html
echo