[med-svn] [Git][med-team/cct][upstream] New upstream version 1.0.2

Andreas Tille (@tille) gitlab at salsa.debian.org
Tue Jul 20 09:00:56 BST 2021



Andreas Tille pushed to branch upstream at Debian Med / cct


Commits:
8c996c30 by Andreas Tille at 2021-07-20T07:56:31+02:00
New upstream version 1.0.2
- - - - -


27 changed files:

- README.md
- lib/scripts/assign_cogs/test.sh
- lib/scripts/cgview_xml_builder/test_input/R_denitrificans.cogs
- lib/scripts/convert_vcf_to_features/test.sh
- lib/scripts/get_cds/test.sh
- lib/scripts/get_orfs/test.sh
- lib/scripts/local_blast_client/local_blast_client.pl
- lib/scripts/local_blast_client/test.sh
- lib/scripts/ncbi_search/README.md
- lib/scripts/ncbi_search/ncbi_search.pl
- lib/scripts/ncbi_search/test.sh
- lib/scripts/sequence_to_multi_fasta/test.sh
- scripts/build_blast_atlas.sh
- scripts/build_blast_atlas_all_vs_all.sh
- scripts/build_cog_db.sh
- scripts/check_env.sh
- scripts/create_zoomed_maps.sh
- scripts/fetch_all_refseq_bacterial_genomes.sh
- scripts/fetch_all_refseq_chloroplast_genomes.sh
- scripts/fetch_all_refseq_mitochondrial_genomes.sh
- scripts/fetch_genome_by_accession.sh
- scripts/fetch_refseq_bacterial_genomes_by_name.sh
- scripts/process_sample_projects.sh
- scripts/process_test_projects.sh
- scripts/redraw_maps.sh
- scripts/remove_long_seqs.sh
- scripts/remove_short_seqs.sh


Changes:

=====================================
README.md
=====================================
@@ -19,34 +19,33 @@ Pull the Docker image:
 docker pull pstothard/cgview_comparison_tool
 ```
 
-Run the Docker image and use `fetch_genome_by_accession.sh` to download a sequence in GenBank format (to simplify this and subsequent commands, `$CCT` is used to store the first part of the command, which runs the Docker image):
+Run the Docker image and use `fetch_genome_by_accession.sh` to download a sequence in GenBank format:
 
 ```bash
-CCT="docker run --rm -v $(pwd):/dir -w /dir pstothard/cgview_comparison_tool"
-$CCT fetch_genome_by_accession.sh -a AC_000022 -o ./
+docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview_comparison_tool fetch_genome_by_accession.sh -a AC_000022 -o ./
 ```
 
-Use `build_blast_atlas.sh` to create a BLAST Atlas project for the sequence that was downloaded:
+Use `build_blast_atlas.sh` to create a BLAST atlas project for the sequence that was downloaded:
 
 ```bash
-$CCT build_blast_atlas.sh -i AC_000022.gbk
+docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview_comparison_tool build_blast_atlas.sh -i AC_000022.gbk
 ```
 
-Download some sequences to be used as "comparison genomes" in the BLAST Atlas project:
+Download some sequences to be used as "comparison genomes" in the BLAST atlas project:
 
 ```bash
-$CCT fetch_genome_by_accession.sh -a NC_046914 -o ./AC_000022/comparison_genomes
-$CCT fetch_genome_by_accession.sh -a NC_047196 -o ./AC_000022/comparison_genomes
-$CCT fetch_genome_by_accession.sh -a NC_047457 -o ./AC_000022/comparison_genomes
-$CCT fetch_genome_by_accession.sh -a AC_000022 -o ./AC_000022/comparison_genomes
-$CCT fetch_genome_by_accession.sh -a NC_001326 -o ./AC_000022/comparison_genomes
-$CCT fetch_genome_by_accession.sh -a NC_043914 -o ./AC_000022/comparison_genomes
+docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview_comparison_tool fetch_genome_by_accession.sh -a NC_046914 -o ./AC_000022/comparison_genomes
+docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview_comparison_tool fetch_genome_by_accession.sh -a NC_047196 -o ./AC_000022/comparison_genomes
+docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview_comparison_tool fetch_genome_by_accession.sh -a NC_047457 -o ./AC_000022/comparison_genomes
+docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview_comparison_tool fetch_genome_by_accession.sh -a AC_000022 -o ./AC_000022/comparison_genomes
+docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview_comparison_tool fetch_genome_by_accession.sh -a NC_001326 -o ./AC_000022/comparison_genomes
+docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview_comparison_tool fetch_genome_by_accession.sh -a NC_043914 -o ./AC_000022/comparison_genomes
 ```
 
 Generate the CGView maps:
 
 ```bash
-$CCT build_blast_atlas.sh -p AC_000022 -z medium
+docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview_comparison_tool build_blast_atlas.sh -p AC_000022 -z medium
 ```
 
 Once complete, the maps can be found in the `AC_000022/maps_for_cds_vs_cds` and `AC_000022/maps_for_dna_vs_dna` directories on the host system.
@@ -56,13 +55,13 @@ There are multiple ways to alter the appearance and contents of a map generated
 For example, the following command uses the [--custom option](https://paulstothard.github.io/cgview_comparison_tool/customization_keys.html) to change several aspects of the map:
 
 ```bash
-$CCT build_blast_atlas.sh -p AC_000022 -x -z medium --custom "title='Example map' global_label=T legend=F use_opacity=F backboneRadius=900 labelFontSize=60 borderColor=white width=3000 height=3000"
+docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview_comparison_tool build_blast_atlas.sh -p AC_000022 -x -z medium --custom "title='Example map' global_label=T legend=F use_opacity=F backboneRadius=900 labelFontSize=60 borderColor=white width=3000 height=3000"
 ```
 
 This command redraws the maps in SVG format:
 
 ```bash
