changeset 1:bda961c955d5 draft

Uploaded
author kellrott
date Tue, 24 Jul 2012 17:40:44 -0400
parents 907b95ba9cf7
children 1fce03693725
files mongo_client.xml
diffstat 1 files changed, 54 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mongo_client.xml	Tue Jul 24 17:40:44 2012 -0400
@@ -0,0 +1,54 @@
+<tool id="mongo_client" name="Mongo Client" version="1.0.0">
+  <description>Mongo Client</description>
+  <command interpreter="python">$scriptfile</command>
+  <inputs>
+	  <param name="server" type="text" size="52" label="Server address"/>
+	  <param name="port" type="integer" label="Server Port" value="27017"/>
+	  <param name="db" type="text" size="32" label="Database"/>
+	  <param name="collection" type="text" size="32" label="Collection"/>
+	  <param name="query" type="text" area="True" size="5x25" label="Query">
+		<sanitizer>
+			<valid initial="string.printable"/>
+			<mapping initial="none">
+				<add source="&#10;" target="__cn__"/>
+				<add source="&quot;" target="__dq__"/>
+			</mapping>
+		</sanitizer>
+	  </param>      
+  </inputs>
+  <outputs>
+      <data name="output" format="txt"/>
+  </outputs>
+  	<configfiles>
+
+  <configfile name="scriptfile"><![CDATA[#!/usr/bin/env python
+import pymongo
+import json
+import galaxy.eggs
+import galaxy.util
+
+query=galaxy.util.restore_text("""$query""")
+
+conn = pymongo.Connection(galaxy.util.restore_text("$server"), $port)
+db = conn[galaxy.util.restore_text('$db')]
+collection = db[galaxy.util.restore_text('$collection')]
+
+qObj = None
+if len(query):
+	qObj = json.loads(query)
+
+handle = open(galaxy.util.restore_text("$output"), "w")
+for row in collection.find(qObj):
+	handle.write("%s\n" % (json.dumps(row)))
+handle.close()
+
+]]></configfile>
+  	</configfiles>
+<help>
+
+Info about the Mongo Query Syntax:
+ - `Mongo Query Language &lt;http://www.mongodb.org/display/DOCS/Mongo+Query+Language&gt;`_
+ - `Advanced Queries &lt;http://www.mongodb.org/display/DOCS/Advanced+Queries&gt;`_
+
+</help>
+</tool>