From e58d5a56b3f3595be8427e1a8f9e78f3cc2a74c2 Mon Sep 17 00:00:00 2001
From: edgrif <edgrif>
Date: Wed, 18 Aug 2010 09:16:53 +0000
Subject: [PATCH] add function to test whether an alignment is gapped.

---
 src/include/ZMap/zmapFeature.h |  5 +++--
 src/zmapFeature/zmapFeature.c  | 33 +++++++++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/include/ZMap/zmapFeature.h b/src/include/ZMap/zmapFeature.h
index 792107b96..f16a85996 100755
--- a/src/include/ZMap/zmapFeature.h
+++ b/src/include/ZMap/zmapFeature.h
@@ -25,9 +25,9 @@
  * Description: Data structures describing a sequence feature.
  *
  * HISTORY:
- * Last edited: Aug 11 09:47 2010 (edgrif)
+ * Last edited: Aug 17 08:35 2010 (edgrif)
  * Created: Fri Jun 11 08:37:19 2004 (edgrif)
- * CVS info:   $Id: zmapFeature.h,v 1.178 2010-08-11 08:47:36 edgrif Exp $
+ * CVS info:   $Id: zmapFeature.h,v 1.179 2010-08-18 09:16:53 edgrif Exp $
  *-------------------------------------------------------------------
  */
 #ifndef ZMAP_FEATURE_H
@@ -782,6 +782,7 @@ gboolean zMapFeatureAddAlignmentData(ZMapFeature feature,
 				     ZMapPhase target_phase,
 				     GArray *gaps, unsigned int align_error,
 				     gboolean has_local_sequence) ;
+gboolean zMapFeatureAlignmentIsGapped(ZMapFeature feature) ;
 gboolean zMapFeatureAddAssemblyPathData(ZMapFeature feature,
 					int length, ZMapStrand strand, GArray *path) ;
 gboolean zMapFeatureSetCoords(ZMapStrand strand, int *start, int *end,
diff --git a/src/zmapFeature/zmapFeature.c b/src/zmapFeature/zmapFeature.c
index 0f35b3e59..894ef1517 100755
--- a/src/zmapFeature/zmapFeature.c
+++ b/src/zmapFeature/zmapFeature.c
@@ -28,9 +28,9 @@
  *
  * Exported functions: See zmapView_P.h
  * HISTORY:
- * Last edited: Aug  5 15:01 2010 (edgrif)
+ * Last edited: Aug 17 08:42 2010 (edgrif)
  * Created: Fri Jul 16 13:05:58 2004 (edgrif)
- * CVS info:   $Id: zmapFeature.c,v 1.132 2010-08-09 09:04:30 edgrif Exp $
+ * CVS info:   $Id: zmapFeature.c,v 1.133 2010-08-18 09:16:53 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -832,6 +832,35 @@ gboolean zMapFeatureAddAlignmentData(ZMapFeature feature,
   return result ;
 }
 
+/* Returns TRUE if alignment is gapped, FALSE otherwise. NOTE that sometimes
+ * we are passed data for an alignment feature which must represent a gapped
+ * alignment but we are not passed the gap data. This test all this. */
+gboolean zMapFeatureAlignmentIsGapped(ZMapFeature feature)
+{
+  gboolean result = FALSE ;
+
+  zMapAssert(zMapFeatureIsValidFull(feature, ZMAPFEATURE_STRUCT_FEATURE)) ;
+
+  if (feature->type == ZMAPSTYLE_MODE_ALIGNMENT)
+    {
+      int ref_length, match_length ;
+
+      ref_length = (feature->x2 - feature->x1) + 1 ;
+
+      match_length = (feature->feature.homol.y2 - feature->feature.homol.y1) + 1 ;
+      if (feature->feature.homol.type != ZMAPHOMOL_N_HOMOL)
+	match_length *= 3 ;
+
+      if (ref_length != match_length)
+	result = TRUE ;
+    }
+
+  return result ;
+}
+
+
+
+
 /*!
  * Adds assembly path data to a feature.
  *  */
-- 
GitLab