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

Fix up the three frame func so it will reuse existing pep features and redo...

Fix up the three frame func so it will reuse existing pep features and redo their sequence for revcomping
parent 6794448b
No related branches found
No related tags found
No related merge requests found
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
* *
* Exported functions: See ZMap/zmapFeature.h * Exported functions: See ZMap/zmapFeature.h
* HISTORY: * HISTORY:
* Last edited: Mar 2 11:50 2007 (rds) * Last edited: Mar 13 13:48 2007 (edgrif)
* Created: Tue Nov 2 2004 (rnc) * Created: Tue Nov 2 2004 (rnc)
* CVS info: $Id: zmapFeatureUtils.c,v 1.46 2007-03-02 14:57:21 rds Exp $ * CVS info: $Id: zmapFeatureUtils.c,v 1.47 2007-03-13 16:12:36 edgrif Exp $
*------------------------------------------------------------------- *-------------------------------------------------------------------
*/ */
...@@ -668,35 +668,49 @@ ZMapFeature zMapFeatureCopy(ZMapFeature feature) ...@@ -668,35 +668,49 @@ ZMapFeature zMapFeatureCopy(ZMapFeature feature)
} }
/* Creates the three reading frame translations for a piece of dna. Note that the function
* will create the three frame set and a feature for each translation if they don't
* already exist. If they do exist, the existing translation text is simply replaced
* with a new translation (e.g. after a revcomp the translation must be redone).
*
* This must be done on a per block basis as each block has its own dna. */
gboolean zMapFeatureBlockThreeFrameTranslation(ZMapFeatureBlock block, ZMapFeatureSet *set_out) gboolean zMapFeatureBlockThreeFrameTranslation(ZMapFeatureBlock block, ZMapFeatureSet *set_out)
{ {
gboolean result = FALSE ;
ZMapFeatureSet feature_set = NULL; ZMapFeatureSet feature_set = NULL;
ZMapFeatureTypeStyle style = NULL; ZMapFeatureTypeStyle style = NULL;
ZMapFeatureContext context = NULL; ZMapFeatureContext context = NULL;
GQuark style_id = 0, feature_set_id = 0; GQuark style_id = 0, feature_set_id = 0;
gboolean still_good = FALSE, created = FALSE; gboolean new_set = FALSE ;
feature_set_id = zMapFeatureSetCreateID(ZMAP_FIXED_STYLE_3FT_NAME); feature_set_id = zMapFeatureSetCreateID(ZMAP_FIXED_STYLE_3FT_NAME);
style_id = zMapStyleCreateID(ZMAP_FIXED_STYLE_3FT_NAME); style_id = zMapStyleCreateID(ZMAP_FIXED_STYLE_3FT_NAME);
if(block->sequence.length)
still_good = TRUE;
if(!(context = (ZMapFeatureContext)(zMapFeatureGetParentGroup((ZMapFeatureAny)block, if (block->sequence.length)
ZMAPFEATURE_STRUCT_CONTEXT)))) result = TRUE;
still_good = FALSE;
if((feature_set = (ZMapFeatureSet)(g_datalist_id_get_data(&(block->feature_sets), feature_set_id)))) if (!(context = (ZMapFeatureContext)(zMapFeatureGetParentGroup((ZMapFeatureAny)block, ZMAPFEATURE_STRUCT_CONTEXT))))
still_good = FALSE; /* We've already got one */ result = FALSE;
if (still_good && (style = zMapFindStyle(context->styles, style_id)) != NULL) /* If we don't have a 3 frame feature set then make one. */
if (result)
{ {
feature_set = zMapFeatureSetCreate(ZMAP_FIXED_STYLE_3FT_NAME, NULL); if (!(feature_set = (ZMapFeatureSet)(g_datalist_id_get_data(&(block->feature_sets), feature_set_id))))
feature_set->style = style; {
created = TRUE; if ((style = zMapFindStyle(context->styles, style_id)) != NULL)
{
feature_set = zMapFeatureSetCreate(ZMAP_FIXED_STYLE_3FT_NAME, NULL);
feature_set->style = style;
new_set = TRUE ;
}
else
result = FALSE;
}
else
style = feature_set->style ;
} }
if(still_good && feature_set) if (result && feature_set)
{ {
int i, frame_offset; int i, frame_offset;
char *seq = NULL, *f_name = NULL, *s_name; char *seq = NULL, *f_name = NULL, *s_name;
...@@ -709,33 +723,46 @@ gboolean zMapFeatureBlockThreeFrameTranslation(ZMapFeatureBlock block, ZMapFeatu ...@@ -709,33 +723,46 @@ gboolean zMapFeatureBlockThreeFrameTranslation(ZMapFeatureBlock block, ZMapFeatu
frame_offset = 0 - ZMAPFRAME_0; /* set this up ! */ frame_offset = 0 - ZMAPFRAME_0; /* set this up ! */
for(i = ZMAPFRAME_0; seq && *seq && i <= ZMAPFRAME_2; i++, seq++) for (i = ZMAPFRAME_0; seq && *seq && i <= ZMAPFRAME_2; i++, seq++)
{ {
threeft = zMapFeatureCreateEmpty(); f_name = g_strdup_printf("%s_frame_%d",
f_name = g_strdup_printf("%s_frame_%d",
g_quark_to_string(feature_set_id), g_quark_to_string(feature_set_id),
i); i);
pep = zMapPeptideCreateSafely(NULL, NULL, seq, NULL, FALSE); pep = zMapPeptideCreateSafely(NULL, NULL, seq, NULL, FALSE);
threeft->text = g_strdup(zMapPeptideSequence(pep)); /* For a new feature set we create new features, otherwise we simply replace the translation. */
if (new_set)
zMapFeatureAddStandardData(threeft, f_name, f_name, {
s_name, "sequence", threeft = zMapFeatureCreateEmpty();
ZMAPFEATURE_PEP_SEQUENCE, style,
i, zMapPeptideLength(pep) * 3 + i, zMapFeatureAddStandardData(threeft, f_name, f_name,
FALSE, 0.0, s_name, "sequence",
ZMAPSTRAND_NONE, ZMAPPHASE_NONE); ZMAPFEATURE_PEP_SEQUENCE, style,
i, zMapPeptideLength(pep) * 3 + i,
zMapFeatureSetAddFeature(feature_set, threeft); FALSE, 0.0,
ZMAPSTRAND_NONE, ZMAPPHASE_NONE);
zMapFeatureSetAddFeature(feature_set, threeft);
}
else
{
threeft = zMapFeatureSetGetFeatureByID(feature_set, g_quark_from_string(f_name)) ;
zMapAssert(threeft) ;
g_free(threeft->text) ;
}
threeft->text = g_strdup(zMapPeptideSequence(pep)) ;
zMapPeptideDestroy(pep) ;
} }
} }
if(set_out) if (set_out)
*set_out = feature_set; *set_out = feature_set;
return created; return result ;
} }
......
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