annotate mongo_client.xml @ 1:bda961c955d5 draft

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