Skip to content
Snippets Groups Projects
Commit 7ea33284 authored by edgrif's avatar edgrif
Browse files

add function from zmapView.c and generalise to one that takes strings of words...

add function from zmapView.c and generalise to one that takes strings of words and makes context ids from them.
parent a173c78c
No related branches found
No related tags found
No related merge requests found
......@@ -25,9 +25,9 @@
* Description: Data structures describing a sequence feature.
*
* HISTORY:
* Last edited: Mar 2 11:50 2007 (rds)
* Last edited: Mar 12 09:11 2007 (edgrif)
* Created: Fri Jun 11 08:37:19 2004 (edgrif)
* CVS info: $Id: zmapFeature.h,v 1.116 2007-03-02 14:27:31 rds Exp $
* CVS info: $Id: zmapFeature.h,v 1.117 2007-03-12 12:26:37 edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_FEATURE_H
......@@ -622,6 +622,9 @@ void zMapFeatureContextDestroy(ZMapFeatureContext context, gboolean free_data) ;
/* THOSE IN FEATURECONTEXT.C */
GList *zMapFeatureString2QuarkList(char *string_list) ;
void zMapFeatureContextExecute(ZMapFeatureAny feature_any,
ZMapFeatureStructType stop,
ZMapGDataRecurseFunc callback,
......
......@@ -27,9 +27,9 @@
*
* Exported functions: See ZMap/zmapFeature.h
* HISTORY:
* Last edited: Feb 27 16:00 2007 (rds)
* Last edited: Mar 12 09:11 2007 (edgrif)
* Created: Tue Jan 17 16:13:12 2006 (edgrif)
* CVS info: $Id: zmapFeatureContext.c,v 1.19 2007-03-02 14:29:54 rds Exp $
* CVS info: $Id: zmapFeatureContext.c,v 1.20 2007-03-12 12:26:37 edgrif Exp $
*-------------------------------------------------------------------
*/
......@@ -223,6 +223,46 @@ char *zMapFeatureGetTranscriptDNA(ZMapFeatureContext context, ZMapFeature transc
}
/* Take a string containing space separated context names (e.g. perhaps a list
* of featuresets: "coding fgenes codon") and convert it to a list of
* proper context id quarks. */
GList *zMapFeatureString2QuarkList(char *string_list)
{
GList *context_quark_list = NULL ;
char *list_pos = NULL ;
char *next_context = NULL ;
char *target ;
target = string_list ;
do
{
GQuark context_id ;
if (next_context)
{
target = NULL ;
context_id = zMapStyleCreateID(next_context) ;
context_quark_list = g_list_append(context_quark_list, GUINT_TO_POINTER(context_id)) ;
}
else
list_pos = target ;
}
while (((list_pos && nextIsQuoted(&list_pos))
&& (next_context = strtok_r(target, "\"", &list_pos)))
|| (next_context = strtok_r(target, " \t", &list_pos))) ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
zMap_g_quark_list_print(context_quark_list) ; /* debug.... */
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
return context_quark_list ;
}
/*!
* \brief A similar call to g_datalist_foreach. However there are a number of differences.
*
......@@ -883,3 +923,34 @@ static void doFeatureAnyCB(ZMapFeatureAny any_feature, gpointer user_data)
}
#endif
/* Look through string to see if next non-space char is a quote mark, if it is return TRUE
* and set *text to point to the quote mark, otherwise return FALSE and leave *text unchanged. */
static gboolean nextIsQuoted(char **text)
{
gboolean quoted = FALSE ;
char *text_ptr = *text ;
while (*text_ptr)
{
if (!(g_ascii_isspace(*text_ptr)))
{
if (*text_ptr == '"')
{
quoted = TRUE ;
*text = text_ptr ;
}
break ;
}
text_ptr++ ;
}
return quoted ;
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment