Commits

beroe committed 539a723

vars_retrieve_concept 1.47 - Changed order of fields in output, added field number for cutting

  • Participants
  • Parent commits 1ddb6ab

Comments (0)

Files changed (1)

database/vars_retrieve_concept.py

 	{0} -k Narcomed, Scyphozo # All species for both Narcos and Scyphos 
 	{0} -a Narcome, Scyphoz + Amphipod # Associations between Narcos and Amphipods
 	
+version 1.47: Changed order of fields in output, added field number for cutting
+version 1.46: Cleaned up output and improved library installation instructions
 version 1.45: Added associations and reformatted output
 version 1.4: Added extraction of species from higher taxon
 version 1.3: Handle sample numbers in V3875-D5 format
 		# Take all args as a string, split on commas (genus species have spaces)
 	
 		Aquery = """ SELECT
-		ann.DiveNumber,ann.DEPTH, ann.ConceptName,ann.Latitude, ann.Longitude, ann.Temperature, ann.Oxygen, ann.Salinity,
-		ann.RecordedDate, ann.RovName, ann.TapeTimeCode, ann.Zoom,
+		ann.RovName, ann.DiveNumber,ann.DEPTH, ann.ConceptName,ann.Latitude, ann.Longitude, ann.Temperature, ann.Oxygen, ann.Salinity,
+		ann.RecordedDate, ann.Image, ann.TapeTimeCode, ann.Zoom,
 		ann.ObservationID_FK AS obsid, ann.LinkValue, ann.linkName,
 		ann.VideoArchiveSetID_FK AS vasid, ann.ShipName,
 		ann.Associations,ann.videoArchiveName, ann.CameraDirection,
-		ann.ChiefScientist, ann.FieldWidth, ann.Image, ann.Light, ann.Notes,
+		ann.ChiefScientist, ann.FieldWidth, ann.Light, ann.Notes,
 		ann.Observer, ann.ToConcept
 		FROM Annotations AS ann
 		WHERE (
 		TotalNum += NumFound 
 		Outstr += ResultStr
 
-	Fields = """DiveNumber\tDEPTH\tConceptName\tLatitude\tLongitude\tTemperature\tOxygen\tSalinity\t\
-	RecordedDate\tEpochSecs\tRovName\tTapeTimeCode\tZoom\tObservationID_FK\tLinkValue\tlinkName\t\
+	Fields = """RovName\tDiveNumber\tDEPTH\tConceptName\tLatitude\tLongitude\tTemperature\tOxygen\tSalinity\t\
+	RecordedDate\tImage\tEpochSecs\tTapeTimeCode\tZoom\tObservationID_FK\tLinkValue\tlinkName\t\
 	VideoArchiveSetID_FK\tShipName\tObservationID_FK\tAssociations\tvideoArchiveName\tCameraDirection\t\
-	ChiefScientist\tFieldWidth\tImage\tNotes\tObserver\tAssocConcept\n"""
-	head = """DiveNumber	Depth	ConceptName	Latitude	Longitude	Temperature	Oxygen	EpochSecs	Salinity	RecordedDate	RovName	TapeTimeCode	Zoom	ObservationID_FK	LinkValue	linkName	VideoArchiveSetID_FK	ShipName	Associations	videoArchiveName	CameraDirection	ChiefScientist	FieldWidth	Image	Light	Notes	Observer	AssocConcept"""
+	ChiefScientist\tFieldWidth\tNotes\tObserver\tAssocConcept\n"""
+	L = Fields.split("\t")
+	while '' in L:
+			L.remove('')
+	NumFields = "\t".join(["".join([str(i+1),j]) for i,j in enumerate(L)])
+	
+	# head = """RovName	DiveNumber	Depth	ConceptName	Latitude	Longitude	Temperature	Oxygen	EpochSecs	Salinity	RecordedDate	Image	TapeTimeCode	Zoom	ObservationID_FK	LinkValue	linkName	VideoArchiveSetID_FK	ShipName	Associations	videoArchiveName	CameraDirection	ChiefScientist	FieldWidth	Light	Notes	Observer	AssocConcept"""
 	# print Fields
 	# sys.stderr.write("## Found %d associations for %s...\n" % (TotalNum,conceptstrings))
 
-	return TotalNum, Fields + Outstr
+	return TotalNum, NumFields + Outstr
 	
 def getsamples(DiveList):
 	
 	Constraint = "( %s )" % (" OR ".join(ConList))
 	# Concept = " ".join(sys.argv[1:])
 	query = """ SELECT
