Exemplo n.º 1
0
struct taggedFile *taggedFileForComposite(struct composite *composite, struct hash *metaHash)
/* Return a taggedFile for every file in the composite. */
{
struct slRef *manRefList = composite->manRefList;
struct taggedFile *tf, *tfList = NULL;
struct slRef *ref;
for (ref = manRefList; ref != NULL; ref = ref->next)
    {
    /* Wrap up tags and manifest together, including a bonus tag or two from manifest. */
    struct encode2Manifest *man = ref->val;
    struct meta *meta = hashMustFindVal(metaHash, man->experiment);
    AllocVar(tf);
    tf->manifest = man;
    slAddHead(&tfList, tf);
    struct metaTagVal *s, *d;
    for (s = meta->tagList; s != NULL; s = s->next)
        {
	d = metaTagValNew(s->tag, s->val);
	slAddHead(&tf->tagList, d);
	}
    d = metaTagValNew("replicate", man->replicate);
    slAddHead(&tf->tagList, d);
    }
return tfList;
}
void encode2MetaPatchRenamed(char *inputMeta, char *patchFile, char *outputMeta)
/* encode2MetaPatchRenamed - Patch in renamed files (with same metadata) to encode2Meta. */
{
struct meta *metaList = metaLoadAll(inputMeta, NULL, NULL, FALSE, FALSE);
verbose(1, "%d in metaList\n", slCount(metaList));
struct patch *patch, *patchList = patchLoadAll(patchFile);
verbose(1, "%d in patchList\n", slCount(patchList));
for (patch =  patchList; patch != NULL; patch = patch->next)
    {
    verbose(2, "patching %s\n", patch->source);
    struct meta *meta = metaFindFirstMatch(metaList, "fileName", patch->source);
    if (meta == NULL)
	{
        verbose(2, "Can't find %s in %s", patch->source, inputMeta);
	continue;
	}
    struct meta *parent = meta->parent;
    assert(parent != NULL);
    boolean multiPatch = (slCount(patch->destList) > 1);
    if (multiPatch)
        {
	struct meta **oldSpot = &meta->children;
	struct slName *dest;
	int destId = 0;
	for (dest = patch->destList; dest != NULL; dest = dest->next)
	    {
	    /* Make up new object name if patching in more than one new thing. */
	    char metaObjName[PATH_LEN];
	    safef(metaObjName, sizeof(metaObjName), "%sSub%d", meta->name, ++destId);

	    /* Create subobject. */
	    struct meta *sub;
	    AllocVar(sub);
	    sub->tagList = metaTagValNew("meta", metaObjName);
	    sub->name = sub->tagList->val;
	    sub->tagList->next = metaTagValNew("fileName", dest->name);

	    /* And integrate into tree. */
	    sub->parent = meta;
	    sub->next = *oldSpot;
	    *oldSpot = sub;
	    oldSpot = &sub->next;
	    }
	/* Remove fileName element from parent. */
	meta->tagList = metaTagValListRemove(meta->tagList, "fileName"); 
	}
    else
        {
	metaAddTag(meta, "fileName", patch->destList->name);
	}
    }
metaWriteAll(metaList, outputMeta, 3, FALSE);
}
struct metaTagVal *metaTagValListClone(struct metaTagVal *oldList)
/* Make a list that is a clone of the current list, but in it's own memory. */
{
struct metaTagVal *newList = NULL, *mtv, *clone;
for (mtv = oldList; mtv != NULL; mtv  = mtv->next)
    {
    clone = metaTagValNew(mtv->tag, mtv->val);
    slAddHead(&newList, clone);
    }
slReverse(&newList);
return newList;
}
Exemplo n.º 4
0
void metaAddTag(struct meta *meta, char *tag, char *val)
/* Add tag to meta, replacing existing tag if any */
{
    /* First loop through to replace an existing tag. */
    struct metaTagVal *mtv;
    for (mtv = meta->tagList; mtv != NULL; mtv = mtv->next)
    {
        if (sameString(mtv->tag, tag))
        {
            freeMem(mtv->val);
            mtv->val = cloneString(val);
            return;
        }
    }
    /* If didn't make it then add new tag (at end) */
    mtv = metaTagValNew(tag, val);
    slAddTail(&meta->tagList, mtv);
}