- added a new table 'sample_dataset' to store sample datasets & their info when they are transfered from the sequencer
- the datasets transfer page now uses a grid to facilitate bulk renaming
- bulk renaming possible to fix the problem with the way SOLiD generates datasets
- the remote file browser is now independent of a specific sample, the user may select any sample when transferring datasets from the sequencer
This commit is contained in:
Ramkrishna Chakrabarty
2010-07-29 10:55:08 -04:00
parent 457a08eb5b
commit c925dc1f2c
14 changed files with 653 additions and 242 deletions
@@ -70,12 +70,12 @@ class DataTransfer(object):
self.config_id_secret = config_id_secret
count=0
while True:
index = self.get_value_index(self.dom, 'index', count)
dataset_id = self.get_value_index(self.dom, 'dataset_id', count)
file = self.get_value_index(self.dom, 'file', count)
name = self.get_value_index(self.dom, 'name', count)
if file:
self.dataset_files.append(dict(name=name,
index=int(index),
dataset_id=int(dataset_id),
file=file))
else:
break
@@ -149,7 +149,7 @@ class DataTransfer(object):
def print_ticks(d):
pass
for i, df in enumerate(self.dataset_files):
self.update_status(Sample.transfer_status.TRANSFERRING, df['index'])
self.update_status(Sample.transfer_status.TRANSFERRING, df['dataset_id'])
try:
cmd = "scp %s@%s:'%s' '%s/%s'" % ( self.username,
self.host,
@@ -168,7 +168,7 @@ class DataTransfer(object):
raise Exception(msg)
except Exception, e:
msg = traceback.format_exc()
self.update_status('Error', df['index'], msg)
self.update_status('Error', df['dataset_id'], msg)
def add_to_library(self):
@@ -189,29 +189,17 @@ class DataTransfer(object):
log.debug(e)
self.error_and_exit(str(e))
def update_status(self, status, dataset_index='All', msg=''):
def update_status(self, status, dataset_id='All', msg=''):
'''
Update the data transfer status for this dataset in the database
'''
try:
log.debug('Setting status "%s" for dataset "%s" of sample "%s"' % ( status, str(dataset_index), str(self.sample_id) ) )
df = from_json_string(self.galaxydb.get_sample_dataset_files(self.sample_id))
if dataset_index == 'All':
log.debug('Setting status "%s" for dataset "%s" of sample "%s"' % ( status, str(dataset_id), str(self.sample_id) ) )
if dataset_id == 'All':
for dataset in self.dataset_files:
df[dataset['index']]['status'] = status
if status == 'Error':
df[dataset['index']]['error_msg'] = msg
else:
df[dataset['index']]['error_msg'] = ''
self.galaxydb.set_sample_dataset_status(dataset['dataset_id'], status, msg)
else:
df[dataset_index]['status'] = status
if status == 'Error':
df[dataset_index]['error_msg'] = msg
else:
df[dataset_index]['error_msg'] = ''
self.galaxydb.set_sample_dataset_files(self.sample_id, to_json_string(df))
self.galaxydb.set_sample_dataset_status(dataset_id, status, msg)
log.debug('done.')
except:
log.error(traceback.format_exc())
@@ -229,12 +217,12 @@ class DataTransfer(object):
rc = rc + node.data
return rc
def get_value_index(self, dom, tag_name, index):
def get_value_index(self, dom, tag_name, dataset_id):
'''
This method extracts the tag value from the xml message
'''
try:
nodelist = dom.getElementsByTagName(tag_name)[index].childNodes
nodelist = dom.getElementsByTagName(tag_name)[dataset_id].childNodes
except:
return None
rc = ""
@@ -28,11 +28,12 @@ class GalaxyDbInterface(object):
def __init__(self, dbstr):
self.dbstr = dbstr
self.db_engine = create_engine(self.dbstr)
self.db_engine.echo = False
self.db_engine.echo = True
self.metadata = MetaData(self.db_engine)
self.session = sessionmaker(bind=self.db_engine)
self.event_table = Table('sample_event', self.metadata, autoload=True )
self.sample_table = Table('sample', self.metadata, autoload=True )
self.sample_dataset_table = Table('sample_dataset', self.metadata, autoload=True )
self.request_table = Table('request', self.metadata, autoload=True )
self.request_event_table = Table('request_event', self.metadata, autoload=True )
self.state_table = Table('sample_state', self.metadata, autoload=True )
@@ -105,7 +106,7 @@ class GalaxyDbInterface(object):
create_time=datetime.utcnow(),
sample_id=sample_id,
sample_state_id=int(new_state_id),
comment='bar code scanner')
comment='Update by barcode scan')
# if all the samples for this request are in the final state
# then change the request state to 'Complete'
result = select(columns=[self.sample_table.c.id],
@@ -126,23 +127,22 @@ class GalaxyDbInterface(object):
request_id=self.request_id,
state=request_state,
comment='All samples of this request have finished processing.')
def get_sample_dataset_files(self, sample_id):
subsubquery = select(columns=[self.sample_table.c.dataset_files],
whereclause=self.sample_table.c.id==sample_id)
return subsubquery.execute().fetchall()[0][0]
def set_sample_dataset_files(self, sample_id, value):
u = self.sample_table.update(whereclause=self.sample_table.c.id==sample_id)
u.execute(dataset_files=value)
def set_sample_dataset_status(self, id, new_status, msg=None):
u = self.sample_dataset_table.update(whereclause=self.sample_dataset_table.c.id==int(id))
u.execute(status=new_status)
if new_status == 'Error':
u.execute(error_msg=msg)
else:
u.execute(error_msg='')
return
if __name__ == '__main__':
print '''This file should not be run directly. To start the Galaxy AMQP Listener:
%sh run_galaxy_listener.sh'''
dbstr = 'postgres://postgres:postgres@localhost/galaxy_uft'
dbstr = 'postgres://postgres:postgres@localhost/g2'
parser = optparse.OptionParser()
parser.add_option('-n', '--name', help='name of the sample field', dest='name', \