diff --git a/extras/config.example b/extras/config.example index 4bbecc30a65e772e202e1d4aa04c499a27bc4580..df98ac593175f27d2f54ab1d991a966b768f583c 100644 --- a/extras/config.example +++ b/extras/config.example @@ -109,7 +109,8 @@ PIDfile = "/var/run/mutalyzer/mutalyzer-batchd.pid" batchInputMaxSize = 5 # The output header for NameChecking -nameCheckOutHeader = "Input", "Errors | Messages", "AccNo", "Genesymbol", "Variant", "Reference Sequence Start Descr.", "Coding DNA Descr.", "Protein Descr.", "GeneSymbol Coding DNA Descr.", "GeneSymbol Protein Descr.", "Genomic Reference", "Coding Reference", "Protein Reference", "Affected Transcripts", "Affected Proteins" +# Todo: migration for restriction sites +nameCheckOutHeader = "Input", "Errors | Messages", "AccNo", "Genesymbol", "Variant", "Reference Sequence Start Descr.", "Coding DNA Descr.", "Protein Descr.", "GeneSymbol Coding DNA Descr.", "GeneSymbol Protein Descr.", "Genomic Reference", "Coding Reference", "Protein Reference", "Affected Transcripts", "Affected Proteins", "Restriction Sites Created", "Restriction Sites Deleted" # The output header for SyntaxChecking syntaxCheckOutHeader = "Input", "Status" diff --git a/extras/migrations/005-config-batch-restriction-sites.migration b/extras/migrations/005-config-batch-restriction-sites.migration new file mode 100755 index 0000000000000000000000000000000000000000..36a040fc970113c0a3142aae50a609cfcc6543be --- /dev/null +++ b/extras/migrations/005-config-batch-restriction-sites.migration @@ -0,0 +1,25 @@ +#!/bin/bash + +# Add batch checker restriction sites headers to the configuration file. +# +# Usage: +# ./005-config-batch-restriction-sites.migration [migrate] + +COLOR_INFO='\033[32m' +COLOR_WARNING='\033[33m' +COLOR_ERROR='\033[31m' +COLOR_END='\033[0m' + +if [ -e /etc/mutalyzer/config ] && $(grep -q '^nameCheckOutHeader = "Input", "Errors | Messages", "AccNo", "Genesymbol", "Variant", "Reference Sequence Start Descr.", "Coding DNA Descr.", "Protein Descr.", "GeneSymbol Coding DNA Descr.", "GeneSymbol Protein Descr.", "Genomic Reference", "Coding Reference", "Protein Reference", "Affected Transcripts", "Affected Proteins"$' /etc/mutalyzer/config); then + echo -e "${COLOR_WARNING}This migration is needed.${COLOR_END}" + if [ "$1" = 'migrate' ]; then + echo 'Performing migration.' + echo -e "${COLOR_INFO}Copying /etc/mutalyzer/config to /etc/mutalyzer/config.backup${COLOR_END}" + cp /etc/mutalyzer/config /etc/mutalyzer/config.backup + sed -i 's/nameCheckOutHeader = "Input", "Errors | Messages", "AccNo", "Genesymbol", "Variant", "Reference Sequence Start Descr.", "Coding DNA Descr.", "Protein Descr.", "GeneSymbol Coding DNA Descr.", "GeneSymbol Protein Descr.", "Genomic Reference", "Coding Reference", "Protein Reference", "Affected Transcripts", "Affected Proteins"/nameCheckOutHeader = "Input", "Errors | Messages", "AccNo", "Genesymbol", "Variant", "Reference Sequence Start Descr.", "Coding DNA Descr.", "Protein Descr.", "GeneSymbol Coding DNA Descr.", "GeneSymbol Protein Descr.", "Genomic Reference", "Coding Reference", "Protein Reference", "Affected Transcripts", "Affected Proteins", "Restriction Sites Created", "Restriction Sites Deleted"/' /etc/mutalyzer/config + echo -e "${COLOR_INFO}Added batch checker restriction sites headers to /etc/mutalyzer/config${COLOR_END}" + echo 'Performed migration.' + fi +else + echo -e "${COLOR_INFO}This migration is not needed.${COLOR_END}" +fi diff --git a/mutalyzer/util.py b/mutalyzer/util.py index 8738bbca0ee1650fb0ea9517a45be36c117d5b3a..e340ebe5a8d3f113d6c07ac5b04d2a4c8b34983f 100644 --- a/mutalyzer/util.py +++ b/mutalyzer/util.py @@ -768,7 +768,7 @@ def slow(f): and os.environ['MUTALYZER_QUICK_TEST'] == '1': return else: - f(*args, **kwargs) + return f(*args, **kwargs) return slow_f #slow diff --git a/mutalyzer/variantchecker.py b/mutalyzer/variantchecker.py index 7ece5cbe3c72d025b7506077baba375742296937..ab4f62a03ffdc1f50d667d1b14a94b06faf193fa 100644 --- a/mutalyzer/variantchecker.py +++ b/mutalyzer/variantchecker.py @@ -256,6 +256,17 @@ def _add_batch_output(O): else: outputline += "\t"*2 + # Add effects on restriction sites as two columns (created and deleted). + # The value for each column is a semicolon-separated list of + # comma-separated lists: for each raw variant, a list of restriction + # sites. + sites_created = [] + sites_deleted = [] + for variant in O.getOutput("restrictionSites"): + sites_created.append(','.join(variant[0])) + sites_deleted.append(','.join(variant[1])) + outputline += "%s\t%s\t" % (';'.join(sites_created), ';'.join(sites_deleted)) + #Link naar additional info: #outputline+="http://localhost/mutalyzer2/redirect?mutationName=%s" %\ # "todovariant" diff --git a/tests/test_website.py b/tests/test_website.py index 97a67cd5d36950d722d41e0fd0e28039df257316..438b9e71a9096638422df1a72d91c3c59167a99b 100644 --- a/tests/test_website.py +++ b/tests/test_website.py @@ -461,6 +461,26 @@ class TestWSGI(): size=len(variants)-1, header='Input\tStatus') + @slow + def test_batch_namechecker_restriction_sites(self): + """ + Submit the batch name checker form and see if restriction site effects + are added. + + Note that we use the @slow decorator here even though it is already + applied to self._batch. The reason is that we use the result from + self._batch, which does not exist if @slow checks are disabled. + """ + variants=['AB026906.1:c.274G>T', + 'AB026906.1:c.[274G>T;143A>G;15G>T]'] + results = self._batch('NameChecker', + file='\n'.join(variants), + size=len(variants), + header='Input\tErrors | Messages') + assert 'Restriction Sites Created\tRestriction Sites Deleted' in results[0] + assert 'CviQI,RsaI\tBccI' in results[1] + assert 'CviQI,RsaI;HinP1I,HhaI;SfcI\tBccI;;BpmI,MnlI,BsaXI (2),Hpy188III' in results[2] + @slow def test_batch_syntaxchecker_toobig(self): """