1
|
1 <tool id="mongo_client" name="Mongo Client" version="1.0.0">
|
|
2 <description>Mongo Client</description>
|
|
3 <command interpreter="python">$scriptfile</command>
|
|
4 <inputs>
|
|
5 <param name="server" type="text" size="52" label="Server address"/>
|
|
6 <param name="port" type="integer" label="Server Port" value="27017"/>
|
|
7 <param name="db" type="text" size="32" label="Database"/>
|
|
8 <param name="collection" type="text" size="32" label="Collection"/>
|
|
9 <param name="query" type="text" area="True" size="5x25" label="Query">
|
|
10 <sanitizer>
|
|
11 <valid initial="string.printable"/>
|
|
12 <mapping initial="none">
|
|
13 <add source=" " target="__cn__"/>
|
|
14 <add source=""" target="__dq__"/>
|
|
15 </mapping>
|
|
16 </sanitizer>
|
|
17 </param>
|
|
18 </inputs>
|
|
19 <outputs>
|
|
20 <data name="output" format="txt"/>
|
|
21 </outputs>
|
|
22 <configfiles>
|
|
23
|
|
24 <configfile name="scriptfile"><![CDATA[#!/usr/bin/env python
|
|
25 import pymongo
|
|
26 import json
|
|
27 import galaxy.eggs
|
|
28 import galaxy.util
|
|
29
|
|
30 query=galaxy.util.restore_text("""$query""")
|
|
31
|
|
32 conn = pymongo.Connection(galaxy.util.restore_text("$server"), $port)
|
|
33 db = conn[galaxy.util.restore_text('$db')]
|
|
34 collection = db[galaxy.util.restore_text('$collection')]
|
|
35
|
|
36 qObj = None
|
|
37 if len(query):
|
|
38 qObj = json.loads(query)
|
|
39
|
|
40 handle = open(galaxy.util.restore_text("$output"), "w")
|
|
41 for row in collection.find(qObj):
|
|
42 handle.write("%s\n" % (json.dumps(row)))
|
|
43 handle.close()
|
|
44
|
|
45 ]]></configfile>
|
|
46 </configfiles>
|
|
47 <help>
|
|
48
|
|
49 Info about the Mongo Query Syntax:
|
|
50 - `Mongo Query Language <http://www.mongodb.org/display/DOCS/Mongo+Query+Language>`_
|
|
51 - `Advanced Queries <http://www.mongodb.org/display/DOCS/Advanced+Queries>`_
|
|
52
|
|
53 </help>
|
|
54 </tool>
|