From dd15f79bb95a118162a4e247a7c8689bd2f90e93 Mon Sep 17 00:00:00 2001 From: Hans Date: Wed, 26 Apr 2023 09:23:12 +0200 Subject: [PATCH] Removed the bash careful mode as it created issues with Ubuntu users. Replaced a bash command for changing column orders in tabular files with a python script --- mOTUs-extender/extend_mOTUs_addGenome.sh | 2 +- mOTUs-extender/extend_mOTUs_addMarkerGenes.sh | 2 +- mOTUs-extender/extend_mOTUs_generateDB.sh | 5 +++-- mOTUs-extender/swap_columns.py | 6 ++++++ 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 mOTUs-extender/swap_columns.py diff --git a/mOTUs-extender/extend_mOTUs_addGenome.sh b/mOTUs-extender/extend_mOTUs_addGenome.sh index c2ec879..12bbaf0 100755 --- a/mOTUs-extender/extend_mOTUs_addGenome.sh +++ b/mOTUs-extender/extend_mOTUs_addGenome.sh @@ -1,4 +1,4 @@ -set -euxo pipefail +#set -euxo pipefail #add genomes to mOTU DB sequence_file=$1 diff --git a/mOTUs-extender/extend_mOTUs_addMarkerGenes.sh b/mOTUs-extender/extend_mOTUs_addMarkerGenes.sh index 5f509a2..8490c0a 100755 --- a/mOTUs-extender/extend_mOTUs_addMarkerGenes.sh +++ b/mOTUs-extender/extend_mOTUs_addMarkerGenes.sh @@ -1,4 +1,4 @@ -set -euxo pipefail +#set -euxo pipefail #add genomes to mOTU DB sequence_file=$1 diff --git a/mOTUs-extender/extend_mOTUs_generateDB.sh b/mOTUs-extender/extend_mOTUs_generateDB.sh index c626b49..0e69a8d 100644 --- a/mOTUs-extender/extend_mOTUs_generateDB.sh +++ b/mOTUs-extender/extend_mOTUs_generateDB.sh @@ -1,4 +1,4 @@ -set -euxo pipefail +#set -euxo pipefail #filter genomes from mOTU DB @@ -155,7 +155,8 @@ do paste $new_database_folder/$newDBName/vsearch/$newDBName.mOTU-LG.map.tsv.temp1 $new_database_folder/$newDBName/vsearch/$newDBName.mOTU-LG.map.tsv.temp1 | sed "s/^/${line}./" done < $mOTU_MG_file > $new_database_folder/$newDBName/vsearch/$newDBName.mOTU-LG.map.tsv -awk -F $'\t' ' { t = $1; $1 = $2; $2 = t; print; } ' OFS=$'\t' $new_database_folder/$newDBName/vsearch/$newDBName.mOTU-LG.map.tsv > $new_database_folder/$newDBName/vsearch/$newDBName.mOTU-LG.map.tsv.temp +python $scriptDir/swap_columns.py $new_database_folder/$newDBName/vsearch/$newDBName.mOTU-LG.map.tsv > $new_database_folder/$newDBName/vsearch/$newDBName.mOTU-LG.map.tsv.temp +#awk -F $'\t' ' { t = $1; $1 = $2; $2 = t; print; } ' OFS=$'\t' $new_database_folder/$newDBName/vsearch/$newDBName.mOTU-LG.map.tsv > $new_database_folder/$newDBName/vsearch/$newDBName.mOTU-LG.map.tsv.temp python $scriptDir/reformatMapping2Clustering.py $new_database_folder/$newDBName/vsearch/$newDBName.mOTU-LG.map.tsv.temp $new_database_folder/$newDBName/vsearch/$newDBName.mOTU-LG.map.line.tsv diff --git a/mOTUs-extender/swap_columns.py b/mOTUs-extender/swap_columns.py new file mode 100644 index 0000000..c84ac9a --- /dev/null +++ b/mOTUs-extender/swap_columns.py @@ -0,0 +1,6 @@ +import sys + +with open(sys.argv[1]) as handle: + for line in handle: + splits = line.strip().split() + print(f'{splits[1]}\t{splits[0]}')