This object provides access to all Madrigal experiment information in the metadata file expTab.txt.
Methods
|
|
|
|
__compareDateSite__
|
__compareDateSite__ (
self,
first,
second,
)
__compareDateSite__ is a private method to help sort by start date and then site.
first, second - lists of experiment information as parsed from expTab.txt filesself.__expStartDateCol
|
|
__getPositionByExpIdBinarySearch__
|
__getPositionByExpIdBinarySearch__ ( self, expId )
__getPositionByExpIdBinarySearch__ is a private method that does a binary search for
a given experiment id.
May fail if experiment ids are not in order, or if expId does not exist. If fails, returns
None.
Input: expId - experiment ID (int) to search for
Returns: position (int) of expId. First position = 0. Returns None if not found.
|
|
__init__
|
__init__ (
self,
madDB=None,
initFile=None,
)
__init__ initializes MadrigalExperiment by reading from expTab.txt (or initFile).
Inputs: Existing MadrigalDB object, by default = None.
String representing the full path to the metadata file. Default is None, in
which case file read is MadrigalDB.getMetadataDir()/expTab.txt.
Returns: void
Affects: Initializes all the class member variables.
Exceptions: MadrigalError thrown by MadrigalMetadata if file not opened or parsed successfully.
|
|
__str__
|
__str__ ( self )
return possibly modified file as a string in same format as writeMetadata
|
|
getExpCount
|
getExpCount ( self )
getExpCount returns number of experiments in MadrigalExperiment object
|
|
getExpDirByExpId
|
getExpDirByExpId ( self, expId )
getExpDirByExpId returns the full experiment directory for a given experiment id.
Inputs: Experiment Id (integer).
Returns: the full experiment directory (string). Returns None if experiment id not found.
Uses experiment url to determine directory.
Affects: None
Exceptions: None
|
|
getExpDirByPosition
|
getExpDirByPosition ( self, position=0 )
getExpDirByPosition returns the full experiment directory of the experiment at given position.
Inputs: position of experiment in list (first position is zero). Defaults to first.
Returns: the full experiment directory, or None if position >= number of experiments. Uses
experiment url to determine directory.
Affects: None
Exceptions: None
|
|
getExpEndDateTimeByExpId
|
getExpEndDateTimeByExpId ( self, expId )
getExpEndDateTimeByExpId returns the ending date/time of the experiment for a given experiment id.
Inputs: Experiment Id (integer).
Returns: the experiment end date/time in the standard python form of 9 item tuple in UTC.
Returns None if experiment id not found. Since mktime does not go before 1970, I use
date.c methods, and miss only day of week and DST flag
Affects: None
Exceptions: None
|
|
getExpEndDateTimeByPosition
|
getExpEndDateTimeByPosition ( self, position=0 )
getExpEndDateTimeByPosition returns the ending date/time of the experiment at given position.
Inputs: position of experiment in list (first position is zero). Defaults to first.
Returns: the experiment end date/time in the standard python form of 9 item tuple in UTC.
Returns None if position >= number of experiments. Since mktime does not go before 1970, I use
date.c methods, and miss only day of week and DST flag
Affects: None
Exceptions: None
|
|
getExpIdByPosition
|
getExpIdByPosition ( self, position=0 )
getExpIdByPosition returns the experiment id of the experiment at given position.
Inputs: position of experiment in list (first position is zero). Defaults to first.
Returns: the experiment id (integer), or None if position >= number of experiments.
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
Exceptions
|
|
madrigal.admin.MadrigalError('Error in expTab.txt parsing metadata row: ' + str( position ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getExpLinksByExpId
|
getExpLinksByExpId ( self, expId )
getExpLinksByExpId returns a list of (title, url) tuples containing all links for this experiment.
Inputs:
Inputs: Experiment Id (integer).
Returns: a list of (title, url) tuples containing all links for this experiment.
In order to be a link, a file must be in the experiment directory in the form *.html,
*/index.html, or */*/index.html. The title is parsed from the title in the head; if not found,
returns No title as title. The follow file extensions are also links if found in the
main experiment directory: ['ps', eps , png , jpg , jpeg , pdf , 'gif']. For these
files, the title is simply the basename.
Affects: None
Exceptions: None
|
|
getExpNameByExpId
|
getExpNameByExpId ( self, expId )
getExpNameByExpId returns the experiment name for a given experiment id.
Inputs: Experiment Id (integer).
Returns: the experiment name (string). Returns None if experiment id not found.
Affects: None
Exceptions: None
|
|
getExpNameByPosition
|
getExpNameByPosition ( self, position=0 )
getExpNameByPosition returns the experiment name of the experiment at given position.
Inputs: position of experiment in list (first position is zero). Defaults to first.
Returns: the experiment name, or None if position >= number of experiments.
Affects: None
Exceptions: None
|
|
getExpSiteIdByExpId
|
getExpSiteIdByExpId ( self, expId )
getExpSiteIdByExpId returns the site id (int) for a given experiment id.
Inputs: Experiment Id (integer).
Returns: the site id for this experiment. Returns None if experiment id not found.
Affects: None
Exceptions: None
|
|
getExpSiteIdByPosition
|
getExpSiteIdByPosition ( self, position=0 )
getExpSiteIdByPosition returns the experiment site id of the experiment at given position.
Inputs: position of experiment in list (first position is zero). Defaults to first.
Returns: the experiment site id (integer), or None if position >= number of experiments.
Affects: None
Exceptions: MadrigalError if any item in row cannot be cast to correct format
Exceptions
|
|
madrigal.admin.MadrigalError('Error in expTab.txt parsing metadata row: ' + str( position ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getExpStartDateTimeByExpId
|
getExpStartDateTimeByExpId ( self, expId )
getExpStartDateTimeByExpId returns the starting date/time of the experiment for a given experiment id.
Inputs: Experiment Id (integer).
Returns: the experiment start date/time in the standard python form of 9 item tuple in UTC.
Returns None if experiment id not found. Since mktime does not go before 1970, I use
date.c methods, and miss only day of week and DST flag
Affects: None
Exceptions: None
|
|
getExpStartDateTimeByPosition
|
getExpStartDateTimeByPosition ( self, position=0 )
getExpStartDateTimeByPosition returns the starting date/time of the experiment at given position.
Inputs: position of experiment in list (first position is zero). Defaults to first.
Returns: the experiment start date/time in the standard python form of 9 item tuple in UTC.
Returns None if position >= number of experiments. Since mktime does not go before 1970, I use
date.c methods, and miss only day of week and DST flag
Affects: None
Exceptions: None
|
|
getExpUrlByExpId
|
getExpUrlByExpId ( self, expId )
getExpUrlByExpId returns the experiment url for a given experiment id.
Inputs: Experiment Id (integer).
Returns: the experiment url (string). Returns None if experiment id not found.
Affects: None
Exceptions: None
|
|
getExpUrlByPosition
|
getExpUrlByPosition ( self, position=0 )
getExpUrlByPosition returns the experiment url of the experiment at given position.
Inputs: position of experiment in list (first position is zero). Defaults to first.
Returns: the experiment url, or None if position >= number of experiments.
Affects: None
Exceptions: None
|
|
getKinstByExpId
|
getKinstByExpId ( self, expId )
getKinstByExpId returns the kinst (integer) of the experiment for a given experiment id.
Inputs: Experiment Id (integer).
Returns: the experiment kinst (integer). Returns None if experiment id not found.
Affects: None
Exceptions: None
Exceptions
|
|
madrigal.admin.MadrigalError('Error in expTab.txt parsing metadata row: ' + str( position ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getKinstByPosition
|
getKinstByPosition ( self, position=0 )
getKinstByPosition returns the kinst (kind of instrument code) of the experiment at given position.
Inputs: position of file in list (first position is zero). Defaults to first.
Returns: the kindat (kind of data code) of the file at given position as an integer.
Returns None if position >= number of files.
Affects: None
Exceptions: Thrown if kindat column cannot be parsed into an integer
Exceptions
|
|
madrigal.admin.MadrigalError('Error in expTab.txt parsing metadata row: ' + str( position ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getLine
|
getLine ( self, position )
getLine returns the line at a given position. Returns None if position > number of lines.
Inputs: position - position in file. First line = 0
|
|
getPIByExpId
|
getPIByExpId ( self, expId )
getPIByExpId returns the principal investigator (string) of the experiment for a given experiment id.
Inputs: Experiment Id (integer).
Returns: the principal investigator's name (string). Returns None if experiment id not found.
Since not all expTab.txt files may have this column, returns None if the column does not exist.
Affects: None
Exceptions: None
This method added in Madrigal 2.6
|
|
getPIByPosition
|
getPIByPosition ( self, position=0 )
getPIByPosition returns the principal investigator of the experiment at given position.
Inputs: position of file in list (first position is zero). Defaults to first.
Returns: the principal investigator's name (string) of the file at given position as a string.
Returns None if position >= number of files. Since not all expTab.txt files may have this
column, returns None if the column does not exist.
Affects: None
Exceptions: None
This method added in Madrigal 2.6
|
|
getPIEmailByExpId
|
getPIEmailByExpId ( self, expId )
getPIEmailByExpId returns the principal investigator email (string) of the experiment for a given experiment id.
Inputs: Experiment Id (integer).
Returns: the principal investigator's email (string). Returns None if experiment id not found.
Since not all expTab.txt files may have this column, returns None if the column does not exist.
Affects: None
Exceptions: None
This method added in Madrigal 2.6
|
|
getPIEmailByPosition
|
getPIEmailByPosition ( self, position=0 )
getPIEmailByPosition returns the principal investigator email of the experiment at given position.
Inputs: position of file in list (first position is zero). Defaults to first.
Returns: the principal investigator's email (string) of the file at given position as a string.
Returns None if position >= number of files. Since not all expTab.txt files may have this
column, returns None if the column does not exist.
Affects: None
Exceptions: None
This method added in Madrigal 2.6
|
|
getSecurityByExpId
|
getSecurityByExpId ( self, expId )
getSecurityByExpId returns the security code (integer) of the experiment for a given experiment id.
Inputs: Experiment Id (integer).
Returns: the security code (integer). Returns None if experiment id not found.
Affects: None
Exceptions: None
Exceptions
|
|
madrigal.admin.MadrigalError('Error in expTab.txt parsing metadata row: ' + str( position ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
getSecurityByPosition
|
getSecurityByPosition ( self, position=0 )
getSecurityByPosition returns the security code of the experiment at given position.
Inputs: position of file in list (first position is zero). Defaults to first.
Returns: the security code (integer) of the file at given position as an integer.
Returns None if position >= number of files.
Affects: None
Exceptions: Thrown if security column cannot be parsed into an integer
Exceptions
|
|
madrigal.admin.MadrigalError('Error in expTab.txt parsing metadata row: ' + str( position ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|
|
setExpEndDateTimeByPosition
|
setExpEndDateTimeByPosition (
self,
endDateTime,
position=0,
)
setExpEndDateTimeByPosition sets a new MadrigalExperiment end date and time by position.
Inputs:
endDateTime - a python datetime object to set the exp end date and time to.
position - which experiment row to change - defaults to 0
Returns: None.
Affects: sets exp end date and time in self.__fileList.
Exceptions: None
|
|
setExpIdByPosition
|
setExpIdByPosition (
self,
position,
expId,
)
setExpIdByPosition sets the experiment id of the experiment at given position.
Inputs:
position - position of experiment in list (first position is zero).
expId - the new experiment id to use
Returns: None.
Affects: sets the experiment id of the experiment at given position
Exceptions: MadrigalError if any item in row cannot be cast to correct format, or
position not found.
Exceptions
|
|
madrigal.admin.MadrigalError('Error in setExpIdByPosition with args %s: %s' %(str(( position, expId ) ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) ) )
|
|
|
setExpKinstByPosition
|
setExpKinstByPosition (
self,
position,
expKinst,
)
setExpKinstByPosition sets the experiment kinst of the experiment at given position.
Inputs:
position - position of experiment in list (first position is zero).
expKinst - the new experiment kinst to use
Returns: None.
Affects: sets the experiment kinst of the experiment at given position
Exceptions: MadrigalError if any item in row cannot be cast to correct format, or
position not found.
Exceptions
|
|
madrigal.admin.MadrigalError('Error in setExpKinstByPosition with args %s: %s' %(str( position, expKinst ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) ) )
|
|
|
setExpNameByPosition
|
setExpNameByPosition (
self,
position,
expName,
)
setExpNameByPosition sets the experiment name of the experiment at given position.
Inputs:
position - position of experiment in list (first position is zero).
expName - the new experiment name to use
Returns: None.
Affects: sets the experiment name of the experiment at given position
Exceptions: MadrigalError if any item in row cannot be cast to correct format, or
position not found.
Exceptions
|
|
madrigal.admin.MadrigalError('Error in setExpNameByPosition with args %s: %s' %(str( position, expName ), [traceback.format_exc() ] ) )
madrigal.admin.MadrigalError('Error in setExpNameByPosition with args %s: %s' %(str( position, expName ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) ) )
|
|
|
setExpSiteIdByPosition
|
setExpSiteIdByPosition (
self,
position,
expSiteId,
)
setExpSiteIdByPosition sets the experiment site id of the experiment at given position.
Inputs:
position - position of experiment in list (first position is zero).
expSiteId - the new experiment site id to use
Returns: None.
Affects: sets the experiment site id of the experiment at given position
Exceptions: MadrigalError if any item in row cannot be cast to correct format, or
position not found.
Exceptions
|
|
madrigal.admin.MadrigalError('Error in setExpSiteIdByPosition with args %s: %s' %(str( position, expSiteId ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) ) )
|
|
|
setExpStartDateTimeByPosition
|
setExpStartDateTimeByPosition (
self,
startDateTime,
position=0,
)
setExpStartDateTimeByPosition sets a new MadrigalExperiment start date and time by position.
Inputs:
startDateTime - a python datetime object to set the exp start date and time to.
position - which experiment row to change - defaults to 0
Returns: None.
Affects: sets exp start date and time in self.__fileList.
Exceptions: None
|
|
setExpUrlByPosition
|
setExpUrlByPosition (
self,
position,
expUrl,
)
setExpUrlByPosition sets the experiment url of the experiment at given position.
Inputs:
position - position of experiment in list (first position is zero).
expUrl - the new experiment url to use
Returns: None.
Affects: sets the experiment url of the experiment at given position
Exceptions: MadrigalError if any item in row cannot be cast to correct format, or
position not found.
Exceptions
|
|
madrigal.admin.MadrigalError('Error in setExpUrlByPosition with args %s: %s' %(str( position, expUrl ), [traceback.format_ex() ] ) )
madrigal.admin.MadrigalError('Error in setExpUrlByPosition with args %s: %s' %(str( position, expUrl ), [traceback.format_exc() ] ) )
|
|
|
setPIByPosition
|
setPIByPosition (
self,
position,
PI,
)
setPIByPosition sets the principal investigator (string) of the experiment at given position.
Inputs:
position - position of experiment in list (first position is zero).
PI - the new experiment principal investigator's name (string) to use
Returns: None.
Affects: sets the principal investigator of the experiment at given position
Exceptions: MadrigalError if any item in row cannot be cast to correct format, or
position not found.
This method added in Madrigal 2.6
Exceptions
|
|
madrigal.admin.MadrigalError('Error in setPIByPosition with args %s: %s' %(str( position, PI ), [traceback.format_exc() ] ) )
|
|
|
setPIEmailByPosition
|
setPIEmailByPosition (
self,
position,
PIEmail,
)
setPIEmailByPosition sets the principal investigator email (string) of the experiment at given position.
Inputs:
position - position of experiment in list (first position is zero).
PIEmail - the new experiment principal investigator's email (string) to use
Returns: None.
Affects: sets the principal investigator email of the experiment at given position
Exceptions: MadrigalError if any item in row cannot be cast to correct format, or
position not found.
This method added in Madrigal 2.6
Exceptions
|
|
madrigal.admin.MadrigalError('Error in setPIEmailByPosition with args %s: %s' %(str( position, PIEmail ), [traceback.format_exc() ] ) )
|
|
|
setSecurityByPosition
|
setSecurityByPosition (
self,
position,
securityCode,
)
setSecurityByPosition sets the security code (integer) of the experiment at given position.
Inputs:
position - position of experiment in list (first position is zero).
securityCode - the new experiment security code (integer) to use
Returns: None.
Affects: sets the security code of the experiment at given position
Exceptions: MadrigalError if any item in row cannot be cast to correct format, or
position not found.
Exceptions
|
|
madrigal.admin.MadrigalError('Error in setSecurityByPosition with args %s: %s' %(str( position, securityCode ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) ) )
|
|
|
sortByDateSite
|
sortByDateSite ( self )
sortByDateSite will resort self.__fileList so that experiments are listed first by experiment
start date, and then by site
|
|
writeMetadata
|
writeMetadata ( self, newFullPath=None )
writeMetadata writes a new version of the expTab.txt file.
Inputs: newFullPath: a new path to write the expTab.txt file to, if
not the same as the original metadata file opened. Defaults to None, which overwrites
metadata file that was read from.
Returns: None.
Affects: Writes updated version of metadata file.
Exceptions: If unable to write file
Exceptions
|
|
madrigal.admin.MadrigalError("Unable to write metadata file " + str( newFullPath ), traceback.format_exception(sys.exc_info() [ 0 ], sys.exc_info() [ 1 ], sys.exc_info() [ 2 ] ) )
|
|