src/hg/instinct/lib/heatmapUtility.c 1.6
1.6 2009/06/04 03:42:49 jsanborn
added copyright notices, removed cluster library
Index: src/hg/instinct/lib/heatmapUtility.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/lib/heatmapUtility.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -b -B -U 1000000 -r1.5 -r1.6
--- src/hg/instinct/lib/heatmapUtility.c 21 Nov 2008 19:46:09 -0000 1.5
+++ src/hg/instinct/lib/heatmapUtility.c 4 Jun 2009 03:42:49 -0000 1.6
@@ -1,97 +1,101 @@
+/********************************************************************************/
+/* Copyright 2007-2009 -- The Regents of the University of California */
+/********************************************************************************/
+
/* utilities */
#include "common.h"
#include "hash.h"
#include "dystring.h"
/* Return a string from slName List,
* comma separated, each item in list is in double-quote
* free return pointer after use */
char *sqlStrFromSlNameList(struct slName *list)
{
if (!list)
return NULL;
struct dyString *dy=newDyString(1024);
int i=0, N= slCount(list);
struct slName *sl;
for (sl=list, i=0 ; i<N-1 ; i++, sl= sl->next)
{
dyStringPrintf(dy, "\"%s\",", sl->name);
}
dyStringPrintf(dy, "\"%s\"", sl->name);
char *str = cloneString(dy->string);
dyStringFree(&dy);
return str;
}
/* Return a string from slName List,
* comma separated */
char *strFromSlNameList(struct slName *list)
{
if (!list)
return NULL;
struct dyString *dy=newDyString(1024);
int i=0, N= slCount(list);
struct slName *sl;
for (sl=list, i=0 ; i<N-1 ; i++, sl= sl->next)
{
dyStringPrintf(dy, "%s,", sl->name);
}
dyStringPrintf(dy, "%s", sl->name);
return dy->string;
}
struct slName *slNameListFromStringTrimWhiteSpaces (char *s, char delimiter)
/* Return list of slNames gotten from parsing delimited string.
* The final delimiter is optional. a,b,c and a,b,c, are equivalent
* for comma-delimited lists. */
{
char *e;
struct slName *list = NULL, *el;
while (s != NULL && s[0] != 0)
{
e = strchr(s, delimiter);
if (e == NULL)
{
el = slNameNew(trimSpaces(s));
}
else
{
el = slNameNewN(s, e-s);
el = slNameNew(trimSpaces(el->name));
e += 1;
}
slAddHead(&list, el);
s = e;
}
slReverse(&list);
return list;
}
char *cleanUpMemberStr(char* varText)
{
struct slName *slList=NULL, *lineList=NULL, *fList =NULL;
struct slName *sl, *sl1;
if (isNotEmpty(varText) )
{
fList = slNameListFromStringTrimWhiteSpaces(varText,'\n');
for (sl=fList; sl; sl=sl->next)
{
lineList = slNameListFromStringTrimWhiteSpaces(sl->name,',');
for (sl1 = lineList; sl1; sl1=sl1->next)
{
slNameAddHead(&slList, sl1->name);
}
}
slReverse(&slList);
return slNameListToString(slList, ',');
}
else
return NULL;
}