473bc7f4705c122d450278c5f505f215964aba21 tdreszer Wed Apr 20 16:33:38 2011 -0700 Cleaned up some mesages in experimentify mdbPrint command diff --git src/hg/lib/mdb.c src/hg/lib/mdb.c index a695c32..913875e 100644 --- src/hg/lib/mdb.c +++ src/hg/lib/mdb.c @@ -2759,31 +2759,32 @@ continue; } dyStringClear(dyVars); dyStringAppend(dyVars,slNameListToString(compositeEdvs, ' ')); if (warn > 0) printf("Composite%s '%s' with %d objects has %d EDVs(%s): [%s].\n",(compositelessObj?"less set":""),compName, slCount(mdbCompositeObjs),slCount(compositeEdvs),MDB_VAR_ENCODE_EDVS,dyStringContents(dyVars)); // Set the stage // Organize composite objs by EDVs dyStringPrintf(dyVars, " %s %s ",MDB_VAR_VIEW,MDB_VAR_REPLICATE); // Allows for nicer sorted list char *edvSortOrder = cloneString(dyStringContents(dyVars)); // Walk through objs for an exp as defined by EDVs int expCount=0; // Count of experiments in composite - int expMissing=0; // Count of experiments with missing expId + int expMissing=0; // Count of objects with missing expId + int accMissing=0; // Count of objects with missing accessions int expObjsCount=0; // Total of all experimental object accoss the composite int expMax=0; // Largest experiment (in number of objects) int expMin=999; // Smallest experiment (in number of objects) while(mdbCompositeObjs != NULL) { // Must sort each cycle, because sort order is lost during mdbObjs FilterByVars(); mdbObjsSortOnVars(&mdbCompositeObjs, edvSortOrder); // Get the EDVs for the first obj struct mdbVar *edvVarVals = mdbObjEncodeEdvsAsMdbVars(mdbCompositeObjs,compositeEdvs,TRUE); // use first obj on list and include Nones if (edvVarVals == NULL) { verbose(1, "There are no experiment defining variables for this object '%s'.\n",mdbCompositeObjs->obj); slAddHead(&mdbProcessedObs,slPopHead(&mdbCompositeObjs)); // We're done with this one continue; @@ -2834,31 +2835,31 @@ if (createExpIfNecessary && updateAccession && exp->ix != ENCODE_EXP_IX_UNDEFINED && exp->accession == NULL) encodeExpSetAccession(exp, expTable); if (exp != NULL) expId = exp->ix; if (expId == ENCODE_EXP_IX_UNDEFINED) { safef(experimentId,sizeof(experimentId),"{missing}"); if (warn > 0) printf("Experiment %s EDV: [%s] is not defined in %s.%s table.\n",experimentId,dyStringContents(dyVars), ENCODE_EXP_DATABASE, expTable); //printf("Experiment %s EDV: [%s] is not defined in %s table. Remaining:%d and %d\n",experimentId,dyStringContents(dyVars),EXPERIMENTS_TABLE,slCount(mdbCompositeObjs),slCount(mdbObjs)); if (warn < 2) // From mdbUpdate (warn=1), just interested in testing waters. From mdbPrint (warn=2) list all objs in exp. { - expMissing++; + expMissing += slCount(mdbExpObjs); mdbProcessedObs = slCat(mdbProcessedObs,mdbExpObjs); mdbExpObjs = NULL; encodeExpFree(&exp); continue; } } else { safef(experimentId,sizeof(experimentId),"%d",expId); if (warn > 0) printf("Experiment %s has %d objects based upon %d EDVs: [%s].\n",experimentId,slCount(mdbExpObjs),valsFound,dyStringContents(dyVars)); // Set the stage } // Now we can walk through each obj in experiment and determine if it has the correct expId int foundId = FALSE; @@ -2873,96 +2874,106 @@ { // NOTE: This list could expand but we expect only tables and files to be objs in an experiment char *objType = mdbObjFindValue(obj,MDB_OBJ_TYPE); assert(objType != NULL && (sameString(objType,MDB_OBJ_TYPE_TABLE) || sameString(objType,MDB_OBJ_TYPE_FILE))); } boolean updateObj = FALSE; char *val = mdbObjFindValue(obj,MDB_VAR_ENCODE_EXP_ID); if (val != NULL) { foundId = TRUE; // warn==1 will give only 1 exp wide error if no individual errors. NOTE: would be nice if those with expId sorted to beginning, but can't have everything. int thisId = atoi(val); if (expId == ENCODE_EXP_IX_UNDEFINED || thisId != expId) { updateObj = TRUE; // Always an error! - printf(" ERROR %s %s has bad %s=%s.\n",experimentId,obj->obj,MDB_VAR_ENCODE_EXP_ID,val); + expMissing++; + + printf(" ERROR %s %-60s has bad %s=%s.\n",experimentId,obj->obj,MDB_VAR_ENCODE_EXP_ID,val); } else { char *acc = mdbObjFindValue(obj,MDB_VAR_DCC_ACCESSION); // FIXME: Add code to update accession to encodeExp if (updateAccession && !createExpIfNecessary && exp->accession == NULL) { exp->accession = needMem(16); safef(exp->accession, 16, "TEMP%06d", exp->ix); // Temporary since this is not an update but we want -test to work. } if (exp->accession != NULL && (acc == NULL || differentString(acc,exp->accession))) { updateObj = TRUE; + accMissing++; + if (acc != NULL) // Always an error - printf(" ERROR %s %s %s set, has wrong %s: %s.\n",experimentId,obj->obj, + printf(" ERROR %s %-60s %s set, has wrong %s: %s.\n",experimentId,obj->obj, MDB_VAR_ENCODE_EXP_ID,MDB_VAR_DCC_ACCESSION,acc); else if (warn > 1) // NOTE: Could give more info for each obj as per wrangler's desires - printf(" %s %s %s set, needs %s.\n",experimentId,obj->obj,MDB_VAR_ENCODE_EXP_ID,MDB_VAR_DCC_ACCESSION); + printf(" %s %-60s %s set, needs %s.\n",experimentId,obj->obj,MDB_VAR_ENCODE_EXP_ID,MDB_VAR_DCC_ACCESSION); } else { errors--; // One less error if (warn > 1) // NOTE: Could give more info for each obj as per wrangler's desires - printf(" %s %s %s\n",experimentId,obj->obj,(exp->accession != NULL ? exp->accession : "")); + printf(" %s %-60s %s\n",experimentId,obj->obj,(exp->accession != NULL ? exp->accession : "")); } } } else { - updateObj = (expId != ENCODE_EXP_IX_UNDEFINED); + if (expId != ENCODE_EXP_IX_UNDEFINED) + { + updateObj = TRUE; + expMissing++; + } + if ((foundId && warn > 0) || warn > 1) { if (updateObj) - printf(" %s %s needs updating to mdb.\n",experimentId,obj->obj); + printf(" %s %-60s needs updating to mdb.\n",experimentId,obj->obj); else printf(" %s %s\n",experimentId,obj->obj); // missing } } // This object needs to be updated. if (updateObj) { mdbObjSetVarInt(obj,MDB_VAR_ENCODE_EXP_ID,expId); struct mdbObj *newObj = mdbObjCreate(obj->obj,MDB_VAR_ENCODE_EXP_ID, experimentId); assert(exp != NULL); if (exp->accession != NULL) mdbObjSetVar(newObj,MDB_VAR_DCC_ACCESSION,exp->accession); slAddHead(&mdbUpdateObjs,newObj); } slAddHead(&mdbProcessedObs,obj); } // Done with one experiment encodeExpFree(&exp); - if (!foundId && errors > 0) - { - expMissing++; - if (warn > 0) + if (!foundId && errors > 0 && warn > 0) printf(" %s all %d objects are missing an %s.\n",experimentId,objsInExp,MDB_VAR_ENCODE_EXP_ID); } - } // Done with one composite if (expCount > 0) - printf("Composite%s '%s' has %d recognizable experiment%s with %d missing an %s.\n objects/experiment: min:%d max:%d mean:%lf.\n", - (compositelessObj?"less set":""),compName,expCount,(expCount != 1?"s":""),expMissing,MDB_VAR_ENCODE_EXP_ID,expMin,expMax,((double)expObjsCount/expCount)); + { + printf("Composite%s '%s' has %d recognizable experiment%s with %d objects needing %s", + (compositelessObj?"less set":""),compName,expCount,(expCount != 1?"s":""),expMissing,MDB_VAR_ENCODE_EXP_ID); + if (accMissing > 0) + printf(" and %d objects needing %s",accMissing,MDB_VAR_DCC_ACCESSION); + printf(" updated.\n objects/experiment: min:%d max:%d mean:%lf.\n",expMin,expMax,((double)expObjsCount/expCount)); + } if (edvSortOrder != NULL) freeMem(edvSortOrder); slNameFreeList(compositeEdvs); } // Done with all composites dyStringFree(&dyVars); *pMdbObjs = mdbProcessedObs; return mdbUpdateObjs; } boolean mdbObjIsEncode(struct mdbObj *mdb)