From 62a95fb3406aa98450369513bfd824c996dee201 Mon Sep 17 00:00:00 2001 From: mh17 <mh17> Date: Mon, 8 Feb 2010 18:13:23 +0000 Subject: [PATCH] restored partial sequence display (not starting from 1) --- src/include/ZMap/zmapFeature.h | 42 ++++++- src/zmapFeature/zmapFeatureContext.c | 42 +++---- src/zmapFeature/zmapFeature_P.h | 24 ++-- src/zmapServer/pipe/pipeServer.c | 43 ++++--- src/zmapServer/zmapServerProtocolHandler.c | 16 ++- src/zmapWindow/zmapWindowDrawFeatures.c | 140 ++++++++++++++++----- src/zmapWindow/zmapWindowFeature.c | 9 +- src/zmapWindow/zmapWindowItemFactory.c | 51 ++++++-- src/zmapWindow/zmapWindowNavigator.c | 5 +- src/zmapWindow/zmapWindowState.c | 35 ++++-- 10 files changed, 295 insertions(+), 112 deletions(-) diff --git a/src/include/ZMap/zmapFeature.h b/src/include/ZMap/zmapFeature.h index 8a46de481..d9d8ce795 100755 --- a/src/include/ZMap/zmapFeature.h +++ b/src/include/ZMap/zmapFeature.h @@ -27,7 +27,7 @@ * HISTORY: * Last edited: Feb 5 11:25 2010 (edgrif) * Created: Fri Jun 11 08:37:19 2004 (edgrif) - * CVS info: $Id: zmapFeature.h,v 1.169 2010-02-05 11:44:21 edgrif Exp $ + * CVS info: $Id: zmapFeature.h,v 1.170 2010-02-08 18:13:23 mh17 Exp $ *------------------------------------------------------------------- */ #ifndef ZMAP_FEATURE_H @@ -185,6 +185,38 @@ typedef struct } ZMapMapBlockStruct, *ZMapMapBlock ; +/* + * Sequences and Block Coordinates + * + * In the context of displaying a single align with a single block, + * given a chromosome and a sequence from that to look at *we have: + * + * 1 X chromosome bases + * ============================= ZMapFeatureContext.parent_span.x1/x1 + * + * 1 Y our sequence + * ===================== ZMapFeatureContext.sequence_to_parent + * p1,p2 = 1,X and c1,c2 = 1,Y + * + * S E displayed block + * ============ ZMapFeatureBlockStruct.block_to_sequence + * q1,q2 = 1,Y and t1,t2 = S,E + * q_strand, t_strand + * + * We should always have parent_span set up, if not specified then it will be set to 1,Y. + * ZMap will always be run using a sequence of 1,Y; it will never start from a coordinate not equal to 1. + * Y may be specified as 0 in various places which signifies 'the end'. + * + * Start and end coordinates may be specified by command line args, from the main window, + * from a GFF file header, from other servers (eg ACEDB, DAS) and these will refer to the block + * coordinates not the sequence. + * + * Reverse complementing is a process that applies to blocks and this involves transforming + * the coordinates S,E in the context of the containing sequence 1,Y + */ + + + /* DO THESE STRUCTS NEED TO BE EXPOSED ? PROBABLY NOT....TO HIDE THEM WOULD REQUIRE @@ -269,9 +301,7 @@ typedef struct ZMapFeatureContextStruct_ GQuark parent_name ; /* Name of parent sequence (== sequence_name if no parent). */ - - int length ; /* total length of sequence. */ - +// int length ; /* total length of sequence. */ @@ -922,7 +952,7 @@ gboolean zMapFeatureListForeachDumperDestroy(gpointer dumper_data); gboolean zMapFeatureGetFeatureListExtent(GList *feature_list, int *start_out, int *end_out); -void zMapFeature3FrameTranslationRevComp(ZMapFeatureSet feature_set, int origin); +//void zMapFeature3FrameTranslationRevComp(ZMapFeatureSet feature_set, RevCompData cb_data); mh17: moved to zmapFeature_P.h char *zMapFeature3FrameTranslationFeatureName(ZMapFeatureSet feature_set, ZMapFrame frame); void zMapFeature3FrameTranslationPopulate(ZMapFeatureSet feature_set); gboolean zMapFeature3FrameTranslationCreateSet(ZMapFeatureBlock block, ZMapFeatureSet *set_out); @@ -974,7 +1004,7 @@ ZMapFeature zMapFeatureDNACreateFeature(ZMapFeatureBlock block, void zMapFeature3FrameTranslationSetCreateFeatures(ZMapFeatureSet feature_set, ZMapFeatureTypeStyle style); -void zMapFeature3FrameTranslationSetRevComp(ZMapFeatureSet feature_set, int origin); + GArray *zMapFeatureAnyAsXMLEvents(ZMapFeatureAny feature_any, /* ZMapFeatureXMLType xml_type */ diff --git a/src/zmapFeature/zmapFeatureContext.c b/src/zmapFeature/zmapFeatureContext.c index f09224e79..0e05e4e5b 100755 --- a/src/zmapFeature/zmapFeatureContext.c +++ b/src/zmapFeature/zmapFeatureContext.c @@ -29,7 +29,7 @@ * HISTORY: * Last edited: Nov 30 16:23 2009 (edgrif) * Created: Tue Jan 17 16:13:12 2006 (edgrif) - * CVS info: $Id: zmapFeatureContext.c,v 1.49 2009-12-02 16:30:04 edgrif Exp $ + * CVS info: $Id: zmapFeatureContext.c,v 1.50 2010-02-08 18:13:23 mh17 Exp $ *------------------------------------------------------------------- */ @@ -47,12 +47,6 @@ #define ZMAP_CONTEXT_EXEC_RECURSE_OK (ZMAP_CONTEXT_EXEC_STATUS_OK | ZMAP_CONTEXT_EXEC_STATUS_OK_DELETE) #define ZMAP_CONTEXT_EXEC_RECURSE_FAIL (~ ZMAP_CONTEXT_EXEC_RECURSE_OK) -typedef struct -{ - GData *styles ; - int end ; -} RevCompDataStruct, *RevCompData ; - typedef struct { /* Input dna string, note that start != 1 where we are looking at a sub-part of an assembly @@ -80,12 +74,12 @@ typedef struct }ContextExecuteStruct, *ContextExecute; -static void revCompFeature(ZMapFeature feature, int end_coord); +static void revCompFeature(ZMapFeature feature, int start_coord, int end_coord); static ZMapFeatureContextExecuteStatus revCompFeaturesCB(GQuark key, gpointer data, gpointer user_data, char **error_out); -static void revcompSpan(GArray *spans, int seq_end) ; +static void revcompSpan(GArray *spans, int start_coord, int seq_end) ; static char *fetchBlockDNAPtr(ZMapFeatureAny feature, ZMapFeatureBlock *block_out) ; static gboolean coordsInBlock(ZMapFeatureBlock block, int *start_out, int *end_out) ; @@ -135,9 +129,11 @@ void zMapFeatureReverseComplement(ZMapFeatureContext context, GData *styles) cb_data.styles = styles ; +printf("\nReverseComplement\n"); /* Get this first...Then swop */ - cb_data.end = context->sequence_to_parent.c2 ; - zmapFeatureSwop(Coord, context->sequence_to_parent.p1, context->sequence_to_parent.p2) ; + // mh17: this should really be block->block_to_sequence.q1,q2 + cb_data.start = context->sequence_to_parent.c1 ; + cb_data.end = context->sequence_to_parent.c2 ; /* Because this doesn't allow for execution at context level ;( */ zMapFeatureContextExecute((ZMapFeatureAny)context, @@ -859,7 +855,7 @@ static ZMapFeatureContextExecuteStatus revCompFeaturesCB(GQuark key, zMapDNAReverseComplement(feature_block->sequence.sequence, feature_block->sequence.length) ; } - zmapFeatureRevComp(Coord, cb_data->end, + zmapFeatureRevComp(Coord, cb_data->start, cb_data->end, feature_block->block_to_sequence.t1, feature_block->block_to_sequence.t2) ; } @@ -872,7 +868,7 @@ static ZMapFeatureContextExecuteStatus revCompFeaturesCB(GQuark key, /* Now redo the 3 frame translations from the dna (if they exist). */ if(feature_set->original_id == g_quark_from_string(ZMAP_FIXED_STYLE_3FT_NAME)) - zMapFeature3FrameTranslationSetRevComp(feature_set, cb_data->end); + zMapFeature3FrameTranslationSetRevComp(feature_set, cb_data); } break; case ZMAPFEATURE_STRUCT_FEATURE: @@ -881,7 +877,7 @@ static ZMapFeatureContextExecuteStatus revCompFeaturesCB(GQuark key, feature_ft = (ZMapFeature)feature_any; - revCompFeature(feature_ft, cb_data->end); + revCompFeature(feature_ft, cb_data->start, cb_data->end); break; } @@ -896,7 +892,7 @@ static ZMapFeatureContextExecuteStatus revCompFeaturesCB(GQuark key, return status; } -static void revcompSpan(GArray *spans, int seq_end) +static void revcompSpan(GArray *spans, int seq_start, int seq_end) { int i ; @@ -906,7 +902,7 @@ static void revcompSpan(GArray *spans, int seq_end) span = &g_array_index(spans, ZMapSpanStruct, i) ; - zmapFeatureRevComp(Coord, seq_end, span->x1, span->x2) ; + zmapFeatureRevComp(Coord, seq_start, seq_end, span->x1, span->x2) ; } @@ -914,11 +910,11 @@ static void revcompSpan(GArray *spans, int seq_end) } -static void revCompFeature(ZMapFeature feature, int end_coord) +static void revCompFeature(ZMapFeature feature, int start_coord, int end_coord) { zMapAssert(feature); - zmapFeatureRevComp(Coord, end_coord, feature->x1, feature->x2) ; + zmapFeatureRevComp(Coord, start_coord, end_coord, feature->x1, feature->x2) ; if (feature->strand == ZMAPSTRAND_FORWARD) feature->strand = ZMAPSTRAND_REVERSE ; @@ -929,13 +925,13 @@ static void revCompFeature(ZMapFeature feature, int end_coord) && (feature->feature.transcript.exons || feature->feature.transcript.introns)) { if (feature->feature.transcript.exons) - revcompSpan(feature->feature.transcript.exons, end_coord) ; + revcompSpan(feature->feature.transcript.exons, start_coord, end_coord) ; if (feature->feature.transcript.introns) - revcompSpan(feature->feature.transcript.introns, end_coord) ; + revcompSpan(feature->feature.transcript.introns, start_coord, end_coord) ; if(feature->feature.transcript.flags.cds) - zmapFeatureRevComp(Coord, end_coord, + zmapFeatureRevComp(Coord, start_coord, end_coord, feature->feature.transcript.cds_start, feature->feature.transcript.cds_end); } @@ -950,7 +946,7 @@ static void revCompFeature(ZMapFeature feature, int end_coord) align = &g_array_index(feature->feature.homol.align, ZMapAlignBlockStruct, i) ; - zmapFeatureRevComp(Coord, end_coord, align->t1, align->t2) ; + zmapFeatureRevComp(Coord, start_coord, end_coord, align->t1, align->t2) ; } zMapFeatureSortGaps(feature->feature.homol.align) ; @@ -958,7 +954,7 @@ static void revCompFeature(ZMapFeature feature, int end_coord) else if (feature->type == ZMAPSTYLE_MODE_ASSEMBLY_PATH) { if (feature->feature.assembly_path.path) - revcompSpan(feature->feature.assembly_path.path, end_coord) ; + revcompSpan(feature->feature.assembly_path.path, start_coord, end_coord) ; } return ; diff --git a/src/zmapFeature/zmapFeature_P.h b/src/zmapFeature/zmapFeature_P.h index 0a609172f..3d45a3605 100755 --- a/src/zmapFeature/zmapFeature_P.h +++ b/src/zmapFeature/zmapFeature_P.h @@ -27,7 +27,7 @@ * HISTORY: * Last edited: May 10 08:06 2007 (edgrif) * Created: Wed Nov 24 11:01:24 2004 (edgrif) - * CVS info: $Id: zmapFeature_P.h,v 1.5 2007-05-30 14:05:52 edgrif Exp $ + * CVS info: $Id: zmapFeature_P.h,v 1.6 2010-02-08 18:13:23 mh17 Exp $ *------------------------------------------------------------------- */ #ifndef ZMAP_FEATURE_P_H @@ -46,20 +46,29 @@ typedef struct } ZMapFeatureStr2EnumStruct, *ZMapFeatureStr2Enum ; +// mh17: needed in zmapFeature3Frame.c as well as FeatureContext.c +typedef struct +{ + GData *styles ; + int start; + int end ; +} RevCompDataStruct, *RevCompData ; + #define zmapFeatureSwop(TYPE, FIRST, SECOND) \ { TYPE tmp = (FIRST) ; (FIRST) = (SECOND) ; (SECOND) = tmp ; } -#define zmapFeatureInvert(COORD, SEQ_END) \ +#define zmapFeatureInvert(COORD, SEQ_START, SEQ_END) \ (COORD) = (SEQ_END) - (COORD) + 1 -#define zmapFeatureRevComp(TYPE, SEQ_END, COORD_1, COORD_2) \ - { \ - zmapFeatureSwop(TYPE, COORD_1, COORD_2) ; \ - zmapFeatureInvert(COORD_1, SEQ_END) ; \ - zmapFeatureInvert(COORD_2, SEQ_END) ; \ +// +#define zmapFeatureRevComp(TYPE, SEQ_START, SEQ_END, COORD_1, COORD_2) \ + { \ + zmapFeatureSwop(TYPE, COORD_1, COORD_2) ; \ + zmapFeatureInvert(COORD_1, SEQ_START, SEQ_END) ; \ + zmapFeatureInvert(COORD_2, SEQ_START, SEQ_END) ; \ } @@ -71,6 +80,7 @@ gboolean zmapStr2Enum(ZMapFeatureStr2Enum type_table, char *type_str, int *type_ ZMapFeatureAny zmapFeatureAnyCopy(ZMapFeatureAny orig_feature_any, GDestroyNotify destroy_cb) ; +void zMapFeature3FrameTranslationSetRevComp(ZMapFeatureSet feature_set, RevCompData cb_data); #endif /* !ZMAP_FEATURE_P_H */ diff --git a/src/zmapServer/pipe/pipeServer.c b/src/zmapServer/pipe/pipeServer.c index a7bf8654c..d0f031048 100755 --- a/src/zmapServer/pipe/pipeServer.c +++ b/src/zmapServer/pipe/pipeServer.c @@ -34,7 +34,7 @@ * HISTORY: * Last edited: Jan 14 10:10 2010 (edgrif) * Created: 2009-11-26 12:02:40 (mh17) - * CVS info: $Id: pipeServer.c,v 1.15 2010-01-27 15:03:03 mh17 Exp $ + * CVS info: $Id: pipeServer.c,v 1.16 2010-02-08 18:13:23 mh17 Exp $ *------------------------------------------------------------------- */ @@ -897,7 +897,7 @@ static ZMapServerResponseType destroyConnection(void *server_in) -/* +/* * --------------------- Internal routines. --------------------- */ @@ -915,24 +915,32 @@ static void addMapping(ZMapFeatureContext feature_context, ZMapGFFHeader header) * are several streams.... */ feature_context->parent_name = feature_context->sequence_name ; - feature_context->parent_span.x1 = header->features_start ; - feature_context->parent_span.x2 = header->features_end ; - /* I don't like having to do this right down here but user is allowed to specify "0" for * end coord meaning "to the end of the sequence" and this is where we know the end... */ - if(feature_block->block_to_sequence.t1 == 0) // in case seq range not pre-specified, don't anchor to 1 + + // refer to comment in zmapFeature.h 'Sequences and Block Coordinates' + // NB at time of writing parent_span not always initialised + feature_context->parent_span.x1 = 1; + if(feature_context->parent_span.x2 < header->features_end) + feature_context->parent_span.x2 = header->features_end ; + + // seq coords from parent sequence + feature_context->sequence_to_parent.p1 = header->features_start; + feature_context->sequence_to_parent.p2 = header->features_end; + + // seq coords for our sequence based from 1 + feature_context->sequence_to_parent.c1 = feature_block->block_to_sequence.q1 = 1; + feature_context->sequence_to_parent.c2 = feature_block->block_to_sequence.q2 + = header->features_end; + + if(feature_block->block_to_sequence.t1 == 0) + { feature_block->block_to_sequence.t1 = header->features_start ; - if (feature_block->block_to_sequence.t2 == 0) feature_block->block_to_sequence.t2 = header->features_end ; - - feature_context->sequence_to_parent.p1 = feature_context->sequence_to_parent.c1 - = feature_block->block_to_sequence.q1 = feature_block->block_to_sequence.t1 ; + } - feature_context->sequence_to_parent.p2 = feature_context->sequence_to_parent.c2 - = feature_block->block_to_sequence.q2 = feature_block->block_to_sequence.t2 ; +// feature_context->length = feature_context->sequence_to_parent.c2 - feature_context->sequence_to_parent.c1 + 1; - feature_context->length = feature_context->sequence_to_parent.c2 - feature_context->sequence_to_parent.c1 + 1; - return ; } @@ -1012,9 +1020,10 @@ static gboolean sequenceRequest(PipeServer server, ZMapGFFParser parser, GString /* The caller may only want a small part of the features in the stream so we set the * feature start/end from the block, not the gff stream start/end. */ zMapGFFSetFeatureClipCoords(parser, - feature_block->block_to_sequence.q1, - feature_block->block_to_sequence.q2) ; - + feature_block->block_to_sequence.t1, + feature_block->block_to_sequence.t2) ; + zMapGFFSetFeatureClip(parser,GFF_CLIP_ALL); // mh17: needs config added to server stanza + first = TRUE ; do { diff --git a/src/zmapServer/zmapServerProtocolHandler.c b/src/zmapServer/zmapServerProtocolHandler.c index c00a89ee0..eced6763c 100755 --- a/src/zmapServer/zmapServerProtocolHandler.c +++ b/src/zmapServer/zmapServerProtocolHandler.c @@ -27,7 +27,7 @@ * HISTORY: * Last edited: Jan 14 10:26 2010 (edgrif) * Created: Thu Jan 27 13:17:43 2005 (edgrif) - * CVS info: $Id: zmapServerProtocolHandler.c,v 1.53 2010-01-14 13:31:52 edgrif Exp $ + * CVS info: $Id: zmapServerProtocolHandler.c,v 1.54 2010-02-08 18:13:23 mh17 Exp $ *------------------------------------------------------------------- */ @@ -458,11 +458,15 @@ if(*slave_data) zMapLogMessage("req %s/%s %d",server->url->protocol,server->url- zMapAssert(g_hash_table_size(blocks) == 1) ; block = (ZMapFeatureBlock)(zMap_g_hash_table_nth(blocks, 0)) ; - block->block_to_sequence.q1 = block->block_to_sequence.t1 - = context->context->sequence_to_parent.c1 ; - block->block_to_sequence.q2 = block->block_to_sequence.t2 - = context->context->sequence_to_parent.c2 ; - + if(!block->block_to_sequence.t2) + { + // mh17: this happens before getFeatures? which is where the data gets set + // adding the if has no effect of course + block->block_to_sequence.q1 = block->block_to_sequence.t1 + = context->context->sequence_to_parent.c1 ; + block->block_to_sequence.q2 = block->block_to_sequence.t2 + = context->context->sequence_to_parent.c2 ; + } block->block_to_sequence.q_strand = block->block_to_sequence.t_strand = ZMAPSTRAND_FORWARD ; } diff --git a/src/zmapWindow/zmapWindowDrawFeatures.c b/src/zmapWindow/zmapWindowDrawFeatures.c index ffcc65dc8..c86161896 100755 --- a/src/zmapWindow/zmapWindowDrawFeatures.c +++ b/src/zmapWindow/zmapWindowDrawFeatures.c @@ -28,7 +28,7 @@ * HISTORY: * Last edited: Jan 28 01:16 2010 (roy) * Created: Thu Jul 29 10:45:00 2004 (rnc) - * CVS info: $Id: zmapWindowDrawFeatures.c,v 1.262 2010-01-27 12:38:31 rds Exp $ + * CVS info: $Id: zmapWindowDrawFeatures.c,v 1.263 2010-02-08 18:13:23 mh17 Exp $ *------------------------------------------------------------------- */ @@ -48,7 +48,7 @@ #define SCALEBAR_OFFSET 0.0 #define SCALEBAR_WIDTH 50.0 - +#define MH17_REVCOMP_DEBUG 1 /* parameters passed between the various functions drawing the features on the canvas, it's * simplest to cache the current stuff as we go otherwise the code becomes convoluted by having @@ -69,7 +69,7 @@ typedef struct _ZMapCanvasDataStruct * ORDERING/PLACEMENT MECHANISM.... */ /* Records current positional information. */ double curr_x_offset ; - //double curr_y_offset ; +// double curr_y_offset ; /* Records current canvas item groups, these are the direct parent groups of the display @@ -175,6 +175,8 @@ static FooCanvasGroup *separatorGetFeatureSetColumn(ZMapWindowContainerStrand se ZMapFeatureSet feature_set); +static gboolean contextGetMasterAlignSpan(ZMapFeatureContext context,int *start,int *end); + extern GTimer *view_timer_G ; static gboolean window_draw_context_debug_G = FALSE; @@ -234,8 +236,8 @@ void zmapWindowDrawFeatures(ZMapWindow window, FooCanvasItem *tmp_item = NULL; gboolean debug_containers = FALSE, root_created = FALSE; double x, y; - double ix1, ix2, iy1, iy2; /* initial root_group coords */ - +// double ix1, ix2, iy1, iy2; /* initial root_group coords */ + int seq_start,seq_end; zMapPrintTimer(NULL, "About to create canvas features") ; @@ -261,24 +263,36 @@ void zmapWindowDrawFeatures(ZMapWindow window, /* Must be reset each time because context will change as features get merged in. */ window->feature_context = full_context ; +#ifdef SHOW_PARENT_SPAN + //original code, window based from 1 window->seq_start = full_context->sequence_to_parent.c1 ; window->seq_end = full_context->sequence_to_parent.c2 ; +#else + // we want to display just the data in our block, not the surrounding sequence + contextGetMasterAlignSpan(full_context,&seq_start,&seq_end); + window->seq_start = seq_start; + window->seq_end = seq_end; +#endif + window->seqLength = zmapWindowExt(window->seq_start, window->seq_end) ; - /* Set the origin used for displaying coords.... + /* Set the origin used for displaying coords.... + * which must refer to the parent span to allow reverse strand coords to be calculated. * The "+ 2" is because we have to go from sequence_start == 1 to sequence_start == -1 * which is a shift of 2. */ if (window->display_forward_coords) { if (window->revcomped_features) - window->origin = window->seq_end + 2 ; + window->origin = full_context->sequence_to_parent.c2 + 2 ; else - window->origin = 1 ; + window->origin = 1; zmapWindowRulerCanvasSetOrigin(window->ruler, window->origin) ; } - +#ifdef MH17_REVCOMP_DEBUG + printf("drawFeatures window: %f-%f, %d, %d\n",window->seq_start,window->seq_end,window->origin,window->revcomped_features); +#endif zmapWindowZoomControlInitialise(window); /* Sets min/max/zf */ @@ -286,7 +300,7 @@ void zmapWindowDrawFeatures(ZMapWindow window, zmapWindowLongItemSetMaxZoom(window->long_items, zMapWindowGetZoomMax(window)) ; - window->min_coord = window->seq_start ; + window->min_coord = window->seq_start; window->max_coord = window->seq_end ; zmapWindowSeq2CanExt(&(window->min_coord), &(window->max_coord)) ; @@ -306,7 +320,9 @@ void zmapWindowDrawFeatures(ZMapWindow window, /* I have no idea why, but... */ /* Get the current scroll region */ - zmapWindowGetScrollRegion(window, &ix1, &iy1, &ix2, &iy2); + +// mh17: these are not used at all +// zmapWindowGetScrollRegion(window, &ix1, &iy1, &ix2, &iy2); if((tmp_item = zmapWindowFToIFindItemFull(window->context_to_item, 0, 0, 0, ZMAPSTRAND_NONE, ZMAPFRAME_NONE, 0))) @@ -333,7 +349,7 @@ void zmapWindowDrawFeatures(ZMapWindow window, &(window->colour_root), &(window->canvas_border)); - zmapWindowContainerGroupBackgroundSize(root_group, window->max_coord); + zmapWindowContainerGroupBackgroundSize(root_group, window->max_coord - window->min_coord); g_signal_connect(G_OBJECT(root_group), "destroy", G_CALLBACK(containerDestroyCB), window) ; @@ -1345,6 +1361,23 @@ static gboolean pick_forward_reverse_columns(ZMapWindow window, return found_one; } +static gboolean contextGetMasterAlignSpan(ZMapFeatureContext context,int *start,int *end) +{ + gboolean res = TRUE; + GHashTable *blocks = context->master_align->blocks ; + ZMapFeatureBlock block ; + + // refer to RT 158542 + zMapAssert(g_hash_table_size(blocks) == 1) ; // (currently we only ever have one) + + block = (ZMapFeatureBlock)(zMap_g_hash_table_nth(blocks, 0)) ; + if(start) *start = block->block_to_sequence.t1; + if(end) *end = block->block_to_sequence.t2; + + return(res); +} + + static ZMapFeatureContextExecuteStatus windowDrawContextCB(GQuark key_id, gpointer data, gpointer user_data, @@ -1389,18 +1422,25 @@ static ZMapFeatureContextExecuteStatus windowDrawContextCB(GQuark key_id, ZMapWindowContainerGroup align_parent; FooCanvasItem *align_hash_item; double x, y; + int start,end; feature_align = (ZMapFeatureAlignment)feature_any; - +#ifdef MH17_REVCOMP_DEBUG + printf("drawFeatures align"); +#endif /* record the full_context current align, not the diff align which will get destroyed! */ canvas_data->curr_alignment = zMapFeatureContextGetAlignmentByID(canvas_data->full_context, feature_any->unique_id) ; - /* THIS MUST GO.t...because we will have aligns that .sigh.do not start at 0 one day.... */ + /* THIS MUST GO....because we will have aligns that .sigh.do not start at 0 one day.... */ /* Always reset the aligns to start at y = 0. */ //canvas_data->curr_y_offset = 0.0 ; x = canvas_data->curr_x_offset ; - y = canvas_data->full_context->sequence_to_parent.c1 ; +// y = canvas_data->full_context->sequence_to_parent.c1 ; + contextGetMasterAlignSpan(canvas_data->full_context,&start,&end); // else we get everything offset by the start coord + y = start; +// canvas_data->curr_y_offset = start ; + my_foo_canvas_item_w2i(FOO_CANVAS_ITEM(canvas_data->curr_root_group), &x, &y) ; if ((align_hash_item = zmapWindowFToIFindItemFull(window->context_to_item, @@ -1460,21 +1500,27 @@ static ZMapFeatureContextExecuteStatus windowDrawContextCB(GQuark key_id, gboolean block_created = FALSE; feature_block = (ZMapFeatureBlock)feature_any; +#ifdef MH17_REVCOMP_DEBUG +printf("\ndrawFeatures block %d-%d",feature_block->block_to_sequence.t1,feature_block->block_to_sequence.t2); +#endif /* record the full_context current block, not the diff block which will get destroyed! */ canvas_data->curr_block = zMapFeatureAlignmentGetBlockByID(canvas_data->curr_alignment, feature_block->unique_id); /* Always set y offset to be top of current block. */ - // canvas_data->curr_y_offset = feature_block->block_to_sequence.t1 ; +// canvas_data->curr_y_offset = feature_block->block_to_sequence.t1 ; if ((block_hash_item = zmapWindowFToIFindItemFull(window->context_to_item, canvas_data->curr_alignment->unique_id, feature_block->unique_id, 0, ZMAPSTRAND_NONE, ZMAPFRAME_NONE, 0))) { - zMapAssert(ZMAP_IS_CONTAINER_GROUP(block_hash_item)); + zMapAssert(ZMAP_IS_CONTAINER_GROUP(block_hash_item)); block_parent = (ZMapWindowContainerGroup)(block_hash_item); +#ifdef MH17_REVCOMP_DEBUG + printf(" old"); +#endif } else { @@ -1488,6 +1534,9 @@ static ZMapFeatureContextExecuteStatus windowDrawContextCB(GQuark key_id, G_CALLBACK(containerDestroyCB), window) ; block_created = TRUE; +#ifdef MH17_REVCOMP_DEBUG + printf(" new"); +#endif zmapWindowContainerBlockAugment((ZMapWindowContainerBlock)block_parent, canvas_data->curr_block) ; @@ -1557,8 +1606,8 @@ static ZMapFeatureContextExecuteStatus windowDrawContextCB(GQuark key_id, zmapWindowContainerStrandAugment((ZMapWindowContainerStrand)reverse_group, ZMAPSTRAND_REVERSE); - zmapWindowContainerGroupBackgroundSize(reverse_group, - (double)feature_block->block_to_sequence.t2); + zmapWindowContainerGroupBackgroundSize(reverse_group, + (double)(feature_block->block_to_sequence.t2 - feature_block->block_to_sequence.t1)); g_signal_connect(G_OBJECT(zmapWindowContainerGetBackground(reverse_group)), "event", G_CALLBACK(strandBoundingBoxEventCB), @@ -1571,15 +1620,16 @@ static ZMapFeatureContextExecuteStatus windowDrawContextCB(GQuark key_id, if ((block_created == TRUE) || (strand_separator = (ZMapWindowContainerGroup)zmapWindowContainerBlockGetContainerSeparator(container_block)) == NULL) + { - strand_separator = zmapWindowContainerGroupCreate(canvas_data->curr_block_group, + strand_separator = zmapWindowContainerGroupCreate(canvas_data->curr_block_group, ZMAPCONTAINER_LEVEL_STRAND, window->config.column_spacing, &(window->colour_separator), &(canvas_data->window->canvas_border)); - zmapWindowContainerStrandSetAsSeparator((ZMapWindowContainerStrand)strand_separator); - zmapWindowContainerGroupBackgroundSize(strand_separator, - (double)feature_block->block_to_sequence.t2); + zmapWindowContainerStrandSetAsSeparator((ZMapWindowContainerStrand)strand_separator); + zmapWindowContainerGroupBackgroundSize(strand_separator, + (double) (feature_block->block_to_sequence.t2 - feature_block->block_to_sequence.t1)); } if ((block_created == TRUE) || @@ -1592,8 +1642,8 @@ static ZMapFeatureContextExecuteStatus windowDrawContextCB(GQuark key_id, &(canvas_data->window->canvas_border)); zmapWindowContainerStrandAugment((ZMapWindowContainerStrand)forward_group, ZMAPSTRAND_FORWARD); - zmapWindowContainerGroupBackgroundSize(forward_group, - (double)feature_block->block_to_sequence.t2); + zmapWindowContainerGroupBackgroundSize(forward_group, + (double)(feature_block->block_to_sequence.t2 - feature_block->block_to_sequence.t1)); g_signal_connect(G_OBJECT(zmapWindowContainerGetBackground(forward_group)), "event", G_CALLBACK(strandBoundingBoxEventCB), @@ -1627,6 +1677,9 @@ static ZMapFeatureContextExecuteStatus windowDrawContextCB(GQuark key_id, * copy of the view context's feature set. It should also get * destroyed with the diff context, so be warned. */ feature_set = (ZMapFeatureSet)feature_any; +#ifdef MH17_REVCOMP_DEBUG +printf("drawFeatures set %s",feature_set->description); +#endif if (feature_set_matches_frame_drawing_mode(window, canvas_data, canvas_data->curr_set, &frame_start, &frame_end)) @@ -1650,6 +1703,10 @@ static ZMapFeatureContextExecuteStatus windowDrawContextCB(GQuark key_id, zMapWindowContainerFeatureSetMarkUnsorted(ZMAP_CONTAINER_FEATURESET(tmp_forward)); if(tmp_reverse) zMapWindowContainerFeatureSetMarkUnsorted(ZMAP_CONTAINER_FEATURESET(tmp_reverse)); +#ifdef MH17_REVCOMP_DEBUG + printf("\nFeatures...\n"); +#endif + zmapWindowDrawFeatureSet(window, canvas_data->styles, @@ -1670,7 +1727,7 @@ static ZMapFeatureContextExecuteStatus windowDrawContextCB(GQuark key_id, break; } - case ZMAPFEATURE_STRUCT_INVALID: + case ZMAPFEATURE_STRUCT_INVALID: default: { status = ZMAP_CONTEXT_EXEC_STATUS_ERROR; @@ -1678,6 +1735,10 @@ static ZMapFeatureContextExecuteStatus windowDrawContextCB(GQuark key_id, break; } } +#ifdef MH17_REVCOMP_DEBUG + if(feature_type != ZMAPFEATURE_STRUCT_FEATURE) + printf(" -> status %s\n",status == ZMAP_CONTEXT_EXEC_STATUS_OK ? "OK" : "error"); +#endif return status; } @@ -1841,7 +1902,7 @@ static FooCanvasGroup *createColumnFull(ZMapWindowContainerFeatures parent_group zmapWindowContainerGroupChildRedrawRequired(container, FALSE) ; /* Make sure group covers whole span in y direction. */ - zmapWindowContainerGroupBackgroundSize(container, bot) ; + zmapWindowContainerGroupBackgroundSize(container, bot-top) ; /* THIS WOULD ALL GO IF WE DIDN'T ADD EMPTY COLS...... */ /* We can't set the ITEM_FEATURE_DATA as we don't have the feature set at this point. @@ -1914,7 +1975,9 @@ static void ProcessFeature(gpointer key, gpointer data, gpointer user_data) FooCanvasItem *feature_item ; ZMapFeatureTypeStyle style ; - +#ifdef MH17_REVCOMP_DEBUG + printf("ProcessFeature %d-%d ",feature->x1,feature->x2); +#endif /* Do some filtering on frame and strand */ /* Find out which strand group the feature should be displayed in. */ @@ -1924,15 +1987,25 @@ static void ProcessFeature(gpointer key, gpointer data, gpointer user_data) * curr_forward_col or curr_reverse_col */ if ((display_strand == ZMAPSTRAND_FORWARD && !(featureset_data->curr_forward_col)) || (display_strand == ZMAPSTRAND_REVERSE && !(featureset_data->curr_reverse_col))) + { +#ifdef MH17_REVCOMP_DEBUG + printf("wrong strand 1\n"); +#endif return ; - + } + /* If we are doing frame specific display then don't display the feature if its the wrong * frame or its on the reverse strand and we aren't displaying reverse strand frames. */ if (featureset_data->frame != ZMAPFRAME_NONE && (featureset_data->frame != zmapWindowFeatureFrame(feature) || (!(window->show_3_frame_reverse) && display_strand == ZMAPSTRAND_REVERSE))) + { +#ifdef MH17_REVCOMP_DEBUG + printf("wrong strand 2\n"); +#endif return ; - + } + /* Get the correct column to draw into... */ if (display_strand == ZMAPSTRAND_FORWARD) { @@ -1946,6 +2019,9 @@ static void ProcessFeature(gpointer key, gpointer data, gpointer user_data) featureset_data->feature_count++; style = zMapFindStyle(featureset_data->styles, feature->style_id) ; +#ifdef MH17_REVCOMP_DEBUG + if(!style) printf("no style 1 "); +#endif if(style) style = zmapWindowContainerFeatureSetStyleFromStyle((ZMapWindowContainerFeatureSet)column_group, style) ; @@ -1954,6 +2030,10 @@ static void ProcessFeature(gpointer key, gpointer data, gpointer user_data) g_quark_to_string(feature->style_id), g_quark_to_string(feature->original_id)); +#ifdef MH17_REVCOMP_DEBUG + if(!style) printf("no style 2"); + printf("\n"); +#endif if(style) feature_item = zmapWindowFeatureDraw(window, style, (FooCanvasGroup *)column_group, feature) ; else diff --git a/src/zmapWindow/zmapWindowFeature.c b/src/zmapWindow/zmapWindowFeature.c index b8b97eb29..ddb5ff038 100755 --- a/src/zmapWindow/zmapWindowFeature.c +++ b/src/zmapWindow/zmapWindowFeature.c @@ -30,7 +30,7 @@ * HISTORY: * Last edited: Jan 22 11:23 2010 (edgrif) * Created: Mon Jan 9 10:25:40 2006 (edgrif) - * CVS info: $Id: zmapWindowFeature.c,v 1.172 2010-01-22 13:53:15 edgrif Exp $ + * CVS info: $Id: zmapWindowFeature.c,v 1.173 2010-02-08 18:13:24 mh17 Exp $ *------------------------------------------------------------------- */ @@ -52,6 +52,8 @@ #define PFETCH_FAILED_PREFIX "PFetch failed:" #define PFETCH_TITLE_FORMAT "ZMap - pfetch \"%s\"" +#define MH17_REVCOMP_DEBUG 1 + enum { ITEM_MENU_INVALID, @@ -502,7 +504,6 @@ FooCanvasItem *zmapWindowFeatureDraw(ZMapWindow window, ZMapFeatureBlock block ; ZMapFeatureSet set ; - /* Users will often not want to see what is on the reverse strand, style specifies what should * be shown. */ if ((zMapStyleIsStrandSpecific(style)) && @@ -510,6 +511,10 @@ FooCanvasItem *zmapWindowFeatureDraw(ZMapWindow window, { return NULL ; } +#ifdef MH17_REVCOMP_DEBUG + printf("FeatureDraw %d-%d\n",feature->x1,feature->x2); +#endif + /* These should be parameters, rather than continually fetch them, caller will almost certainly know these! */ set = (ZMapFeatureSet)zMapFeatureGetParentGroup((ZMapFeatureAny)feature, diff --git a/src/zmapWindow/zmapWindowItemFactory.c b/src/zmapWindow/zmapWindowItemFactory.c index 20d1ee0e7..ee94e53f7 100755 --- a/src/zmapWindow/zmapWindowItemFactory.c +++ b/src/zmapWindow/zmapWindowItemFactory.c @@ -30,9 +30,11 @@ * HISTORY: * Last edited: Jan 17 10:28 2010 (edgrif) * Created: Mon Sep 25 09:09:52 2006 (rds) - * CVS info: $Id: zmapWindowItemFactory.c,v 1.73 2010-01-22 17:33:53 mh17 Exp $ + * CVS info: $Id: zmapWindowItemFactory.c,v 1.74 2010-02-08 18:13:24 mh17 Exp $ *------------------------------------------------------------------- */ + +#define MH17_REVCOMP_DEBUG 1 #include <math.h> #include <string.h> @@ -285,12 +287,16 @@ FooCanvasItem *zmapWindowFToIFactoryRunSingle(ZMapWindowFToIFactory factory, ZMapFeatureTypeStyle style = NULL; ZMapStyleMode style_mode = ZMAPSTYLE_MODE_INVALID ; gboolean no_points_in_block = TRUE; - /* check here before they get called. I'd prefer to only do this - * once per factory rather than once per Run! */ +#if MH17_REVCOMP_DEBUG + printf("run_single "); +#endif + /* check here before they get called. I'd prefer to only do this + * once per factory rather than once per Run! */ zMapAssert(factory->user_funcs && factory->user_funcs->top_item_created); + #ifndef RDS_REMOVED_STATS // ZMapWindowItemFeatureSetData set_data = NULL; @@ -329,13 +335,17 @@ FooCanvasItem *zmapWindowFToIFactoryRunSingle(ZMapWindowFToIFactory factory, if (zMapStyleIsStrandSpecific(style) && (feature->strand == ZMAPSTRAND_REVERSE && !zMapStyleIsShowReverseStrand(style))) + { +#if MH17_REVCOMP_DEBUG + printf("not reverse\n"); +#endif goto undrawn; - + } /* Note: for object to _span_ "width" units, we start at zero and end at "width". */ limits[0] = 0.0; - limits[1] = (double)(block->block_to_sequence.q1); + limits[1] = (double)(block->block_to_sequence.t1); limits[2] = zMapStyleGetWidth(style); - limits[3] = (double)(block->block_to_sequence.q2); + limits[3] = (double)(block->block_to_sequence.t2); /* Set these to this for normal main window use. */ points[0] = 0.0; @@ -346,8 +356,13 @@ FooCanvasItem *zmapWindowFToIFactoryRunSingle(ZMapWindowFToIFactory factory, /* inline static void normalSizeReq(ZMapFeature f, ... ){ return ; } */ /* inlined this should be nothing most of the time, question is can it be inlined?? */ if((no_points_in_block = (factory->user_funcs->feature_size_request)(feature, &limits[0], &points[0], factory->user_data)) == TRUE) + { +#if MH17_REVCOMP_DEBUG + printf("no points in block\n"); +#endif goto undrawn; - + } + style_mode = zMapStyleGetMode(style) ; @@ -374,6 +389,9 @@ FooCanvasItem *zmapWindowFToIFactoryRunSingle(ZMapWindowFToIFactory factory, break; } +#if MH17_REVCOMP_DEBUG + printf("not reverse\n"); +#endif case ZMAPSTYLE_MODE_ALIGNMENT: { @@ -540,6 +558,9 @@ FooCanvasItem *zmapWindowFToIFactoryRunSingle(ZMapWindowFToIFactory factory, if(factory->ftoi_hash) { +#ifdef MH17_REVCOMP_DEBUG + printf("FToIAddFeature %d-%d\n",feature->x1,feature->x2); +#endif status = zmapWindowFToIAddFeature(factory->ftoi_hash, align->unique_id, block->unique_id, @@ -547,6 +568,12 @@ FooCanvasItem *zmapWindowFToIFactoryRunSingle(ZMapWindowFToIFactory factory, strand, frame, feature->unique_id, item) ; } + else + { +#if MH17_REVCOMP_DEBUG + printf("ho hash\n"); +#endif + } status = (factory->user_funcs->top_item_created)(item, context, align, block, set, feature, factory->user_data); @@ -554,9 +581,19 @@ FooCanvasItem *zmapWindowFToIFactoryRunSingle(ZMapWindowFToIFactory factory, return_item = item; } + else + { +#if MH17_REVCOMP_DEBUG + printf("no item\n"); +#endif + } + } else { +#if MH17_REVCOMP_DEBUG + printf("unknown type\n"); +#endif zMapLogFatal("Feature %s is of unknown type: %d\n", (char *)g_quark_to_string(feature->original_id), feature->type) ; } diff --git a/src/zmapWindow/zmapWindowNavigator.c b/src/zmapWindow/zmapWindowNavigator.c index ce763db87..b7674e0bc 100755 --- a/src/zmapWindow/zmapWindowNavigator.c +++ b/src/zmapWindow/zmapWindowNavigator.c @@ -29,7 +29,7 @@ * HISTORY: * Last edited: Jan 23 22:54 2010 (roy) * Created: Wed Sep 6 11:22:24 2006 (rds) - * CVS info: $Id: zmapWindowNavigator.c,v 1.57 2010-01-24 10:23:57 rds Exp $ + * CVS info: $Id: zmapWindowNavigator.c,v 1.58 2010-02-08 18:13:24 mh17 Exp $ *------------------------------------------------------------------- */ @@ -1006,7 +1006,8 @@ static void createColumnCB(gpointer data, gpointer user_data) container_background = zmapWindowContainerGetBackground(draw_data->container_feature_set); zmapWindowContainerGroupBackgroundSize(draw_data->container_feature_set, - draw_data->current_block->block_to_sequence.t2 * draw_data->navigate->scaling_factor); + (draw_data->current_block->block_to_sequence.t2 - draw_data->current_block->block_to_sequence.t1) + * draw_data->navigate->scaling_factor); /* scale doesn't need this. */ if(set_id != g_quark_from_string(ZMAP_FIXED_STYLE_SCALE_NAME)) diff --git a/src/zmapWindow/zmapWindowState.c b/src/zmapWindow/zmapWindowState.c index d329c1dd0..efdab4ebc 100755 --- a/src/zmapWindow/zmapWindowState.c +++ b/src/zmapWindow/zmapWindowState.c @@ -29,7 +29,7 @@ * HISTORY: * Last edited: Jan 22 12:12 2010 (edgrif) * Created: Mon Jun 11 09:49:16 2007 (rds) - * CVS info: $Id: zmapWindowState.c,v 1.24 2010-01-22 13:56:24 edgrif Exp $ + * CVS info: $Id: zmapWindowState.c,v 1.25 2010-02-08 18:13:24 mh17 Exp $ *------------------------------------------------------------------- */ @@ -417,13 +417,28 @@ gboolean zmapWindowStateGetScrollRegion(ZMapWindowState state, /* INTERNAL */ -static void rev_comp_about_origin(int origin, double *a, double *b) +static void rev_comp_region(ZMapWindow window, double *a, double *b) { - double tp; /* temp */ +/* + * rev comp'd coords are based on sequence end (the new origin) + * these are displayed as -ve numbers via some calcultions in zmapWindowUtils.c + */ + ZMapMapBlock p2s; + + /* RevComp applies to a block not a window or featurecontext + * but for the momwnt we only handle one align and one block + * So we can get the block query sequence coord from here as + * they are the same as the sequence_to_parent child coordinates + * ref to RT 158542 + */ + p2s = &window->feature_context->sequence_to_parent; + + if(a && b) { - *a = origin - *a; - *b = origin - *b; + double tp; /* temp */ + *a = p2s->c2 + 1 - *a; + *b = p2s->c2 + 1 - *b; tp = *a; *a = *b; *b = tp; @@ -438,9 +453,7 @@ static void state_mark_restore(ZMapWindow window, ZMapWindowMark mark, ZMapWindo if(window->revcomped_features != restore.rev_comp_state) { - double seq_length; - seq_length = window->seqLength + 1; /* seqToExtent */ - rev_comp_about_origin(seq_length, &(restore.y1), &(restore.y2)); + rev_comp_region(window, &(restore.y1), &(restore.y2)); } if(serialized->item.align_id != 0 && serialized->item.feature_id != 0) @@ -507,15 +520,13 @@ static void state_position_restore(ZMapWindow window, ZMapWindowPositionStruct * if(window->revcomped_features != position->rev_comp_state) { - int seq_length; double tmp; - /* we need to swap positions in the position struct... */ - seq_length = window->seqLength + 1; /* seqToExtent */ if(window_state_debug_G) print_position(position, "state_position_restore rev-comp status switched! reversing position..."); - rev_comp_about_origin(seq_length, &(new_position.scroll_y1), &(new_position.scroll_y2)); + rev_comp_region(window, &(new_position.scroll_y1), &(new_position.scroll_y2)); + #ifdef RDS_DONT_INCLUDE new_position.scroll_y1 = seq_length - position->scroll_y1; new_position.scroll_y2 = seq_length - position->scroll_y2; -- GitLab