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
|
#!/bin/bash -e
PROGNAME=`basename $0`
format=png
mem=1500m
function usage {
echo "
USAGE:
redraw_maps.sh -p DIR [Options]
DESCRIPTION:
Used to redraw the maps. This can be used after editing the CGView XML file
or to change the output image formats.
REQUIRED ARGUMENTS:
-p, --project DIR
Path to a completed CCT project.
OPTIONAL ARGUMENTS:
-f, --format STRING
Image format for output map. Options are png, jpg, svg, svgz.
(Default: png)
-m, --memory STRING
Memory value for Java's -Xmx option (Default: 1500m).
-h, --help
Show this message
EXAMPLE:
redraw_maps.sh -p my_project -f svg
"
}
function error_exit {
echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
exit 1
}
function get_filename_without_extension {
basefile=$(basename "$1")
filename=${basefile%.*}
echo $filename
}
function get_path_to_maps {
file="$1"
filename=`echo "$file" | perl -nl -e 'm/(.+)\/cgview_xml\/[^\/]+$/;' -e 'print $1'`
echo $filename
}
function remove_trailing_slash {
string="$1"
new_string=`echo "$string" | perl -nl -e 's/\/+$//;' -e 'print $_'`
echo $new_string
}
while [ "$1" != "" ]; do
case $1 in
-p | --project ) shift
project=$1
;;
-f | --format ) shift
format=$1
;;
-m | --memory ) shift
mem=$1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
if [ -z "$project" ]; then
error_exit "Please use '-p' to specify a project. Use '-h' for help."
fi
if [ -z $CCT_HOME ]; then
error_exit "Please set the \$CCT_HOME environment variable to the path to the cgview_comparison_tool directory."
fi
cct_home=$CCT_HOME
project=`remove_trailing_slash "$project"`
# save and change IFS to avoid problems with filesnames with spaces
OLDIFS=$IFS
IFS=$'\n'
#find all XML files in the project
files=($( find "$project" -type f -name "*.xml" ))
# restore IFS
IFS=$OLDIFS
length=${#files[@]}
for (( i=0; i<$length; i++ ));
do
xml_file=${files[$i]}
echo "Generating map from the file '$xml_file'."
file_no_extension=`get_filename_without_extension "$xml_file"`
path_to_maps=`get_path_to_maps "$xml_file"`
java -jar -Xmx${mem} "$cct_home"/bin/cgview.jar -i "$xml_file" -o "$path_to_maps"/"${file_no_extension}"."$format" -f "$format"
echo "Map drawn to $path_to_maps/${file_no_extension}.${format}"
done
|