Next changeset 1:446eee605ac1 (2019-03-05) |
Commit message:
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit 690532f4a8e36a334b2d4e15b832532fc1bb8d39 |
added:
README.rst expression_delete_biomaterials.xml macros.xml test-data/blast.xml test-data/blast2go.gaf test-data/citrus_genome.fasta test-data/interpro.xml test-data/sample.gff3 tripal.py |
b |
diff -r 000000000000 -r 939ae64500f9 README.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.rst Mon Feb 25 06:21:08 2019 -0500 |
b |
@@ -0,0 +1,45 @@ +Galaxy-tripal +============= + +Galaxy tools to interface with Tripal using python-tripal + +Dependencies +------------ + +You will need to install some python modules in the Galaxy virtualenv for these +tools to be fully functional: + +.. code:: bash + + . /path/to/galaxy/.venv/bin/activate + pip install future tripal + deactivate + +Environment +----------- + +The following environment variables must be set: + ++--------------------------------+-----------------------------------------------------------+ +| ENV | Use | ++================================+===========================================================+ +| ``$GALAXY_TRIPAL_URL`` | The URL at which Tripal is accessible, internal to Galaxy | +| | and where the tools run. Must be absolute, with FQDN and | +| | protocol. | ++--------------------------------+-----------------------------------------------------------+ +| ``$GALAXY_TRIPAL_USER`` | The admin user which Galaxy should use to talk to Tripal. | +| | | ++--------------------------------+-----------------------------------------------------------+ +| ``$GALAXY_TRIPAL_PASSWORD`` | The password for the admin user. | +| | | +| | | ++--------------------------------+-----------------------------------------------------------+ +| ``$GALAXY_TRIPAL_SHARED_DIR`` | Directory shared between Galaxy and Tripal, used to | +| | exchange data files. | ++--------------------------------+-----------------------------------------------------------+ + + +License +------- + +All python scripts and wrappers are licensed under MIT license. |
b |
diff -r 000000000000 -r 939ae64500f9 expression_delete_biomaterials.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/expression_delete_biomaterials.xml Mon Feb 25 06:21:08 2019 -0500 |
[ |
@@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<tool id="expression_delete_biomaterials" name="Delete biomaterials" version="@WRAPPER_VERSION@.0"> + <description>from Tripal</description> + <macros> + <import>macros.xml</import> + </macros> + <expand macro="requirements"/> + <code file="tripal.py"/> + <command detect_errors="aggressive"><![CDATA[ +@AUTH@ + +tripaille expression delete_biomaterials + +#if $names: + --names '$names' +#end if +#if $organism_id: + --organism_id '$organism_id' +#end if +#if $analysis_id: + --analysis_id '$analysis_id' +#end if + +&& + +echo "Data loaded" > $results +]]></command> + <inputs> + <!-- arguments --> + + <!-- options --> + <param name="names" label="Names" argument="names" type="text" help="JSON list of biomaterial names to delete." optional="true"> + <expand macro="sanitized"/> + </param> + + <param argument="--organism_id" type="select" dynamic_options="list_organisms()" label="Organism" optional="true" /> + <param argument="--analysis_id" type="select" dynamic_options="list_analyses()" label="Analysis" optional="true" /> + + </inputs> + <outputs> + <data format="txt" name="results"/> + </outputs> + <help> +Delete some biomaterials + +@HELP@ + </help> +</tool> |
b |
diff -r 000000000000 -r 939ae64500f9 macros.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/macros.xml Mon Feb 25 06:21:08 2019 -0500 |
[ |
b'@@ -0,0 +1,224 @@\n+<?xml version="1.0"?>\n+<macros>\n+ <xml name="requirements">\n+ <requirements>\n+ <requirement type="package" version="3.2">python-tripal</requirement>\n+ <yield/>\n+ </requirements>\n+ </xml>\n+\n+ <xml name="stdio">\n+ <stdio>\n+ <regex level="fatal" match="Exception:" source="stderr" />\n+ <regex level="fatal" match="error" source="stderr" />\n+ <exit_code range="1:" />\n+ </stdio>\n+ </xml>\n+\n+ <token name="@WRAPPER_VERSION@">3.2</token>\n+\n+ <xml name="citation">\n+ <citations>\n+ <citation type="doi">10.1093/database/bat075</citation>\n+ </citations>\n+ </xml>\n+\n+ <token name="@HELP_OVERVIEW@"><![CDATA[\n+ **Python-tripal Overview**\n+\n+ Python-tripal provides several tools allowing to load data into a remote Chado-based Tripal database.\n+ The tripal_rest_api Tripal module must be installed on the remote server to use these tools.\n+ ]]></token>\n+\n+ <token name="@HELP@"><![CDATA[\n+ **Useful Links**\n+\n+ `Tripal project website <http://tripal.info/>`_\n+\n+ `Tripal REST API module <http://github.com/abretaud/tripal_rest_api>`_: a Tripal module required to use these galaxy tools\n+ ]]></token>\n+\n+ <token name="@DATA_DIR@">\\$GALAXY_TRIPAL_SHARED_DIR</token>\n+\n+ <token name="@AUTH@"><![CDATA[\n+ echo "__default: local" > \'.auth.yml\' &&\n+ echo "local:" >> \'.auth.yml\' &&\n+ echo " tripal_url: \\"\\$GALAXY_TRIPAL_URL\\"" >> \'.auth.yml\' &&\n+ echo " username: \\"\\$GALAXY_TRIPAL_USER\\"" >> \'.auth.yml\' &&\n+ echo " password: \\"\\$GALAXY_TRIPAL_PASSWORD\\"" >> \'.auth.yml\' &&\n+\n+ TRIPAILLE_GLOBAL_CONFIG_PATH=\'.auth.yml\'\n+ ]]></token>\n+\n+ <xml name="wait_for">\n+ <param name="wait_for"\n+ type="data"\n+ format="data"\n+ optional="true"\n+ label="Run this only after the following dataset is ready"\n+ help="Use this if you want to delay the job execution until some data is already loaded. The selected dataset will not be used for anything else."/>\n+ </xml>\n+\n+ <xml name="test_result">\n+ <assert_stderr>\n+ <has_text text="MissingSchema" />\n+ </assert_stderr>\n+ </xml>\n+\n+ <xml name="analysis">\n+ <section name="analysis" title="Analysis" expanded="True">\n+ <param name="name"\n+ type="text"\n+ label="The analysis name [mandatory]">\n+ <expand macro="sanitized"/>\n+ </param>\n+\n+ <param name="program"\n+ type="text"\n+ label="Program name [mandatory]"\n+ help="Name of the program that was used to perform this analysis">\n+ <expand macro="sanitized"/>\n+ </param>\n+ <param name="program_version"\n+ type="text"\n+ label="Program version [mandatory]"\n+ help="Version of the program that was used to perform this analysis"/>\n+ <param name="source"\n+ type="text"\n+ label="Source name [mandatory]"\n+ help="Where this analysis comes from">\n+ <expand macro="sanitized"/>\n+ </param>\n+\n+ <param name="source_version"\n+ argument="--sourceversion"\n+ type="text"\n+ optional="True"\n+ label="Source version" />\n+ <param name="source_uri"\n+ argument="--sourceuri"\n+ type="text"\n+ optional="True"\n+ label="Source URI"\n+ help="URI where source data was retrieved" />\n+ <param name="algorithm"\n+ argument="--algorithm"\n+ type="text"\n+ label="Algorithm"\n+ optional="True"\n'..b'scription">\n+ <expand macro="sanitized"/>\n+ </param>\n+ <param name="date"\n+ argument="--date_executed"\n+ type="text"\n+ optional="True"\n+ label="Execution date"\n+ help="Format: yyyy-mm-dd Default: Today">\n+ <validator type="regex" message="Date in YYYY-MM-DD format">^[0-9]{4}-[0-9]{2}-[0-9]{2}$</validator>\n+ </param>\n+ </section>\n+ </xml>\n+\n+ <xml name="feature_rel">\n+ <param name="rel_subject_re"\n+ argument="--rel-subject-re"\n+ type="text"\n+ label="Regular expression to extract the unique name of the parent feature"\n+ help="this regex will be applied on the fasta definition line to generate the unique name of the parent feature">\n+ <expand macro="sanitized"/>\n+ </param>\n+\n+ <param name="rel_subject_type"\n+ argument="--rel-subject-type"\n+ type="text"\n+ label="Sequence type of the parent"\n+ help="this should be a Sequence Ontology term" />\n+ </xml>\n+\n+ <xml name="match_type">\n+ <param name="match_type"\n+ argument="--match-type"\n+ type="select"\n+ label="Match type for already loaded features">\n+ <option value="uniquename" selected="true">Unique name</option>\n+ <option value="name">Name</option>\n+ </param>\n+ </xml>\n+\n+ <xml name="matching">\n+ <section name="matching" title="Feature matching" expanded="True">\n+ <param name="query_type"\n+ type="text"\n+ label="The feature type of the blast query"\n+ help="It must be a valid Sequence Ontology term. e.g. \'contig\', \'gene\', \'mRNA\', \'polypeptide\'" />\n+\n+ <param name="query_uniquename"\n+ type="boolean"\n+ checked="false"\n+ truevalue="--query_uniquename"\n+ falsevalue=""\n+ label="Find blast query features using their Unique name"\n+ help="Feature name will be used otherwise" />\n+\n+ <param name="query_re"\n+ type="text"\n+ optional="true"\n+ label="Regular expression to extract the feature name from the blast query name"\n+ help="leave empty if the first word in query name is sufficient">\n+ <expand macro="sanitized"/>\n+ </param>\n+ </section>\n+ </xml>\n+\n+ <xml name="sanitized">\n+ <sanitizer>\n+ <valid initial="string.printable">\n+ <remove value="'"/>\n+ </valid>\n+ <mapping initial="none">\n+ <add source="'" target="'"'"'"/>\n+ <add source="(" target="\\("/>\n+ <add source=")" target="\\)"/>\n+ </mapping>\n+ </sanitizer>\n+ </xml>\n+\n+ <token name="@MATCHING@"><![CDATA[\n+ #if str($matching.query_re):\n+ --query_re \'${matching.query_re}\'\n+ #end if\n+\n+ $matching.query_uniquename\n+\n+ --query_type \'$matching.query_type\'\n+ ]]></token>\n+\n+ <token name="@ANALYSIS@"><![CDATA[\n+ #if $analysis.algorithm:\n+ --algorithm \'$analysis.algorithm\'\n+ #end if\n+ #if $analysis.source_version:\n+ --sourceversion \'$analysis.source_version\'\n+ #end if\n+ #if $analysis.source_uri:\n+ --sourceuri \'$analysis.source_uri\'\n+ #end if\n+ #if $analysis.description:\n+ --description \'$analysis.description\'\n+ #end if\n+ #if $analysis.date:\n+ --date_executed \'$analysis.date\'\n+ #end if\n+\n+ \'$analysis.name\'\n+ \'$analysis.program\'\n+ \'$analysis.program_version\'\n+ \'$analysis.source\'\n+ ]]></token>\n+</macros>\n' |
b |
diff -r 000000000000 -r 939ae64500f9 test-data/blast.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/blast.xml Mon Feb 25 06:21:08 2019 -0500 |
[ |
@@ -0,0 +1,68 @@ +<?xml version="1.0"?> +<!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" "http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd"> +<BlastOutput> + <BlastOutput_program>blastx</BlastOutput_program> + <BlastOutput_version>blastx 2.2.25 [Feb-01-2011]</BlastOutput_version> + <BlastOutput_reference>~Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, ~Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), ~"Gapped BLAST and PSI-BLAST: a new generation of protein database search~programs", Nucleic Acids Res. 25:3389-3402.</BlastOutput_reference> + <BlastOutput_db>/scratch/mainlab/data/lib/nr</BlastOutput_db> + <BlastOutput_query-ID>lcl|1_0</BlastOutput_query-ID> + <BlastOutput_query-def>orange1.1g015632m PAC:18136217 (mRNA) Citrus sinensis</BlastOutput_query-def> + <BlastOutput_query-len>2075</BlastOutput_query-len> + <BlastOutput_param> + <Parameters> + <Parameters_matrix>BLOSUM62</Parameters_matrix> + <Parameters_expect>1e-06</Parameters_expect> + <Parameters_gap-open>11</Parameters_gap-open> + <Parameters_gap-extend>1</Parameters_gap-extend> + <Parameters_filter>F</Parameters_filter> + </Parameters> + </BlastOutput_param> + <BlastOutput_iterations> + <Iteration> + <Iteration_iter-num>1</Iteration_iter-num> + <Iteration_query-ID>lcl|1_0</Iteration_query-ID> + <Iteration_query-def>orange1.1g015632m PAC:18136217 (mRNA) Citrus sinensis</Iteration_query-def> + <Iteration_query-len>2075</Iteration_query-len> + <Iteration_hits> + <Hit> + <Hit_num>1</Hit_num> + <Hit_id>gi|224068663|ref|XP_002302794.1|</Hit_id> + <Hit_def>predicted protein [Populus trichocarpa] >gi|222844520|gb|EEE82067.1| predicted protein [Populus trichocarpa]</Hit_def> + <Hit_accession>XP_002302794</Hit_accession> + <Hit_len>409</Hit_len> + <Hit_hsps> + <Hsp> + <Hsp_num>1</Hsp_num> + <Hsp_bit-score>792.727</Hsp_bit-score> + <Hsp_score>2046</Hsp_score> + <Hsp_evalue>0</Hsp_evalue> + <Hsp_query-from>559</Hsp_query-from> + <Hsp_query-to>1767</Hsp_query-to> + <Hsp_hit-from>1</Hsp_hit-from> + <Hsp_hit-to>409</Hsp_hit-to> + <Hsp_query-frame>1</Hsp_query-frame> + <Hsp_identity>387</Hsp_identity> + <Hsp_positive>394</Hsp_positive> + <Hsp_gaps>6</Hsp_gaps> + <Hsp_align-len>409</Hsp_align-len> + <Hsp_qseq>MASVSVVPASG------NTVGVDRLPEEMNDMKIRDDKEMEATVVDGNGTEAGHIIVTTIGGKNGQPKQTISYMAERVVGHGSFGVVFQAKCLETGEAVAIKKVLQDKRYKNRELQTMRLLDHPNVVSLKHCFFSTTEKDELYLNLVLEYVPETVHRVIKHHYKMSQRMPLIYVKLYFYQICRALAYIHNTIGVCHRDIKPQNLLVNPHTHQLKLCDFGSAKVLVKGEPNISYICSRYYRAPELIFGATEYTAAIDIWSAGCVLAELLLGQPLFPGESGVDQLVEIIKVLGTPTREEIKCMNPNYTEFKFPQIKAHPWHKIFQKRMPPEAVDLVSRLLQYSPNLRSTALEALIHPFFDELRDPNTRLPNGRFLPPLFNFKPHELKGVPVDMLVKLIPEHARKQCAFLGL</Hsp_qseq> + <Hsp_hseq>MASVSVVPASGLRDTLGNTTGVDKLPEEMNDMKISDDKEMEAAVVDGNGTETGHIIVTTIGGKNGQPKQTISYMAERVVGHGSFGLVFQAKCLETGETVAIKKVLQDKRYKNRELQTMRLLDHPNVVSLKHCFFSTTEKDELYLNLVLEYVPETIHRVIKHYYKMSQRMPLIYVKLYFYQICRALAYIHNSIGVCHRDIKPQNLLVNPHTHQVKLCDFGSAKVLVKGEPNISYICSRYYRAPELIFGATEYTTAIDIWSAGCVLAELLLGQPLFPGESGVDQLVEIIKVLGTPTREEIKCMNPNYTEFKFPQIKAHPWHKIFHKRMPPEAVDLVSRLLQYSPNLRSTALEALIHPFFDELRDPNARLPNGRILPPLFNFKPHELKGVPVEMLVKLIPEHARKQCAFLGL</Hsp_hseq> + <Hsp_midline>MASVSVVPASG NT GVD+LPEEMNDMKI DDKEMEA VVDGNGTE GHIIVTTIGGKNGQPKQTISYMAERVVGHGSFG+VFQAKCLETGE VAIKKVLQDKRYKNRELQTMRLLDHPNVVSLKHCFFSTTEKDELYLNLVLEYVPET+HRVIKH+YKMSQRMPLIYVKLYFYQICRALAYIHN+IGVCHRDIKPQNLLVNPHTHQ+KLCDFGSAKVLVKGEPNISYICSRYYRAPELIFGATEYT AIDIWSAGCVLAELLLGQPLFPGESGVDQLVEIIKVLGTPTREEIKCMNPNYTEFKFPQIKAHPWHKIF KRMPPEAVDLVSRLLQYSPNLRSTALEALIHPFFDELRDPN RLPNGR LPPLFNFKPHELKGVPV+MLVKLIPEHARKQCAFLGL</Hsp_midline> + </Hsp> + </Hit_hsps> + </Hit> + </Iteration_hits> + <Iteration_stat> + <Statistics> + <Statistics_db-num>18996442</Statistics_db-num> + <Statistics_db-len>6510958228</Statistics_db-len> + <Statistics_hsp-len>0</Statistics_hsp-len> + <Statistics_eff-space>0</Statistics_eff-space> + <Statistics_kappa>0.041</Statistics_kappa> + <Statistics_lambda>0.267</Statistics_lambda> + <Statistics_entropy>0.14</Statistics_entropy> + </Statistics> + </Iteration_stat> + </Iteration> + </BlastOutput_iterations> +</BlastOutput> |
b |
diff -r 000000000000 -r 939ae64500f9 test-data/blast2go.gaf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/blast2go.gaf Mon Feb 25 06:21:08 2019 -0500 |
b |
@@ -0,0 +1,6 @@ +!gaf-version: 2.1 + gi|328696447|ref|XP_003240026.1| GO:0016021 + gi|328696447|ref|XP_003240026.1| GO:0006511 + gi|328696447|ref|XP_003240026.1| GO:0030145 + gi|328696447|ref|XP_003240026.1| GO:0004803 + gi|328696447|ref|XP_003240026.1| GO:0004177 |
b |
diff -r 000000000000 -r 939ae64500f9 test-data/citrus_genome.fasta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/citrus_genome.fasta Mon Feb 25 06:21:08 2019 -0500 |
b |
@@ -0,0 +1,10 @@ +>scaffold00001 length=5927163 +TTTTGTATTCTATGTCCTCTGATCTTTATACTTCTTCATTTTGTCTTTGCAAGAACCGGA +ATTATGGGTACATCACAAATTCTCTAGGTGTGACTTGTGTTGTGGGGCCTTTTTTTtACA +TTTCCATATTGCAAGTATTTTTTTGCTACCATTGGTATATTTGTCTGTTAAAATCAATCT +GCTTTCACTTATGTTCGTGCGTTCTTGTTCCCTCGCCTTGCAATTGCATATCTCAAATTA +TCTTTCTTACTTTGATTTAGATGGCCAAGGTTTTAAGCTAACTTTTTACAATGCCAATTT +TTAAATGGTTTTCTAATGCTGTTCAAAGTTGCAGCCTTTACTTCGTATATTTGTCAGGTT +CTGACGGGTGCGGTCGGCGGCGGGGGCTATAGCATGCGGTCTCGAGAGCCGCAAAGAAAA +ATGGGTGGTTTTCCCGGTTTCGGCCATAACTCGTGATCGGGGCCTCCGATTCTGGTTCCG +TTTCGTCCCACGGGACCAGCCGGGCGGGGGCATCGGATTGCAAAAGTCTTTAAATTTGAA |
b |
diff -r 000000000000 -r 939ae64500f9 test-data/interpro.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/interpro.xml Mon Feb 25 06:21:08 2019 -0500 |
b |
@@ -0,0 +1,12 @@ +<interpro_matches> + + <protein id="orange1.1g022799m_6_ORF4" length="79" crc64="D3F0B609CB0B9D28" > + <interpro id="noIPR" name="unintegrated" type="unintegrated"> + <match id="seg" name="seg" dbname="SEG"> + <location start="11" end="17" score="NA" status="?" evidence="Seg" /> + <location start="54" end="78" score="NA" status="?" evidence="Seg" /> + </match> + </interpro> + </protein> + +</interpro_matches> |
b |
diff -r 000000000000 -r 939ae64500f9 test-data/sample.gff3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/sample.gff3 Mon Feb 25 06:21:08 2019 -0500 |
b |
@@ -0,0 +1,21 @@ +##gff-version 3 +##sequence-region scaffold00001 4058460 4062210 +scaffold00001 phytozome6 supercontig 1 5927163 . . . Name=scaffold00001;ID=scaffold00001 +scaffold00001 phytozome6 gene 4058460 4062210 . + . ID=orange1.1g015632m.g;Name=orange1.1g015632m.g +scaffold00001 phytozome6 mRNA 4058460 4062210 . + . ID=PAC:18136217;Name=orange1.1g015632m;PACid=18136217;Parent=orange1.1g015632m.g +scaffold00001 phytozome6 five_prime_UTR 4058460 4058898 . + . Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 five_prime_UTR 4059019 4059074 . + . Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 five_prime_UTR 4059172 4059234 . + . Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4059235 4059330 . + 0 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4059422 4059514 . + 0 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4059600 4059659 . + 0 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4059790 4060062 . + 0 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4060285 4060359 . + 0 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4060480 4060536 . + 0 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4060625 4060765 . + 0 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4060857 4060907 . + 0 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4061250 4061345 . + 0 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4061417 4061500 . + 0 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4061617 4061719 . + 0 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 CDS 4061823 4061905 . + 2 Parent=PAC:18136217;PACid=18136217 +scaffold00001 phytozome6 three_prime_UTR 4061906 4062210 . + . Parent=PAC:18136217;PACid=18136217 |
b |
diff -r 000000000000 -r 939ae64500f9 tripal.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tripal.py Mon Feb 25 06:21:08 2019 -0500 |
[ |
b'@@ -0,0 +1,502 @@\n+import collections\n+import os\n+import time\n+from abc import abstractmethod\n+\n+import tripal\n+\n+\n+#############################################\n+# BEGIN IMPORT OF CACHING LIBRARY #\n+#############################################\n+# This code is licensed under the MIT #\n+# License and is a copy of code publicly #\n+# available in rev. #\n+# e27332bc82f4e327aedaec17c9b656ae719322ed #\n+# of https://github.com/tkem/cachetools/ #\n+#############################################\n+class DefaultMapping(collections.MutableMapping):\n+\n+ __slots__ = ()\n+\n+ @abstractmethod\n+ def __contains__(self, key): # pragma: nocover\n+ return False\n+\n+ @abstractmethod\n+ def __getitem__(self, key): # pragma: nocover\n+ if hasattr(self.__class__, \'__missing__\'):\n+ return self.__class__.__missing__(self, key)\n+ else:\n+ raise KeyError(key)\n+\n+ def get(self, key, default=None):\n+ if key in self:\n+ return self[key]\n+ else:\n+ return default\n+\n+ __marker = object()\n+\n+ def pop(self, key, default=__marker):\n+ if key in self:\n+ value = self[key]\n+ del self[key]\n+ elif default is self.__marker:\n+ raise KeyError(key)\n+ else:\n+ value = default\n+ return value\n+\n+ def setdefault(self, key, default=None):\n+ if key in self:\n+ value = self[key]\n+ else:\n+ self[key] = value = default\n+ return value\n+\n+\n+DefaultMapping.register(dict)\n+\n+\n+class _DefaultSize(object):\n+ def __getitem__(self, _):\n+ return 1\n+\n+ def __setitem__(self, _, value):\n+ assert value == 1\n+\n+ def pop(self, _):\n+ return 1\n+\n+\n+class Cache(DefaultMapping):\n+ """Mutable mapping to serve as a simple cache or cache base class."""\n+\n+ __size = _DefaultSize()\n+\n+ def __init__(self, maxsize, missing=None, getsizeof=None):\n+ if missing:\n+ self.__missing = missing\n+ if getsizeof:\n+ self.__getsizeof = getsizeof\n+ self.__size = dict()\n+ self.__data = dict()\n+ self.__currsize = 0\n+ self.__maxsize = maxsize\n+\n+ def __repr__(self):\n+ return \'%s(%r, maxsize=%r, currsize=%r)\' % (\n+ self.__class__.__name__,\n+ list(self.__data.items()),\n+ self.__maxsize,\n+ self.__currsize,\n+ )\n+\n+ def __getitem__(self, key):\n+ try:\n+ return self.__data[key]\n+ except KeyError:\n+ return self.__missing__(key)\n+\n+ def __setitem__(self, key, value):\n+ maxsize = self.__maxsize\n+ size = self.getsizeof(value)\n+ if size > maxsize:\n+ raise ValueError(\'value too large\')\n+ if key not in self.__data or self.__size[key] < size:\n+ while self.__currsize + size > maxsize:\n+ self.popitem()\n+ if key in self.__data:\n+ diffsize = size - self.__size[key]\n+ else:\n+ diffsize = size\n+ self.__data[key] = value\n+ self.__size[key] = size\n+ self.__currsize += diffsize\n+\n+ def __delitem__(self, key):\n+ size = self.__size.pop(key)\n+ del self.__data[key]\n+ self.__currsize -= size\n+\n+ def __contains__(self, key):\n+ return key in self.__data\n+\n+ def __missing__(self, key):\n+ value = self.__missing(key)\n+ try:\n+ self.__setitem__(key, value)\n+ except ValueError:\n+ pass # value too large\n+ return value\n+\n+ def __iter__(self):\n+ return iter(self.__data)\n+\n+ def __len__(self):\n+ return len(self.__data)\n+\n+ @staticmethod\n+ def __getsizeof(value):\n+ return 1\n+\n+ @staticmethod\n+ def __missing(key):\n+ raise KeyError(key)\n+\n+ @property\n+ def maxsize(self):\n+ """The maximum size of the cache."""\n+ return self.__maxsize\n+\n+ '..b'XY_TRIPAL_USER\'],\n+ os.environ[\'GALAXY_TRIPAL_PASSWORD\']\n+ )\n+\n+\n+def list_organisms(*args, **kwargs):\n+\n+ ti = _get_instance()\n+\n+ # Key for cached data\n+ cacheKey = \'orgs\'\n+ # We don\'t want to trust "if key in cache" because between asking and fetch\n+ # it might through key error.\n+ if cacheKey not in cache:\n+ # However if it ISN\'T there, we know we\'re safe to fetch + put in\n+ # there.\n+ data = _list_organisms(ti, *args, **kwargs)\n+ cache[cacheKey] = data\n+ return data\n+ try:\n+ # The cache key may or may not be in the cache at this point, it\n+ # /likely/ is. However we take no chances that it wasn\'t evicted between\n+ # when we checked above and now, so we reference the object from the\n+ # cache in preparation to return.\n+ data = cache[cacheKey]\n+ return data\n+ except KeyError:\n+ # If access fails due to eviction, we will fail over and can ensure that\n+ # data is inserted.\n+ data = _list_organisms(ti, *args, **kwargs)\n+ cache[cacheKey] = data\n+ return data\n+\n+\n+def _list_organisms(ti, *args, **kwargs):\n+ # Fetch the orgs.\n+ orgs_data = []\n+ for org in ti.organism.get_organisms():\n+ clean_name = \'%s %s\' % (org[\'genus\'], org[\'species\'])\n+ if org[\'infraspecific_name\']:\n+ clean_name += \' (%s)\' % (org[\'infraspecific_name\'])\n+ orgs_data.append((clean_name, org[\'organism_id\'], False))\n+ return orgs_data\n+\n+\n+def list_analyses(*args, **kwargs):\n+\n+ ti = _get_instance()\n+\n+ # Key for cached data\n+ cacheKey = \'analyses\'\n+ # We don\'t want to trust "if key in cache" because between asking and fetch\n+ # it might through key error.\n+ if cacheKey not in cache:\n+ # However if it ISN\'T there, we know we\'re safe to fetch + put in\n+ # there.<?xml version="1.0"?>\n+\n+ data = _list_analyses(ti, *args, **kwargs)\n+ cache[cacheKey] = data\n+ return data\n+ try:\n+ # The cache key may or may not be in the cache at this point, it\n+ # /likely/ is. However we take no chances that it wasn\'t evicted between\n+ # when we checked above and now, so we reference the object from the\n+ # cache in preparation to return.\n+ data = cache[cacheKey]\n+ return data\n+ except KeyError:\n+ # If access fails due to eviction, we will fail over and can ensure that\n+ # data is inserted.\n+ data = _list_analyses(ti, *args, **kwargs)\n+ cache[cacheKey] = data\n+ return data\n+\n+\n+def _list_analyses(ti, *args, **kwargs):\n+ ans_data = []\n+ for an in ti.analysis.get_analyses():\n+ ans_data.append((an[\'name\'], an[\'analysis_id\'], False))\n+ return ans_data\n+\n+\n+def list_blastdbs(*args, **kwargs):\n+\n+ ti = _get_instance()\n+\n+ # Key for cached data\n+ cacheKey = \'blastdbs\'\n+ # We don\'t want to trust "if key in cache" because between asking and fetch\n+ # it might through key error.\n+ if cacheKey not in cache:\n+ # However if it ISN\'T there, we know we\'re safe to fetch + put in\n+ # there.\n+ data = _list_blastdbs(ti, *args, **kwargs)\n+ cache[cacheKey] = data\n+ return data\n+ try:\n+ # The cache key may or may not be in the cache at this point, it\n+ # /likely/ is. However we take no chances that it wasn\'t evicted between\n+ # when we checked above and now, so we reference the object from the\n+ # cache in preparation to return.\n+ data = cache[cacheKey]\n+ return data\n+ except KeyError:\n+ # If access fails due to eviction, we will fail over and can ensure that\n+ # data is inserted.\n+ data = _list_blastdbs(ti, *args, **kwargs)\n+ cache[cacheKey] = data\n+ return data\n+\n+\n+def _list_blastdbs(ti, *args, **kwargs):\n+ dbs_data = []\n+ for db in ti.db.get_dbs():\n+ dbs_data.append((db[\'name\'], db[\'db_id\'], False))\n+ return dbs_data\n' |