-$CCT redraw_maps.sh -p AC_000022 -f svg
+docker run --rm -v "$(pwd)":/dir -u "$(id -u)":"$(id -g)" -w /dir pstothard/cgview_comparison_tool redraw_maps.sh -p AC_000022 -f svg
 ```
 
 The SVG maps are added to the `AC_000022/maps_for_cds_vs_cds` and `AC_000022/maps_for_dna_vs_dna` directories. Below are the maps generated for the CDS vs CDS comparisons and the DNA vs DNA comparisons, respectively.
@@ -70,21 +69,6 @@ The SVG maps are added to the `AC_000022/maps_for_cds_vs_cds` and `AC_000022/map
 ![CGView map](sample1.svg)
 ![CGView map](sample2.svg)
 
-### Tip
-
-When using the CCT Docker image to run commands described in the [CCT documentation](https://paulstothard.github.io/cgview_comparison_tool/index.html), you can store the Docker portion of the command in an environment variable, for example:
-
-```bash
-CCT="docker run --rm -v $(pwd):/dir -w /dir pstothard/cgview_comparison_tool"
-```
-
-Then the commands in the CCT documentation can be run by preceding them with the environment variable, for example:
-
-```bash
-$CCT fetch_genome_by_accession.sh -a NC_009787 -o ./
-$CCT build_blast_atlas.sh -i NC_009787.gbk
-```
-
 ## Downloading and running CCT
 
 To download CCT:
@@ -123,13 +107,19 @@ export PERL5LIB="$PERL5LIB:${CCT_HOME}/lib/perl_modules"
 Test your setup:
 
 ```bash
-check_env.sh
+./scripts/check_env.sh
+```
+
+Prepare the COG database:
+
+```bash
+./scripts/build_cog_db.sh
 ```
 
 Build some test maps:
 
 ```bash
-process_test_projects.sh
+./scripts/process_test_projects.sh
 ```
 
 Refer to the [CCT documentation](https://paulstothard.github.io/cgview_comparison_tool/index.html) for information on how to use CCT. The [tutorials](https://paulstothard.github.io/cgview_comparison_tool/tutorials.html) are a good starting point.


=====================================
lib/scripts/assign_cogs/test.sh
=====================================
@@ -6,29 +6,17 @@ if [ ! -d test_output ]; then
     mkdir test_output
 fi
 
-if [ ! -d db ]; then
-    mkdir db
-fi
-
-if [ -f db/myva ]; then
-    cp db/myva test_output
-fi
-
-if [ -f db/myva.gz ]; then
-    cp db/myva.gz test_output
+if [ ! -f test_output/myva ]; then
+    cp -f db/myva.gz test_output
     gunzip test_output/myva.gz
 fi
 
-if [ -f db/whog ]; then
-    cp db/whog test_output
-fi
-
-if [ -f db/whog.gz ]; then
-    cp db/whog.gz test_output
+if [ ! -f test_output/whog ]; then
+    cp -f db/whog.gz test_output
     gunzip test_output/whog.gz
 fi
 
-formatdb -p T -i test_output/myva -o T
+FORMATDB -p T -i test_output/myva -o T
 
 rm formatdb.log
 
@@ -56,15 +44,16 @@ rm test_output/whog*
 #compare new output to sample output
 new_output=test_output
 old_output=sample_output
+IFS=$'\n'
 new_files=($( find $new_output -type f -print0 | perl -ne 'my @files = split(/\0/, $_); foreach(@files) { if (!($_ =~ m/\.svn/)) {print "$_\n";}}'))
+unset IFS
 for (( i=0; i<${#new_files[@]}; i++ ));
 do
-    old_file=${old_output}`echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_'`
+    old_file=${old_output}$(echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_')
     echo "Comparing ${old_file} to ${new_files[$i]}"
     set +e
-    diff -u $old_file ${new_files[$i]}
-    if [ $? -eq 0 ]; then
-	echo "No differences found"
+    if diff -u "$old_file" "${new_files[$i]}"; then
+	  echo "No differences found"
     fi
     set -e
 done
\ No newline at end of file


=====================================
lib/scripts/cgview_xml_builder/test_input/R_denitrificans.cogs
=====================================
@@ -4,8 +4,8 @@
 #'start', 'end', and 'strand' information is retrieved.
 
 seqname	source	feature	start	end	score	strand	frame
-RD0004		R
-RD0005		Q
+RD0004		RQ
+RD0005		QRL
 RD0006		R
 RD0007		R
 RD0008		L
@@ -3789,4 +3789,4 @@ RD4249		A
 RD4249		A
 RD4250		A
 RD4251		A
-RD4252		R
\ No newline at end of file
+RD4252		R


=====================================
lib/scripts/convert_vcf_to_features/test.sh
=====================================
@@ -12,15 +12,16 @@ perl convert_vcf_to_features.pl -i test_input/input_multiple_chromosomes.vcf -o
 #compare new output to sample output
 new_output=test_output
 old_output=sample_output
+IFS=$'\n'
 new_files=($( find $new_output -type f -print0 | perl -ne 'my @files = split(/\0/, $_); foreach(@files) { if (!($_ =~ m/\.svn/)) {print "$_\n";}}'))
+unset IFS
 for (( i=0; i<${#new_files[@]}; i++ ));
 do
-    old_file=${old_output}`echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_'`
+    old_file=${old_output}$(echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_')
     echo "Comparing ${old_file} to ${new_files[$i]}"
     set +e
-    diff -u $old_file ${new_files[$i]}
-    if [ $? -eq 0 ]; then
-	echo "No differences found"
+    if diff -u "$old_file" "${new_files[$i]}"; then
+	  echo "No differences found"
     fi
     set -e
-done
+done
\ No newline at end of file


=====================================
lib/scripts/get_cds/test.sh
=====================================
@@ -13,15 +13,16 @@ perl get_cds.pl -i test_input/prokka_multicontig.gbk -o test_output/prokka_multi
 #compare new output to sample output
 new_output=test_output
 old_output=sample_output
+IFS=$'\n'
 new_files=($( find $new_output -type f -print0 | perl -ne 'my @files = split(/\0/, $_); foreach(@files) { if (!($_ =~ m/\.svn/)) {print "$_\n";}}'))
+unset IFS
 for (( i=0; i<${#new_files[@]}; i++ ));
 do
-    old_file=${old_output}`echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_'`
+    old_file=${old_output}$(echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_')
     echo "Comparing ${old_file} to ${new_files[$i]}"
     set +e
-    diff -u $old_file ${new_files[$i]}
-    if [ $? -eq 0 ]; then
-	echo "No differences found"
+    if diff -u "$old_file" "${new_files[$i]}"; then
+	  echo "No differences found"
     fi
     set -e
 done
\ No newline at end of file


=====================================
lib/scripts/get_orfs/test.sh
=====================================
@@ -13,15 +13,16 @@ perl get_orfs.pl -i test_input/prokka_multicontig.gbk -o test_output/prokka_mult
 #compare new output to sample output
 new_output=test_output
 old_output=sample_output
+IFS=$'\n'
 new_files=($( find $new_output -type f -print0 | perl -ne 'my @files = split(/\0/, $_); foreach(@files) { if (!($_ =~ m/\.svn/)) {print "$_\n";}}'))
+unset IFS
 for (( i=0; i<${#new_files[@]}; i++ ));
 do
-    old_file=${old_output}`echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_'`
+    old_file=${old_output}$(echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_')
     echo "Comparing ${old_file} to ${new_files[$i]}"
     set +e
-    diff -u $old_file ${new_files[$i]}
-    if [ $? -eq 0 ]; then
-	echo "No differences found"
+    if diff -u "$old_file" "${new_files[$i]}"; then
+	  echo "No differences found"
     fi
     set -e
 done
\ No newline at end of file


=====================================
lib/scripts/local_blast_client/local_blast_client.pl
=====================================
@@ -198,7 +198,18 @@ while ( my $sequenceEntry = <SEQFILE> ) {
 #-b can be used to specify the number of hits to return when using -m 9. Each hit may consist of one or more HSPs.
 #-b and -v must be set to specify the number of hits to return when using -m 7. Each hit may consist of one or more HSPs.
     my $blast_command
-        = "$settings{BLAST_PATH} -p $settings{PROGRAM} -d $settings{DATABASE} -e $settings{EXPECT} -i $filename -b $settings{HITLIST_SIZE} -v $settings{HITLIST_SIZE} -m $format_type -Q $settings{QUERY_GENETIC_CODE} -D $settings{DATABASE_GENETIC_CODE} -W $settings{WORD_SIZE} -F $settings{FILTER}";
+        = "$settings{BLAST_PATH} -p $settings{PROGRAM} -d $settings{DATABASE} -e $settings{EXPECT} -i $filename -b $settings{HITLIST_SIZE} -v $settings{HITLIST_SIZE} -m $format_type -W $settings{WORD_SIZE} -F $settings{FILTER}";
+
+    if ($settings{PROGRAM} eq 'blastx') {
+        $blast_command .= " -Q $settings{QUERY_GENETIC_CODE}";
+    }
+    elsif ($settings{PROGRAM} eq 'tblastn') {
+        $blast_command .= " -D $settings{DATABASE_GENETIC_CODE}";
+    }
+    elsif ($settings{PROGRAM} eq 'tblastx') {
+        $blast_command .= " -Q $settings{QUERY_GENETIC_CODE}";
+        $blast_command .= " -D $settings{DATABASE_GENETIC_CODE}";
+    }
 
     print
         "Performing BLAST search for sequence number $seqCount ($sequenceTitle).\n";


=====================================
lib/scripts/local_blast_client/test.sh
=====================================
@@ -36,15 +36,16 @@ rm -rf test_output/formatted_databases
 #compare new output to sample output
 new_output=test_output
 old_output=sample_output
+IFS=$'\n'
 new_files=($( find $new_output -type f -print0 | perl -ne 'my @files = split(/\0/, $_); foreach(@files) { if (!($_ =~ m/\.svn/)) {print "$_\n";}}'))
+unset IFS
 for (( i=0; i<${#new_files[@]}; i++ ));
 do
-    old_file=${old_output}`echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_'`
+    old_file=${old_output}$(echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_')
     echo "Comparing ${old_file} to ${new_files[$i]}"
     set +e
-    diff -u $old_file ${new_files[$i]}
-    if [ $? -eq 0 ]; then
-	echo "No differences found"
+    if diff -u "$old_file" "${new_files[$i]}"; then
+	  echo "No differences found"
     fi
     set -e
 done
\ No newline at end of file


=====================================
lib/scripts/ncbi_search/README.md
=====================================
@@ -29,7 +29,7 @@ usage:
 
   perl ncbi_search.pl -help
 
-PERFORM NCBI SEARCH:
+PERFORM NCBI SEARCH
 
 usage:
 


=====================================
lib/scripts/ncbi_search/ncbi_search.pl
=====================================
@@ -255,7 +255,7 @@ usage:
 
   perl ncbi_search.pl -help
 
-PERFORM NCBI SEARCH:
+PERFORM NCBI SEARCH
 
 usage:
 


=====================================
lib/scripts/ncbi_search/test.sh
=====================================
@@ -10,15 +10,16 @@ perl ncbi_search.pl -q 'NC_009925:NC_009934[Accession]' -o test_output -d nuccor
 #compare new output to sample output
 new_output=test_output
 old_output=sample_output
+IFS=$'\n'
 new_files=($( find $new_output -type f -print0 | perl -ne 'my @files = split(/\0/, $_); foreach(@files) { if (!($_ =~ m/\.svn/)) {print "$_\n";}}'))
+unset IFS
 for (( i=0; i<${#new_files[@]}; i++ ));
 do
-    old_file=${old_output}`echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_'`
+    old_file=${old_output}$(echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_')
     echo "Comparing ${old_file} to ${new_files[$i]}"
     set +e
-    diff -u $old_file ${new_files[$i]}
-    if [ $? -eq 0 ]; then
-	echo "No differences found"
+    if diff -u "$old_file" "${new_files[$i]}"; then
+	  echo "No differences found"
     fi
     set -e
-done
+done
\ No newline at end of file


=====================================
lib/scripts/sequence_to_multi_fasta/test.sh
=====================================
@@ -15,15 +15,16 @@ perl sequence_to_multi_fasta.pl -i test_input/test_seq_multi.fasta -o test_outpu
 #compare new output to sample output
 new_output=test_output
 old_output=sample_output
+IFS=$'\n'
 new_files=($( find $new_output -type f -print0 | perl -ne 'my @files = split(/\0/, $_); foreach(@files) { if (!($_ =~ m/\.svn/)) {print "$_\n";}}'))
+unset IFS
 for (( i=0; i<${#new_files[@]}; i++ ));
 do
-    old_file=${old_output}`echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_'`
+    old_file=${old_output}$(echo "${new_files[$i]}" | perl -nl -e 's/^[^\/]+//;' -e 'print $_')
     echo "Comparing ${old_file} to ${new_files[$i]}"
     set +e
-    diff -u $old_file ${new_files[$i]}
-    if [ $? -eq 0 ]; then
-	echo "No differences found"
+    if diff -u "$old_file" "${new_files[$i]}"; then
+	  echo "No differences found"
     fi
     set -e
 done
\ No newline at end of file


=====================================
scripts/build_blast_atlas.sh
=====================================
@@ -9,7 +9,7 @@ size=""
 start_at_map=""
 start_at_xml=""
 
-PROGNAME=$(basename $0)
+PROGNAME=$(basename "$0")
 
 function usage() {
     echo "
@@ -85,7 +85,7 @@ function error_exit() {
 function get_filename_without_extension() {
     basefile=$(basename "$1")
     filename=${basefile%.*}
-    echo $filename
+    echo "$filename"
 }
 
 while [ "$1" != "" ]; do
@@ -133,7 +133,7 @@ while [ "$1" != "" ]; do
 done
 
 # The CCT_HOME variable must be set
-if [ -z $CCT_HOME ]; then
+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
@@ -145,7 +145,7 @@ elif [ -n "$input" ]; then
     if [ ! -f "$input" ]; then
         error_exit "The input GenBank file '$input' does not exist"
     fi
-    project_dir=$(get_filename_without_extension $input)
+    project_dir=$(get_filename_without_extension "$input")
 else
     error_exit "Please use '-i' to specify an input sequence file in GenBank format, with .gbk extension or the '-p' option to specify the project directory. For a full list of options use '-h'."
 fi
@@ -227,7 +227,7 @@ if ! $new_project; then
         fi
 
         if [ -n "$start_at_map" ]; then
-            if [ -d "${project_dir}/maps_for_${type}/cgview_xml/" ] && [ "$(ls -A ${project_dir}/maps_for_${type}/cgview_xml/)" ]; then
+            if [ -d "${project_dir}/maps_for_${type}/cgview_xml/" ] && [ "$(ls -A "${project_dir}/maps_for_${type}/cgview_xml/")" ]; then
                 echo "Redrawing maps for map type $type using existing XML."
                 eval "$command --start_at_map"
                 echo "Maps drawn to ${project_dir}/maps_for_${type}"
@@ -235,7 +235,7 @@ if ! $new_project; then
                 error_exit "The --start_at_map option was provided but there are no XML files present."
             fi
         elif [ -n "$start_at_xml" ]; then
-            if [ -d "${project_dir}/cct_projects/${type}/blast/blast_results_local/" ] && [ "$(ls -A $project_dir/cct_projects/$type/blast/blast_results_local/)" ]; then
+            if [ -d "${project_dir}/cct_projects/${type}/blast/blast_results_local/" ] && [ "$(ls -A "$project_dir/cct_projects/$type/blast/blast_results_local/")" ]; then
                 echo "Redrawing maps for map type $type using existing BLAST results."
                 eval "$command --start_at_xml"
                 echo "Maps drawn to ${project_dir}/maps_for_${type}"
@@ -245,7 +245,7 @@ if ! $new_project; then
         else
             # Redraw from start
             echo "Creating maps for map type $type in ${project_dir}/maps_for_${type}"
-            eval $command
+            eval "$command"
             echo "Maps drawn to ${project_dir}/maps_for_${type}"
         fi
 


=====================================
scripts/build_blast_atlas_all_vs_all.sh
=====================================
@@ -11,7 +11,7 @@ start_at_xml=""
 start_at_montage=""
 columns=4
 
-PROGNAME=$(basename $0)
+PROGNAME=$(basename "$0")
 
 function usage() {
     echo "
@@ -91,7 +91,7 @@ function error_exit() {
 function get_filename_without_extension() {
     basefile=$(basename "$1")
     filename=${basefile%.*}
-    echo $filename
+    echo "$filename"
 }
 
 # Check for ImageMagick
@@ -193,23 +193,22 @@ if (! $new_project) && [ -z "$start_at_montage" ]; then
     fi
 
     # Find all the gbk files, sort by accession and for each one create a new cgview_comparison_tool project
+    IFS=$'\n'
     files=($(find "${project_dir}/comparison_genomes" -maxdepth 1 -type f \( -name "*.gbk" -o -name "*.gb" \) -print0 | perl -ne 'my @files = split(/\0/, $_); my @sorted = sort {$a =~ m/[AN]C_0*(\d+)/; $a_char = $1; $b =~ m/[AN]C_0*(\d+)/; $b_char = $1; return ($a_char <=> $b_char);} @files; foreach(@sorted) { print "$_\n";}'))
+    unset IFS
+
     length=${#files[@]}
-    for ((i = 0; i < $length; i++)); do
+    for ((i = 0; i < length; i++)); do
 
         seqname=$(get_filename_without_extension "${files[$i]}")
-        after=$i+1
-        after_length=$length-$after
-        reference_genome=$(basename "${files[$i]}")
 
-        #the following leaves out the reference genome
-        #comparison_genomes=( ${files[@]:0:$i} ${files[@]:$after:$after_length} )
+        reference_genome=$(basename "${files[$i]}")
 
-        comparison_genomes=(${files[@]:0:$length})
+        comparison_genomes=("${files[@]:0:$length}")
 
         echo "Generating project for $reference_genome as the reference genome."
         echo "The comparison genomes are:"
-        echo ${comparison_genomes[@]}
+        echo "${comparison_genomes[@]}"
 
         # Create project and links
         if [ ! -d "${project_dir}/cct_projects/${seqname}" ]; then
@@ -220,7 +219,7 @@ if (! $new_project) && [ -z "$start_at_montage" ]; then
 
             # Create links to comparison genomes
             length_comparison=${#comparison_genomes[@]}
-            for ((j = 0; j < $length_comparison; j++)); do
+            for ((j = 0; j < length_comparison; j++)); do
                 filename_comparison=$(basename "${comparison_genomes[$j]}")
                 ln -s "../../../comparison_genomes/${filename_comparison}" "${project_dir}/cct_projects/${seqname}/comparison_genomes/${filename_comparison}"
             done
@@ -243,7 +242,7 @@ if (! $new_project) && [ -z "$start_at_montage" ]; then
         fi
 
         if [ -n "$start_at_map" ]; then
-            if [ -d "${project_dir}/cct_projects/${seqname}/maps/cgview_xml/" ] && [ "$(ls -A ${project_dir}/cct_projects/${seqname}/maps/cgview_xml/)" ]; then
+            if [ -d "${project_dir}/cct_projects/${seqname}/maps/cgview_xml/" ] && [ "$(ls -A "${project_dir}/cct_projects/${seqname}/maps/cgview_xml/")" ]; then
                 #xml present, draw from xml
                 echo "Redrawing maps for map $seqname using existing XML."
                 eval "$command --start_at_map"
@@ -251,7 +250,7 @@ if (! $new_project) && [ -z "$start_at_montage" ]; then
                 error_exit "The --start_at_map option was provided but there are no XML files present."
             fi
         elif [ -n "$start_at_xml" ]; then
-            if [ -d "$project_dir/cct_projects/$seqname/blast/blast_results_local/" ] && [ "$(ls -A $project_dir/cct_projects/$seqname/blast/blast_results_local/)" ]; then
+            if [ -d "$project_dir/cct_projects/$seqname/blast/blast_results_local/" ] && [ "$(ls -A "$project_dir/cct_projects/$seqname/blast/blast_results_local/")" ]; then
                 #blast results present, build xml and draw
                 echo "Redrawing maps for map $seqname using existing BLAST results."
                 eval "$command --start_at_xml"
@@ -261,7 +260,7 @@ if (! $new_project) && [ -z "$start_at_montage" ]; then
         else
             # Redraw from start
             echo "Creating maps for map $seqname in $project_dir/cct_projects/$seqname/maps"
-            eval $command
+            eval "$command"
         fi
     done
 fi
@@ -269,12 +268,14 @@ fi
 # COMBINE IMAGES USING IMAGEMAGICK
 if (! $new_project) || [ -n "$start_at_montage" ]; then
     # This sorts the files by accession
+    IFS=$'\n'
     png_files=($(find "$project_dir"/cct_projects -type f \( -name "*.png" \) -print0 | perl -ne 'my @files = split(/\0/, $_); my @sorted = sort {$a =~ m/[A-Z][A-Z]_*0*(\d+)/; $a_char = $1; $b =~ m/[A-Z][A-Z]_*0*(\d+)/; $b_char = $1; return ($a_char <=> $b_char);} @files; foreach(@sorted) { print "$_\n";}'))
+    unset IFS
     png_length=${#png_files[@]}
     #for (( i=0; i<$png_length; i++ ));
     #do
     #convert "${png_files[$i]}" -resize 40% "${png_files[$i]}"
     #done
-    montage "${png_files[@]:0}" -resize 40% -tile ${columns}x -geometry 800x800\>+2+2 -background "#FFFFFF" "$project_dir"/montage.png
+    montage "${png_files[@]:0}" -resize 40% -tile "${columns}"x -geometry 800x800\>+2+2 -background "#FFFFFF" "$project_dir"/montage.png
     echo "Montage drawn to $project_dir/montage.png"
 fi


=====================================
scripts/build_cog_db.sh
=====================================
@@ -16,7 +16,7 @@ if [ -z "$CCT_HOME" ]; then
   For example, add the following to your ~/.bashrc
   or ~/.bash_profile file:
 
-    export CCT_HOME="/path/to/cgview_comparison_tool"
+    export CCT_HOME=\"/path/to/cgview_comparison_tool\"
 
   After saving reload your ~/.bashrc or ~/.bash_profile file:
 
@@ -34,7 +34,7 @@ fi
 
 if [ -f "${CCT_HOME}"/cog_db/.complete ]; then
   echo "COG BLAST database already created"
-  echo "Remove '"${CCT_HOME}"/cog_db/.complete' to create again"
+  echo "Remove '${CCT_HOME}/cog_db/.complete' to create again"
   exit 0
 fi
 


=====================================
scripts/check_env.sh
=====================================
@@ -39,7 +39,7 @@ if [ -z "$CCT_HOME" ]; then
   For example, add the following to your ~/.bashrc
   or ~/.bash_profile file:
 
-    export CCT_HOME="/path/to/cgview_comparison_tool"
+    export CCT_HOME=\"/path/to/cgview_comparison_tool\"
 
   After saving reload your ~/.bashrc or ~/.bash_profile file:
 
@@ -60,7 +60,7 @@ for j in Util::Configurator Util::LogManager; do
   
   For example, add the following to your ~/.bashrc or ~/.bash_profile file:
 
-    export PERL5LIB="\$PERL5LIB":"${CCT_HOME}"/lib/perl_modules
+    export PERL5LIB=\"\$PERL5LIB\":\"${CCT_HOME}\"/lib/perl_modules
 
   After saving reload your ~/.bashrc or ~/.bash_profile file:
 
@@ -80,7 +80,7 @@ if ! command -v cgview_comparison_tool.pl &>/dev/null; then
   
   For example, add the following to your ~/.bashrc or ~/.bash_profile file:
 
-    export PATH="\$PATH":"${CCT_HOME}"/scripts
+    export PATH=\"\$PATH\":\"${CCT_HOME}\"/scripts
 
   After saving reload your ~/.bashrc or ~/.bash_profile file:
 


=====================================
scripts/create_zoomed_maps.sh
=====================================
@@ -3,7 +3,7 @@
 format=png
 mem=1500m
 
-PROGNAME=$(basename $0)
+PROGNAME=$(basename "$0")
 
 function usage() {
     echo "
@@ -43,19 +43,19 @@ function error_exit() {
 function get_filename_without_extension() {
     basefile=$(basename "$1")
     filename=${basefile%.*}
-    echo $filename
+    echo "$filename"
 }
 
 function get_path_to_maps() {
     file="$1"
     filename=$(echo "$file" | perl -nl -e 'm/(.+)\/cgview_xml\/[^\/]+$/;' -e 'print $1')
-    echo $filename
+    echo "$filename"
 }
 
 function remove_trailing_slash() {
     string="$1"
     new_string=$(echo "$string" | perl -nl -e 's/\/+$//;' -e 'print $_')
-    echo $new_string
+    echo "$new_string"
 }
 
 while [ "$1" != "" ]; do
@@ -116,22 +116,11 @@ fi
 
 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 -L "$project" -type f -name "*.xml"))
-
-# restore IFS
-IFS=$OLDIFS
-
-length=${#files[@]}
-for ((i = 0; i < $length; i++)); do
-    xml_file=${files[$i]}
+find "$project" -name "*.xml" -type f | while IFS= read -r xml_file; do
     echo "Generating zoomed 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/cgview.jar -i "$xml_file" -c $center -z $zoom -o "$path_to_maps"/"${file_no_extension}_${center}_${zoom}"."$format" -f "$format"
+    java -jar -Xmx"${mem}" "$cct_home"/bin/cgview/cgview.jar -i "$xml_file" -c "$center" -z "$zoom" -o "$path_to_maps/${file_no_extension}_${center}_${zoom}.$format" -f "$format"
     echo "New map drawn to $path_to_maps/${file_no_extension}_${center}_${zoom}.${format}"
 done


=====================================
scripts/fetch_all_refseq_bacterial_genomes.sh
=====================================
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 
-PROGNAME=$(basename $0)
+PROGNAME=$(basename "$0")
 
 function usage() {
     echo "
@@ -37,7 +37,7 @@ function error_exit() {
 function remove_trailing_slash() {
     string="$1"
     new_string=$(echo "$string" | perl -nl -e 's/\/+$//;' -e 'print $_')
-    echo $new_string
+    echo "$new_string"
 }
 
 min_length=""
@@ -70,7 +70,7 @@ while [ "$1" != "" ]; do
 done
 
 # The CCT_HOME variable must be set
-if [ -z $CCT_HOME ]; then
+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
@@ -92,7 +92,7 @@ if [ -n "$min_length" ]; then
     if [ -n "$max_length" ]; then
         query=$query" AND ${min_length}:${max_length}[SLEN]"
     else
-        min_length=$(expr $min_length - 1)
+        min_length="$(( min_length - 1 ))"
         query=$query" NOT 1:${min_length}[SLEN]"
     fi
 elif [ -n "$max_length" ]; then


=====================================
scripts/fetch_all_refseq_chloroplast_genomes.sh
=====================================
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 
-PROGNAME=$(basename $0)
+PROGNAME=$(basename "$0")
 
 function usage() {
     echo "
@@ -31,7 +31,7 @@ function error_exit() {
 function remove_trailing_slash() {
     string="$1"
     new_string=$(echo "$string" | perl -nl -e 's/\/+$//;' -e 'print $_')
-    echo $new_string
+    echo "$new_string"
 }
 
 # Check for ncbi_search.pl
@@ -60,7 +60,7 @@ while [ "$1" != "" ]; do
 done
 
 # The CCT_HOME variable must be set
-if [ -z $CCT_HOME ]; then
+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


=====================================
scripts/fetch_all_refseq_mitochondrial_genomes.sh
=====================================
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 
-PROGNAME=$(basename $0)
+PROGNAME=$(basename "$0")
 
 function usage() {
     echo "
@@ -31,7 +31,7 @@ function error_exit() {
 function remove_trailing_slash() {
     string="$1"
     new_string=$(echo "$string" | perl -nl -e 's/\/+$//;' -e 'print $_')
-    echo $new_string
+    echo "$new_string"
 }
 
 while [ "$1" != "" ]; do
@@ -53,7 +53,7 @@ while [ "$1" != "" ]; do
 done
 
 # The CCT_HOME variable must be set
-if [ -z $CCT_HOME ]; then
+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


=====================================
scripts/fetch_genome_by_accession.sh
=====================================
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 
-PROGNAME=$(basename $0)
+PROGNAME=$(basename "$0")
 
 function usage() {
     echo "
@@ -33,7 +33,7 @@ function error_exit() {
 function remove_trailing_slash() {
     string="$1"
     new_string=$(echo "$string" | perl -nl -e 's/\/+$//;' -e 'print $_')
-    echo $new_string
+    echo "$new_string"
 }
 
 while [ "$1" != "" ]; do
@@ -59,20 +59,20 @@ while [ "$1" != "" ]; do
 done
 
 # The CCT_HOME variable must be set
-if [ -z $CCT_HOME ]; then
+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
 
-if [ -z $accession ]; then
+if [ -z "$accession" ]; then
     error_exit "Please use '-a' to specify the accession number of the genome to download. Use '-h' for help."
 fi
 
-if [ -z $directory ]; then
+if [ -z "$directory" ]; then
     error_exit "Please use '-o' to specify an output directory. Use '-h' for help."
 fi
 
-if [ -z $CCT_HOME ]; then
+if [ -z "$CCT_HOME" ]; then
     error_exit "Please set the \$CCT_HOME environment variable to the path to the cgview_comparison_tool directory"
 fi
 
@@ -82,6 +82,6 @@ if [ ! -d "$directory" ]; then
     mkdir -p "$directory"
 fi
 
-perl "$cct_home"/lib/scripts/ncbi_search/ncbi_search.pl -q "$accession"[ACCESSION] -d nucleotide -o "$directory"/"$accession".gbk -r gbwithparts -m 1 -v
+perl "$cct_home/lib/scripts/ncbi_search/ncbi_search.pl" -q "$accession"'[ACCESSION]' -d nucleotide -o "$directory/$accession.gbk" -r gbwithparts -m 1 -v
 
 echo "The record has been saved to ${directory}/${accession}.gbk"


=====================================
scripts/fetch_refseq_bacterial_genomes_by_name.sh
=====================================
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 
-PROGNAME=$(basename $0)
+PROGNAME=$(basename "$0")
 
 function usage() {
     echo "
@@ -39,7 +39,7 @@ function error_exit() {
 function remove_trailing_slash() {
     string="$1"
     new_string=$(echo "$string" | perl -nl -e 's/\/+$//;' -e 'print $_')
-    echo $new_string
+    echo "$new_string"
 }
 
 min_length=""
@@ -76,7 +76,7 @@ while [ "$1" != "" ]; do
 done
 
 # The CCT_HOME variable must be set
-if [ -z $CCT_HOME ]; then
+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
@@ -102,7 +102,7 @@ if [ -n "$min_length" ]; then
     if [ -n "$max_length" ]; then
         query=$query" AND ${min_length}:${max_length}[SLEN]"
     else
-        min_length=$(expr $min_length - 1)
+        min_length="$(( min_length - 1 ))"
         query=$query" NOT 1:${min_length}[SLEN]"
     fi
 elif [ -n "$max_length" ]; then


=====================================
scripts/process_sample_projects.sh
=====================================
@@ -16,7 +16,7 @@ if [ -z "$CCT_HOME" ]; then
   For example, add the following to your ~/.bashrc
   or ~/.bash_profile file:
 
-    export CCT_HOME="/path/to/cgview_comparison_tool"
+    export CCT_HOME=\"/path/to/cgview_comparison_tool\"
 
   After saving reload your ~/.bashrc or ~/.bash_profile file:
 
@@ -32,16 +32,18 @@ if [ ! -d "${CCT_HOME}"/test_output ]; then
   mkdir "${CCT_HOME}"/test_output
 fi
 
+IFS=$'\n'
 SAMPLE_PROJECTS=($(find "${CCT_HOME}/sample_projects" -mindepth 1 -maxdepth 1 -name 'sample_project_*' -type d))
+unset IFS
 for project in "${SAMPLE_PROJECTS[@]}"; do
   p=$(basename "$project")
   echo "Processing project '$p'"
   cp -R "$project" "${CCT_HOME}"/test_output
   for j in project_settings_a.conf project_settings_b.conf project_settings_c.conf; do
     echo "Processing project '$p' using configuration '$j'"
-    command="perl '${CCT_HOME}/scripts/cgview_comparison_tool.pl' -g '"${CCT_HOME}"/conf/global_settings.conf' -p '"${CCT_HOME}"/test_output/$p' -s '"${CCT_HOME}"/test_output/$p/$j' -f '${p}_${j}_'"
-    eval $command
+    command="perl ${CCT_HOME}/scripts/cgview_comparison_tool.pl -g ${CCT_HOME}/conf/global_settings.conf -p ${CCT_HOME}/test_output/$p -s ${CCT_HOME}/test_output/$p/$j -f ${p}_${j}_"
+    eval "$command"
   done
 done
 
-echo "Sample project output written to "${CCT_HOME}"/test_output"
+echo "Sample project output written to '${CCT_HOME}/test_output'"


=====================================
scripts/process_test_projects.sh
=====================================
@@ -16,7 +16,7 @@ if [ -z "$CCT_HOME" ]; then
   For example, add the following to your ~/.bashrc
   or ~/.bash_profile file:
 
-    export CCT_HOME="/path/to/cgview_comparison_tool"
+    export CCT_HOME=\"/path/to/cgview_comparison_tool\"
 
   After saving reload your ~/.bashrc or ~/.bash_profile file:
 
@@ -32,16 +32,18 @@ if [ ! -d "${CCT_HOME}"/test_output ]; then
   mkdir "${CCT_HOME}"/test_output
 fi
 
+IFS=$'\n'
 TEST_PROJECTS=($(find "${CCT_HOME}/test_projects" -mindepth 1 -maxdepth 1 -name 'test_*' -type d))
+unset IFS
 for project in "${TEST_PROJECTS[@]}"; do
   p=$(basename "$project")
   echo "Processing project '$p'"
   cp -R "$project" "${CCT_HOME}"/test_output
   for j in project_settings.conf; do
     echo "Processing project '$p' using configuration '$j'"
-    command="perl '${CCT_HOME}/scripts/cgview_comparison_tool.pl' -g '"${CCT_HOME}"/conf/global_settings.conf' -p '"${CCT_HOME}"/test_output/$p' -s '"${CCT_HOME}"/test_output/$p/$j' -f '${p}_${j}_'"
-    eval $command
+    command="perl ${CCT_HOME}/scripts/cgview_comparison_tool.pl -g ${CCT_HOME}/conf/global_settings.conf -p ${CCT_HOME}/test_output/$p -s ${CCT_HOME}/test_output/$p/$j -f ${p}_${j}_"
+    eval "$command"
   done
 done
 
-echo "Test project output written to "${CCT_HOME}"/test_output"
+echo "Test project output written to '${CCT_HOME}/test_output'"


=====================================
scripts/redraw_maps.sh
=====================================
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 
-PROGNAME=$(basename $0)
+PROGNAME=$(basename "$0")
 
 format=png
 mem=1500m
@@ -40,19 +40,19 @@ function error_exit() {
 function get_filename_without_extension() {
     basefile=$(basename "$1")
     filename=${basefile%.*}
-    echo $filename
+    echo "$filename"
 }
 
 function get_path_to_maps() {
     file="$1"
     filename=$(echo "$file" | perl -nl -e 'm/(.+)\/cgview_xml\/[^\/]+$/;' -e 'print $1')
-    echo $filename
+    echo "$filename"
 }
 
 function remove_trailing_slash() {
     string="$1"
     new_string=$(echo "$string" | perl -nl -e 's/\/+$//;' -e 'print $_')
-    echo $new_string
+    echo "$new_string"
 }
 
 while [ "$1" != "" ]; do
@@ -85,7 +85,7 @@ if [ -z "$project" ]; then
     error_exit "Please use '-p' to specify a project. Use '-h' for help."
 fi
 
-if [ -z $CCT_HOME ]; then
+if [ -z "$CCT_HOME" ]; then
     error_exit "Please set the \$CCT_HOME environment variable to the path to the cgview_comparison_tool directory."
 fi
 
@@ -93,22 +93,17 @@ 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
+IFS=$'\n'
 files=($(find "$project" -type f -name "*.xml"))
-
-# restore IFS
-IFS=$OLDIFS
+unset IFS
 
 length=${#files[@]}
-for ((i = 0; i < $length; i++)); do
+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/cgview.jar -i "$xml_file" -o "$path_to_maps"/"${file_no_extension}"."$format" -f "$format"
+    java -jar -Xmx"${mem}" "$cct_home"/bin/cgview/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


=====================================
scripts/remove_long_seqs.sh
=====================================
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 
-PROGNAME=$(basename $0)
+PROGNAME=$(basename "$0")
 
 function usage() {
     echo "
@@ -34,13 +34,13 @@ function error_exit() {
 function remove_trailing_slash() {
     string="$1"
     new_string=$(echo "$string" | perl -nl -e 's/\/+$//;' -e 'print $_')
-    echo $new_string
+    echo "$new_string"
 }
 
 function get_sequence_length() {
     file="$1"
     seq_length=$(head -n 1 "$file" | perl -nl -e 'm/(\d+)\sbp/;' -e 'print $1')
-    echo $seq_length
+    echo "$seq_length"
 }
 
 while [ "$1" != "" ]; do
@@ -69,7 +69,7 @@ if [ -z "$input" ]; then
     error_exit "Please use '-i' to specify an input directory of GenBank files with .gbk extensions. Use '-h' for help."
 fi
 
-if [ -z $max_length ]; then
+if [ -z "$max_length" ]; then
     error_exit "Please use '-l' to specify a maximum sequence length to keep. Use '-h' for help."
 fi
 
@@ -77,23 +77,18 @@ cct_home=$CCT_HOME
 
 input=$(remove_trailing_slash "$input")
 
-# save and change IFS to avoid problems with filesnames with spaces
-OLDIFS=$IFS
-IFS=$'\n'
-
 #find all GenBank files in the directory
+IFS=$'\n'
 files=($(find "$input" -maxdepth 1 -type f -name "*.gbk"))
-
-# restore IFS
-IFS=$OLDIFS
+unset IFS
 
 length=${#files[@]}
-echo $length
-for ((i = 0; i < $length; i++)); do
+
+for ((i = 0; i < length; i++)); do
     gbk_file=${files[$i]}
     seq_length=$(get_sequence_length "$gbk_file")
 
-    if [ -z $seq_length ]; then
+    if [ -z "$seq_length" ]; then
         error_exit "Unable to determine length of sequence '$gbk_file'"
     fi
 


=====================================
scripts/remove_short_seqs.sh
=====================================
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 
-PROGNAME=$(basename $0)
+PROGNAME=$(basename "$0")
 
 function usage() {
     echo "usage: remove_short_seqs.sh [[-i input] [-l length] | [-h]]"
@@ -37,13 +37,13 @@ function error_exit() {
 function remove_trailing_slash() {
     string="$1"
     new_string=$(echo "$string" | perl -nl -e 's/\/+$//;' -e 'print $_')
-    echo $new_string
+    echo "$new_string"
 }
 
 function get_sequence_length() {
     file="$1"
     seq_length=$(head -n 1 "$file" | perl -nl -e 'm/(\d+)\sbp/;' -e 'print $1')
-    echo $seq_length
+    echo "$seq_length"
 }
 
 while [ "$1" != "" ]; do
@@ -68,11 +68,11 @@ while [ "$1" != "" ]; do
     shift
 done
 
-if [ -z $input ]; then
+if [ -z "$input" ]; then
     error_exit "Please use '-i' to specify an input directory of GenBank files with .gbk extensions. Use '-h' for help."
 fi
 
-if [ -z $min_length ]; then
+if [ -z "$min_length" ]; then
     error_exit "Please use '-l' to specify a minimum sequence length to keep. Use '-h' for help."
 fi
 
@@ -80,22 +80,17 @@ cct_home=$CCT_HOME
 
 input=$(remove_trailing_slash "$input")
 
-# save and change IFS to avoid problems with filesnames with spaces
-OLDIFS=$IFS
-IFS=$'\n'
-
 #find all GenBank files in the directory
+IFS=$'\n'
 files=($(find "$input" -maxdepth 1 -type f -name "*.gbk"))
-
-# restore IFS
-IFS=$OLDIFS
+unset IFS
 
 length=${#files[@]}
-for ((i = 0; i < $length; i++)); do
+for ((i = 0; i < length; i++)); do
     gbk_file=${files[$i]}
     seq_length=$(get_sequence_length "$gbk_file")
 
-    if [ -z $seq_length ]; then
+    if [ -z "$seq_length" ]; then
         error_exit "Unable to determine length of sequence '$gbk_file'"
     fi
 



View it on GitLab: https://salsa.debian.org/med-team/cct/-/commit/8c996c301859f25f037fd3ccbe1870a29cdaaf74

-- 
View it on GitLab: https://salsa.debian.org/med-team/cct/-/commit/8c996c301859f25f037fd3ccbe1870a29cdaaf74
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20210720/0444ebe9/attachment-0001.htm>


More information about the debian-med-commit mailing list