-	ann.DiveNumber,ann.DEPTH, ann.ConceptName,ann.Latitude, ann.Longitude, ann.Temperature, ann.Oxygen, ann.Salinity,
-	ann.RecordedDate, ann.RovName, ann.TapeTimeCode, ann.Zoom,
+	ann.RovName, ann.DiveNumber,ann.DEPTH, ann.ConceptName,ann.Latitude, ann.Longitude, ann.Temperature, ann.Oxygen, ann.Salinity,
+	ann.RecordedDate, ann.Image, ann.TapeTimeCode, ann.Zoom,
 	ann.ObservationID_FK AS obsid, ann.LinkValue, ann.linkName,
 	ann.VideoArchiveSetID_FK AS vasid, ann.ShipName,
 	ann.Associations,ann.videoArchiveName, ann.CameraDirection,
-	ann.ChiefScientist, ann.FieldWidth, ann.Image, ann.Light, ann.Notes,
+	ann.ChiefScientist, ann.FieldWidth, ann.Light, ann.Notes,
 	ann.Observer,ann.ToConcept
 	FROM
 	Annotations AS ann
 	where
 	%s """ % Constraint
 
-	Fields = """DiveNumber\tDEPTH\tConceptName\tLatitude\tLongitude\tTemperature\tOxygen\tSalinity\t\
-	RecordedDate\tEpochSecs\tRovName\tTapeTimeCode\tZoom\tObservationID_FK\tLinkValue\tlinkName\t\
+	Fields = """RovName\tDiveNumber\tDEPTH\tConceptName\tLatitude\tLongitude\tTemperature\tOxygen\tSalinity\t\
+	RecordedDate\tImage\tEpochSecs\tTapeTimeCode\tZoom\tObservationID_FK\tLinkValue\tlinkName\t\
 	VideoArchiveSetID_FK\tShipName\tObservationID_FK\tAssociations\tvideoArchiveName\tCameraDirection\t\
-	ChiefScientist\tFieldWidth\tImage\tNotes\tObserver\tToConcept\n"""
+	ChiefScientist\tFieldWidth\tNotes\tObserver\tToConcept\n"""
 
+	L = Fields.split("\t")
+	while '' in L:
+			L.remove('')
+	NumFields = "\t".join(["".join([str(i+1),j]) for i,j in enumerate(L)])
 	sys.stderr.write("Finding all annotations for %s...\n" % conceptstrings)
-	head = """DiveNumber	Depth	ConceptName	Latitude	Longitude	Temperature	Oxygen	EpochSecs	Salinity	RecordedDate	RovName	TapeTimeCode	Zoom	ObservationID_FK	LinkValue	linkName	VideoArchiveSetID_FK	ShipName	Associations	videoArchiveName	CameraDirection	ChiefScientist	FieldWidth	Image	Light	Notes	Observer	ToConcept"""
-	print Fields
+	# head = """RovName	DiveNumber	Depth	ConceptName	Latitude	Longitude	Temperature	Oxygen	EpochSecs	Salinity	RecordedDate	Image	TapeTimeCode	Zoom	ObservationID_FK	LinkValue	linkName	VideoArchiveSetID_FK	ShipName	Associations	videoArchiveName	CameraDirection	ChiefScientist	FieldWidth	Light	Notes	Observer	ToConcept"""
+	print NumFields
 	NumFound,Outstr = execquery(query)
 	print Outstr
 	sys.stderr.write("## Found %d annotations for %s...\n" % (NumFound,conceptstrings))
 def main():
 	
 	if len(sys.argv)<=1:
-		sys.stderr.write(__doc__.format(sys.argv[0]))
+		sys.stderr.write(__doc__.format(sys.argv[0].split("/")[-1]))
 	else:
 		if sys.argv[1] == "-c":
 			findconcept(sys.argv[2:])
 rovname
 shipid
 shipname
-"""
+"""
+