1. beroe
  2. MBARI public

Commits

beroe  committed 818a273

Cleaned up output and improved library installation instructions

  • Participants
  • Parent commits 681d550
  • Branches master

Comments (0)

Files changed (1)

File database/vars_retrieve_concept.py

View file
  • Ignore whitespace
 version 1.2: Flag to perform different queries at run time
 version 1.1: Parses the V2132 format. Can also take dive number w/o vehicle
   [haddock at MBARI dot org]
-Requires: pymssql module, freetds-dev, and unixODBC (not sure about the last one)
+Requires: pymssql module, freetds-dev, and unixODBC 
+Installation instructions are a comment in the source code below...
 
 """
-
-# Possible installation commands for OSX : 
-#     pip install cython
+# main() code is at the bottom
+# INSTALLATION: pre-requisites for OSX, in this order
+#     Command Line Tools from https://developer.apple.com/downloads/ 
+#     Install HomeBrew with this exact command: 
+#         ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
+#     Install pip with this exact command:
+#         sudo easy_install pip
 #     brew install unixodbc
 #     brew install --with-unixodbc freetds
-#     pip install pymssql
-
-##! /opt/python/bin/python
-
-# this needs the pymssql module, which needs freetds and possibly unixODBC,
-# so it is not the easiest to install.
-# to run it on pismo, you have to use the funky path to python so
-# it will use v2.7 instead of 2.5
+#     sudo pip install pymssql
 
 import time
 import sys
 	# Need to search both ways: fish annotated with jelly and jelly annotated with fish...
 	for Flipper in ([HostCons,AssocCons],[AssocCons,HostCons]):
 		FromCon = """ ann.ConceptName IN ({}) """.format(Flipper[0])
-		ToCon = """ ann.ToConcept IN ({}) """.format(Flipper[1])
+		# ToCon = """ ann.ToConcept IN ({},'Marine organism') """.format(Flipper[1])
+		ToCon = """ ( (ann.ToConcept IN ({0}) ) OR (REPLACE(ann.Associations,'-',' ' ) IN ({0}) ) ) """.format(Flipper[1])
 		# FromCon = """ ann.ConceptName IN ({}) """.format("'Chrysaora'")
 		# ToCon = """ ann.ToConcept IN ({}) """.format("'Doryteuthis opalescens'")
 		# Take all args as a string, split on commas (genus species have spaces)
 		FROM Annotations AS ann
 		WHERE (
 		( ({0}) AND ({1}) ) 
-		AND ann.linkName LIKE '%association%'   
+		AND ( ann.linkName LIKE '%association%')   
 		) """.format(FromCon,ToCon)
 		# print "query: ",Aquery
+		# AND (( ann.linkName LIKE '%association%') OR (ann.linkName LIKE '%commensal%'))  
 
 		NumFound,ResultStr = execquery(Aquery)
 
 		# print SQuery.format(ROVName,DiveNum)
 		NumFound,Outstr = execquery(query = SQuery.format(ROVName, DiveNum), mydatabase="EXPD")
 		TotalFound +=NumFound
-		print Outstr
+		print Outstr.rstrip("\n")
 	sys.stderr.write("## Found %s dive summaries...\n" % (TotalFound))
 
 def findconcept(conceptstrings):
 			else:
 				assocnum, assocstr = findassociation(sys.argv[2:]) 
 
-			sys.stderr.write("## Found %d annotations for %s (and vice versa)...\n\n" % (assocnum," ".join(sys.argv[2:]) ))
+			sys.stderr.write("\n## Found %d annotations for %s (and vice versa)...\n" % (assocnum," ".join(sys.argv[2:]) ))
 			if style:
 				print assocstr
 			else: