def expIdLine(args, expId, t): samplefiles = 0 samplesize = 0 submittedfiles = 0 for stanza in expId: for fname in stanza['fileName'].split(','): if fname in t.files: file = t.files[fname] samplesize = samplesize + file.size samplefiles = samplefiles + 1 if 'geoSampleAccession' in stanza: submittedfiles = submittedfiles + 1 if expId.title == None: title = styles.style('Inconsistent', 'red') else: title = expId.title return expId.name.rjust(12) + ' ' + title + ' [%s]' % filesize(samplesize) + ' - %d files' % samplefiles
def trackLine(args, t): nametext = t.name.ljust(25) try: sub = 0 tot = 0 wantSubmit = 1 for exp in t.alphaMetaDb.experiments.iterkeys(): submitted = 0 samples = 0 for stanza in t.alphaMetaDb.experiments[exp]: if 'objStatus' in stanza: continue if 'Aln' not in stanza['metaObject']: if 'geoSampleAccession' in stanza: submitted += 1 samples += 1 if (not args.pessimistic and submitted > 0) or (submitted == samples and submitted != 0): sub += 1 args.totalsubmitted += 1 if samples > 0: tot += 1 args.totalexps += 1 #for stanza in t.alphaMetaDb.filter2(lambda s: s['objType'] != 'composite').itervalues(): # if 'geoSampleAccession' in stanza: # sub += 1 # tot += 1 #subtext = '%d%%' % int((float(sub) / tot) * 100) subtext = ('%d/%d' % (sub, tot)).ljust(10) #subtext = ' ' * (4 - len(subtext)) + subtext filestext = '%d' % tot filestext = ' ' * (4 - len(filestext)) + filestext + ' files' if sub == 0: subtext = styles.style(subtext, 'red') elif sub < tot: subtext = styles.style(subtext, 'yellow') else: subtext = styles.style(subtext, 'green') wantSubmit = 0 status = styles.style('Public ', 'green') #just randomization for testing, replace with # /cluster/home/mmaddren/kent/src/hg/makeDb/trackDb/human/hg19/trackDb.wgEncode.ra if (tot % 2 == 0): status = styles.style('Unreleased', 'blue') wantSubmit = 0 datatype = styles.style('Not Found'.ljust(16), 'red') if t.alphaMetaDb.dataType != None: datatype = t.alphaMetaDb.dataType.name if t.alphaMetaDb.dataType.type == 'MicroArray': datatype = styles.style(datatype.ljust(16), 'yellow') args.totaltracks += 1 elif t.alphaMetaDb.dataType.valid: datatype = styles.style(datatype.ljust(16), 'green') args.totaltracks += 1 else: if t.alphaMetaDb.dataType.shouldSubmit: datatype = styles.style(datatype.ljust(16), 'red') else: datatype = styles.style(datatype.ljust(16), 'blue') #subtext = '' args.totalexps -= tot wantSubmit = 0 if datatype == '' and len(t.alphaMetaDb.experiments) == 0: datatype = styles.style('no expIds'.ljust(16), 'red') #if wantSubmit: # nametext = styles.style(nametext, 'green') geouptodate = '' if args.geo and t.geo != None: exps = dict() local = 0 offsite = 0 mismatch = 0 matched = 0 for expId in t.alphaMetaDb.experiments.iterkeys(): k = t.alphaMetaDb.experiments[expId].title exps[k] = t.alphaMetaDb.experiments[expId] if k in t.geo.accessions.iterkeys(): happened = 0 for stanza in exps[k]: if 'geoSampleAccession' in stanza and stanza['geoSampleAccession'] != t.geo.accessions[k]: mismatch += 1 happened = 1 break if happened == 0: for stanza in exps[k]: if 'geoSampleAccession' not in stanza: offsite += 1 happened = 1 break if happened == 0: matched += 1 else: local += 1 geouptodate = '%d GSMs, %d expIds, %d match, %d local, %d on geo, %d mismatch' % (len(t.geo.accessions.keys()), len(t.alphaMetaDb.experiments.keys()), matched, local, offsite, mismatch) releases = '' for release in t.releaseObjects: if release.onPublic: releases += styles.style(str(release.index), 'green') else: releases += styles.style(str(release.index), 'red') if 'geoSeriesAccession' in t.alphaMetaDb.compositeStanza: args.submittedtracks += 1 return nametext + styles.style(t.alphaMetaDb.compositeStanza['geoSeriesAccession'].ljust(12), 'green') + subtext + datatype + releases + ' ' + geouptodate else: return nametext + styles.style('Unsubmitted'.ljust(12), 'blue') + subtext + datatype + releases except KeyError as e: return styles.style(nametext, 'red') + styles.style('Error ' + str(e), 'red')