Merge pull request #4178 from zipho/neo_datatype

Neostore Zip datatype support
This commit is contained in:
John Chilton
2018-01-02 13:33:27 -05:00
committed by GitHub
6 changed files with 125 additions and 26 deletions
+4
View File
@@ -620,6 +620,9 @@
<datatype extension="mothur.sff.flow" type="galaxy.datatypes.mothur:SffFlow" display_in_upload="true"/>
<datatype extension="mothur.count_table" type="galaxy.datatypes.mothur:CountTable" display_in_upload="true"/>
<datatype extension="neostore" type="galaxy.datatypes.neo4j:Neo4jDB" mimetype="text/html" display_in_upload="false"/>
<datatype extension="neostore.zip" type="galaxy.datatypes.neo4j:Neo4jDBzip" display_in_upload="true">
<converter file="neostorezip_to_neostore_converter.xml" target_datatype="neostore"/>
</datatype>
<datatype extension="trackhub" type="galaxy.datatypes.tracks:UCSCTrackHub" display_in_upload="true">
<display file="ucsc/trackhub.xml" />
</datatype>
@@ -824,5 +827,6 @@
<sniffer type="galaxy.datatypes.binary:OxliStopTags"/>
<sniffer type="galaxy.datatypes.binary:OxliSubset"/>
<sniffer type="galaxy.datatypes.binary:OxliGraphLabels"/>
<sniffer type="galaxy.datatypes.neo4j:Neo4jDBzip"/>
</sniffers>
</datatypes>
@@ -0,0 +1,14 @@
<tool id="CONVERTER_neostorezip_to_neostore" name="Convert neostore.zip files to neostore" version="1.0.0" hidden="true">
<command><![CDATA[
unzip '${input1.extra_files_path}/neostore_file.zip' -d '${output1.files_path}' > $output1
]]>
</command>
<inputs>
<param format="neostore.zip" name="input1" type="data" label="Choose neostore database file"/>
</inputs>
<outputs>
<data format="neostore" name="output1"/>
</outputs>
<help>
</help>
</tool>
+69 -26
View File
@@ -8,6 +8,7 @@ import sys
from galaxy.datatypes.data import Data
from galaxy.datatypes.images import Html
from galaxy.datatypes.metadata import MetadataElement
from galaxy.util import FILENAME_VALID_CHARS
gal_Log = logging.getLogger(__name__)
@@ -26,6 +27,7 @@ class Neo4j(Html):
This is called only at upload to write the html file
cannot rename the datasets here - they come with the default unfortunately
"""
# self.regenerate_primary_file(dataset)
rval = [
'<html><head><title>Files for Composite Dataset (%s)</title></head><p/>\
This composite dataset is composed of the following files:<p/><ul>' % (
@@ -34,7 +36,8 @@ class Neo4j(Html):
opt_text = ''
if composite_file.optional:
opt_text = ' (optional)'
rval.append('<li><a href="%s">%s</a>%s' % (composite_name, composite_name, opt_text))
rval.append('<li><a href="%s">%s</a>%s' %
(composite_name, composite_name, opt_text))
rval.append('</ul></html>')
return "\n".join(rval)
@@ -68,22 +71,27 @@ class Neo4j(Html):
trans.log_event("Display dataset id: %s" % str(data.id))
# the target directory name
neo4j_dir_name = '/dataset_{}_files/neo4jdb'.format(data.dataset.id)
dir_name = str(os.path.dirname(trans.app.object_store.get_filename(data.dataset))) + neo4j_dir_name
neo4j_dir_name = '/dataset_{}_files'.format(
data.dataset.id)
dir_name = str(os.path.dirname(
trans.app.object_store.get_filename(data.dataset))) + neo4j_dir_name
# generate unique filename for this dataset
fname = ''.join(c in FILENAME_VALID_CHARS and c or '_' for c in data.name)[0:150]
fname = ''.join(
c in FILENAME_VALID_CHARS and c or '_' for c in data.name)[0:150]
# zip the target directory (dir_name) using the fname
shutil.make_archive(fname, 'zip', dir_name)
download_zip = fname + '.zip'
# setup headers for the download
trans.response.headers['Content-Length'] = int(os.stat(download_zip).st_size)
trans.response.headers['Content-Length'] = int(
os.stat(download_zip).st_size)
# force octet-stream so Safari doesn't append mime extensions to filename
trans.response.set_content_type("application/octet-stream")
trans.response.headers["Content-Disposition"] = 'attachment; filename="Galaxy%s-[%s].%s"' % \
(data.hid, download_zip, "zip")
(data.hid,
download_zip, "zip")
return open(download_zip)
@@ -97,39 +105,74 @@ class Neo4jDB(Neo4j, Data):
Data.__init__(self, **kwd)
self.add_composite_file('neostore', is_binary=True)
self.add_composite_file('neostore.id', is_binary=True)
self.add_composite_file('neostore.counts.db.a', is_binary=True)
self.add_composite_file('neostore.counts.db.b', is_binary=True)
self.add_composite_file('neostore.counts.db.a', optional=True, is_binary=True)
self.add_composite_file('neostore.counts.db.b', optional=True, is_binary=True)
self.add_composite_file('neostore.labeltokenstore.db', is_binary=True)
self.add_composite_file('neostore.labeltokenstore.db.id', is_binary=True)
self.add_composite_file('neostore.labeltokenstore.db.names', is_binary=True)
self.add_composite_file('neostore.labeltokenstore.db.names.id', is_binary=True)
self.add_composite_file(
'neostore.labeltokenstore.db.id', is_binary=True)
self.add_composite_file(
'neostore.labeltokenstore.db.names', is_binary=True)
self.add_composite_file(
'neostore.labeltokenstore.db.names.id', is_binary=True)
self.add_composite_file('neostore.nodestore.db', is_binary=True)
self.add_composite_file('neostore.nodestore.db.id', is_binary=True)
self.add_composite_file('neostore.nodestore.db.labels', is_binary=True)
self.add_composite_file('neostore.nodestore.db.labels.id', is_binary=True)
self.add_composite_file(
'neostore.nodestore.db.labels.id', is_binary=True)
self.add_composite_file('neostore.propertystore.db', is_binary=True)
self.add_composite_file('neostore.propertystore.db.id', is_binary=True)
self.add_composite_file('neostore.propertystore.db.arrays', is_binary=True)
self.add_composite_file('neostore.propertystore.db.arrays.id', is_binary=True)
self.add_composite_file('neostore.propertystore.db.index', is_binary=True)
self.add_composite_file('neostore.propertystore.db.index.id', is_binary=True)
self.add_composite_file('neostore.propertystore.db.index.keys', is_binary=True)
self.add_composite_file('neostore.propertystore.db.index.keys.id', is_binary=True)
self.add_composite_file('neostore.propertystore.db.strings', is_binary=True)
self.add_composite_file('neostore.propertystore.db.strings.id', is_binary=True)
self.add_composite_file(
'neostore.propertystore.db.arrays', is_binary=True)
self.add_composite_file(
'neostore.propertystore.db.arrays.id', is_binary=True)
self.add_composite_file(
'neostore.propertystore.db.index', is_binary=True)
self.add_composite_file(
'neostore.propertystore.db.index.id', is_binary=True)
self.add_composite_file(
'neostore.propertystore.db.index.keys', is_binary=True)
self.add_composite_file(
'neostore.propertystore.db.index.keys.id', is_binary=True)
self.add_composite_file(
'neostore.propertystore.db.strings', is_binary=True)
self.add_composite_file(
'neostore.propertystore.db.strings.id', is_binary=True)
self.add_composite_file('neostore.relationshipgroupstore.db', is_binary=True)
self.add_composite_file('neostore.relationshipgroupstore.db.id', is_binary=True)
self.add_composite_file('neostore.relationshipstore.db', is_binary=True)
self.add_composite_file('neostore.relationshipstore.db.id', is_binary=True)
self.add_composite_file('neostore.relationshiptypestore.db.names', is_binary=True)
self.add_composite_file('neostore.relationshiptypestore.db.names.id', is_binary=True)
self.add_composite_file(
'neostore.relationshipgroupstore.db', is_binary=True)
self.add_composite_file(
'neostore.relationshipgroupstore.db.id', is_binary=True)
self.add_composite_file(
'neostore.relationshipstore.db', is_binary=True)
self.add_composite_file(
'neostore.relationshipstore.db.id', is_binary=True)
self.add_composite_file(
'neostore.relationshiptypestore.db.names', is_binary=True)
self.add_composite_file(
'neostore.relationshiptypestore.db.names.id', is_binary=True)
self.add_composite_file('neostore.schemastore.db', is_binary=True)
self.add_composite_file('neostore.schemastore.db.id', is_binary=True)
self.add_composite_file('neostore.transaction.db.0', is_binary=True)
class Neo4jDBzip(Neo4j, Data):
"""Class for neo4jDB database files."""
MetadataElement(name='reference_name', default='neostore_file', desc='Reference Name',
readonly=True, visible=True, set_in_upload=True, no_value='neostore')
MetadataElement(name="neostore_zip", default=None, desc="Neostore zip",
readonly=True, visible=True, set_in_upload=True, no_value=None, optional=True)
file_ext = "neostore.zip"
composite_type = 'auto_primary_file'
allow_datatype_change = False
def __init__(self, **kwd):
Data.__init__(self, **kwd)
self.add_composite_file('%s.zip', description='neostore zip', substitute_name_with_metadata='reference_name',
is_binary=True)
if __name__ == '__main__':
import doctest
doctest.testmod(sys.modules[__name__])
Binary file not shown.
@@ -0,0 +1,19 @@
<tool id="compressed_neostorezip_neostore_conversion" name="Confirm neostore.zip is converted to neostore on demand">
<command>
cat '$input1' > '$out_file1'
</command>
<inputs>
<param name="input1" type="data" format="neostore.zip" label="Compressed Dataset"/>
</inputs>
<outputs>
<data name="out_file1" format="neostore"/>
</outputs>
<tests>
<test>
<param name="input1" value="neostore.zip"/>
<output name="out_file1" file="neostore"/>
</test>
</tests>
<help>
</help>
</tool>
@@ -0,0 +1,19 @@
<tool id="compressed_neostorezip_neostore_cat" name="Confirm neostorezip is not uncompressed">
<command>
cat '$input1' > '$out_file1'
</command>
<inputs>
<param name="input1" type="data" format="neostore.zip" label="Compressed Dataset"/>
</inputs>
<outputs>
<data name="out_file1" format="neostore.zip"/>
</outputs>
<tests>
<test>
<param name="input1" value="neostore.zip"/>
<output name="out_file1" file="neostore.zip" ftype="neostore.zip"/>
</test>
</tests>
<help>
</help>
</tool>