Skip to content
Snippets Groups Projects
Commit 11ce4166 authored by gb10's avatar gb10
Browse files

Added 'source' column

parent 59f3830a
No related branches found
No related tags found
No related merge requests found
......@@ -347,7 +347,8 @@ static void parseGffColumns(GString *line_string, const int lineNum, const char
if (!tmpError)
{
msp->qname = g_ascii_strup(tokens[0], -1);
msp->style = getBlxStyle(tokens[1], styles, &tmpError);
msp->source = g_strdup(tokens[1]);
msp->style = getBlxStyle(msp->source, styles, &tmpError);
if (tmpError)
{
......
......@@ -88,7 +88,7 @@
01-10-05 Added getsseqsPfetch to fetch all missing sseqs in one go via socket connection to pfetch [RD]
* Created: Thu Feb 20 10:27:39 1993 (esr)
* CVS info: $Id: blxview.c,v 1.48 2010-07-08 12:06:47 gb10 Exp $
* CVS info: $Id: blxview.c,v 1.49 2010-07-09 11:49:36 gb10 Exp $
*-------------------------------------------------------------------
*/
......@@ -718,9 +718,8 @@ MSP* createNewMsp(MSP **lastMsp,
char *opts,
GError **error)
{
MSP *msp = (MSP *)g_malloc(sizeof(MSP));
MSP *msp = createEmptyMsp(lastMsp, mspList);
msp->next = NULL;
msp->type = mspType;
msp->score = score;
......@@ -731,27 +730,9 @@ MSP* createNewMsp(MSP **lastMsp,
msp->sname = g_ascii_strup(sName, -1);
msp->desc = NULL;
msp->style = NULL;
msp->fs = NULL;
msp->fsColor = 0;
msp->fsShape = BLXCURVE_BADSHAPE;
msp->xy = NULL;
msp->gaps = NULL;
intrangeSetValues(&msp->qRange, qStart, qEnd);
intrangeSetValues(&msp->sRange, sStart, sEnd);
#ifdef ACEDB
msp->key = 0;
#endif
/* ID will be calculated later */
msp->id = 0;
/* For exons and introns, the s strand is not applicable. We always want the exon
* to be in the same direction as the ref sequence, so set the match seq strand to be
* the same as the ref seq strand */
......@@ -767,19 +748,6 @@ MSP* createNewMsp(MSP **lastMsp,
/* Add/create a BlxSequence for this MSP's sequence name */
addBlxSequence(msp, sStrand, seqList, sequence, error);
/* Add it to the list */
if (!*mspList)
{
*mspList = msp; /* first entry in list */
}
if (*lastMsp)
{
(*lastMsp)->next = msp; /* add to end of list */
}
*lastMsp = msp;
if (error && *error)
{
prefixError(*error, "Error creating MSP (ref seq='%s' [%d - %d %s], match seq = '%s' [%d - %d %s]). ",
......@@ -826,6 +794,7 @@ MSP* createEmptyMsp(MSP **lastMsp, MSP **mspList)
msp->sframe[4] = '\0';
msp->desc = NULL;
msp->source = NULL;
msp->style = NULL;
......
......@@ -27,7 +27,7 @@
* Last edited: Aug 21 13:57 2009 (edgrif)
* * Aug 26 16:57 1999 (fw): added this header
* Created: Thu Aug 26 16:57:17 1999 (fw)
* CVS info: $Id: blxview.h,v 1.24 2010-07-08 10:14:02 gb10 Exp $
* CVS info: $Id: blxview.h,v 1.25 2010-07-09 11:49:36 gb10 Exp $
*-------------------------------------------------------------------
*/
#ifndef DEF_BLXVIEW_H
......@@ -219,8 +219,9 @@ typedef struct _MSP
IntRange sRange; /* the range of coords on the match sequence where the alignment lies */
char *desc; /* Optional description text for the MSP */
GSList *gaps; /* Array of "gaps" in this homolgy (this is a bit of a misnomer; the array
* gives the ranges of the bits that align, and the gaps are the bits in between */
char *source; /* Optional source text for the MSP */
GSList *gaps; /* Array of "gaps" in this homolgy (this is a bit of a misnomer because the array
* gives the ranges of the bits that align rather than the ranges of the gaps in between */
BlxStyle *style; /* Specifies drawing style for this MSP, e.g. fill color and line color */
......
......@@ -28,6 +28,14 @@
#define DEFAULT_SNP_CONNECTOR_HEIGHT 0
#define DEFAULT_NUM_UNALIGNED_BASES 5 /* the default number of additional bases to show if displaying unaligned parts of the match sequence */
/* Define the columns' default widths and titles. */
#define BLXCOL_INT_COLUMN_WIDTH 40 /* default width for ordinary integer columns */
#define BLXCOL_HIDDEN_COLUMN_WIDTH 0 /* default width for columns that are initially hidden */
#define BLXCOL_SEQNAME_WIDTH 120 /* default width for the name column */
#define BLXCOL_START_WIDTH 50 /* default width for the start coord column */
#define BLXCOL_END_WIDTH 80 /* default width for end coord column (bigger because it also spans the scrollbar) */
#define BLXCOL_SEQUENCE_WIDTH 40 /* default width for sequence column */
typedef enum {SORT_TYPE_COL, SORT_TEXT_COL, N_SORT_COLUMNS} SortColumns;
......@@ -549,11 +557,11 @@ static void refreshStartColHeader(GtkWidget *header, gpointer data)
if (detailViewGetDisplayRev(detailView))
{
gtk_label_set_text(GTK_LABEL(header), END_COLUMN_HEADER_TEXT);
gtk_label_set_text(GTK_LABEL(header), "End");
}
else
{
gtk_label_set_text(GTK_LABEL(header), BLXCOL_START_TITLE);
gtk_label_set_text(GTK_LABEL(header), "Start");
}
}
......@@ -566,11 +574,11 @@ static void refreshEndColHeader(GtkWidget *header, gpointer data)
if (detailViewGetDisplayRev(detailView))
{
gtk_label_set_text(GTK_LABEL(header), BLXCOL_START_TITLE);
gtk_label_set_text(GTK_LABEL(header), "Start");
}
else
{
gtk_label_set_text(GTK_LABEL(header), END_COLUMN_HEADER_TEXT);
gtk_label_set_text(GTK_LABEL(header), "End");
}
}
......@@ -677,14 +685,9 @@ void resizeDetailViewHeaders(GtkWidget *detailView)
{
DetailViewColumnInfo *columnInfo = (DetailViewColumnInfo*)listItem->data;
if (columnInfo->columnId == BLXCOL_SEQUENCE)
{
/* For the sequence column, don't set the size request, or we won't be
* able to shrink the window. The sequence col header will be resized
* dynamically to fit its text, which is the width that we want anyway. */
gtk_widget_set_size_request(columnInfo->headerWidget, SEQ_COLUMN_DEFAULT_WIDTH, -1);
}
else
/* For the sequence column, don't set the size request, or we won't be able
* to shrink the window. (The sequence col header will be resized dynamically.) */
if (columnInfo->columnId != BLXCOL_SEQUENCE)
{
/* For other columns, we can set the size request: they're small enough
* that we can live without the need to shrink below their sum widths. */
......@@ -3296,6 +3299,16 @@ static void GToggleStrand(GtkButton *button, gpointer data)
* Initialization *
***********************************************************/
/* Comparison function for two DetailViewColumnInfo structs
* Returns : negative value if a < b; zero if a = b; positive value if a > b. */
static gint columnCompareFunc(gconstpointer a, gconstpointer b)
{
DetailViewColumnInfo *col1 = (DetailViewColumnInfo*)a;
DetailViewColumnInfo *col2 = (DetailViewColumnInfo*)b;
return col1->columnId - col2->columnId;
}
/* Creates a detail-view column from the given info and adds it to the columnList. */
static void createColumn(ColumnId columnId,
GtkWidget *specialWidget,
......@@ -3315,15 +3328,19 @@ static void createColumn(ColumnId columnId,
gtk_misc_set_alignment(GTK_MISC(headerWidget), 0.0, 1.0);
}
/* Create the column info and place it in the list */
/* Create the column info */
DetailViewColumnInfo *columnInfo = g_malloc(sizeof(DetailViewColumnInfo));
columnInfo->columnId = columnId;
columnInfo->headerWidget = headerWidget;
columnInfo->refreshFunc = callbackFn,
columnInfo->title = title;
columnInfo->propertyName = propertyName;
columnInfo->width = defaultWidth;
*columnList = g_list_append(*columnList, columnInfo);
/* Place it in the list. Sort the list by ColumnId because the list must be sorted in the same
* order as the variable types in the TREE_COLUMN_TYPE_LIST definition */
*columnList = g_list_insert_sorted(*columnList, columnInfo, columnCompareFunc);
}
......@@ -3344,13 +3361,14 @@ static GList* createColumns(GtkWidget *detailView, const BlxSeqType seqType, con
GtkCallback endCallback = refreshEndColHeader;
/* Create the column headers and pack them into the column header bar */
createColumn(BLXCOL_SEQNAME, NULL, NULL, BLXCOL_SEQNAME_TITLE, RENDERER_TEXT_PROPERTY, NAME_COLUMN_DEFAULT_WIDTH, &columnList);
createColumn(BLXCOL_SCORE, NULL, NULL, BLXCOL_SCORE_TITLE, RENDERER_TEXT_PROPERTY, SCORE_COLUMN_DEFAULT_WIDTH, &columnList);
createColumn(BLXCOL_ID, NULL, NULL, BLXCOL_ID_TITLE, RENDERER_TEXT_PROPERTY, ID_COLUMN_DEFAULT_WIDTH, &columnList);
createColumn(BLXCOL_START, NULL, startCallback, BLXCOL_START_TITLE, RENDERER_TEXT_PROPERTY, START_COLUMN_DEFAULT_WIDTH, &columnList);
createColumn(BLXCOL_SEQUENCE, seqHeader, seqCallback, BLXCOL_SEQUENCE_TITLE, RENDERER_SEQUENCE_PROPERTY, SEQ_COLUMN_DEFAULT_WIDTH, &columnList);
createColumn(BLXCOL_END, NULL, endCallback, END_COLUMN_HEADER_TEXT, RENDERER_TEXT_PROPERTY, END_COLUMN_DEFAULT_WIDTH, &columnList);
createColumn(BLXCOL_SEQNAME, NULL, NULL, "Name", RENDERER_TEXT_PROPERTY, BLXCOL_SEQNAME_WIDTH, &columnList);
createColumn(BLXCOL_SCORE, NULL, NULL, "Score", RENDERER_TEXT_PROPERTY, BLXCOL_INT_COLUMN_WIDTH, &columnList);
createColumn(BLXCOL_ID, NULL, NULL, "%Id", RENDERER_TEXT_PROPERTY, BLXCOL_INT_COLUMN_WIDTH, &columnList);
createColumn(BLXCOL_START, NULL, startCallback, "Start", RENDERER_TEXT_PROPERTY, BLXCOL_START_WIDTH, &columnList);
createColumn(BLXCOL_SEQUENCE, seqHeader, seqCallback, "Sequence", RENDERER_SEQUENCE_PROPERTY, BLXCOL_SEQUENCE_WIDTH, &columnList);
createColumn(BLXCOL_END, NULL, endCallback, "End", RENDERER_TEXT_PROPERTY, BLXCOL_END_WIDTH, &columnList);
createColumn(BLXCOL_SOURCE, NULL, NULL, "Source", RENDERER_TEXT_PROPERTY, BLXCOL_HIDDEN_COLUMN_WIDTH, &columnList);
return columnList;
}
......
......@@ -18,24 +18,6 @@
#define SNP_TRACK_HEADER_NAME "SNP track header"
#define DNA_TRACK_HEADER_NAME "DNA track header"
/* Define the columns. Specify a default width, the display text for the
* column header, and also a name for the property that will be set in the
* cell renderer. (The latter cannot contain special characters.) */
#define NAME_COLUMN_DEFAULT_WIDTH 120
#define SCORE_COLUMN_DEFAULT_WIDTH 40
#define ID_COLUMN_DEFAULT_WIDTH 40
#define START_COLUMN_DEFAULT_WIDTH 50
#define SEQ_COLUMN_DEFAULT_WIDTH 40
#define END_COLUMN_DEFAULT_WIDTH 80
#define BLXCOL_SEQNAME_TITLE "Name"
#define BLXCOL_SCORE_TITLE "Score"
#define BLXCOL_ID_TITLE "%Id"
#define BLXCOL_START_TITLE "Start"
#define BLXCOL_SEQUENCE_TITLE "Sequence"
#define END_COLUMN_HEADER_TEXT "End"
/* This enum is used to define integer values to mean "canonical" and "non canonical". The values
* are converted to pointers to be used in a hash table, so they must be non-zero, or the hash table
* will treat them as null */
......@@ -46,20 +28,34 @@ typedef enum
} BlxCanonical;
/* This enum declares identifiers for each column in the detail view */
/* This enum declares identifiers for each column in the detail-view trees. If you add an enum
* here you must also add its type to the TREE_COLUMN_TYPE_LIST definition below. */
typedef enum
{
BLXCOL_SEQNAME,
BLXCOL_SCORE,
BLXCOL_ID,
BLXCOL_START,
BLXCOL_SEQUENCE,
BLXCOL_END,
BLXCOL_SEQNAME, /* The match sequence's name */
BLXCOL_SOURCE, /* The match's source */
BLXCOL_SCORE, /* The alignment's score */
BLXCOL_ID, /* The alignment's %ID */
BLXCOL_START, /* The start coord of the alignment on the match sequence */
BLXCOL_SEQUENCE, /* This column will display the part of the alignment currently in the display range. */
BLXCOL_END, /* The end coord of the alignment on the match sequence */
N_COLUMNS
BLXCOL_NUM_COLUMNS /* The number of columns; must always be the last item in this enum */
} ColumnId;
/* This defines the variable type for each detail-view-tree column. These MUST be the
* correct types (in the correct order) for the columns listed in the ColumnId enum above. */
#define TREE_COLUMN_TYPE_LIST \
G_TYPE_STRING, /* seq name */ \
G_TYPE_STRING, /* source */ \
G_TYPE_INT, /* score */ \
G_TYPE_INT, /* id */ \
G_TYPE_INT, /* start */ \
G_TYPE_POINTER, /* sequence */ \
G_TYPE_INT /* end */
/* This struct describes a column in the detail view. Multiple widgets (i.e. headers
* and tree columns) in the detail view must all have columns that share the same
* properties (namely the column width). */
......
......@@ -242,6 +242,7 @@ static void addSequenceStructToRow(gpointer listItemData, gpointer data)
gtk_list_store_set(store, &iter,
BLXCOL_SEQNAME, msp->sname,
BLXCOL_SOURCE, msp->source,
BLXCOL_SCORE, msp->score,
BLXCOL_ID, msp->id,
BLXCOL_START, msp->sRange.min,
......@@ -254,6 +255,7 @@ static void addSequenceStructToRow(gpointer listItemData, gpointer data)
/* Add generic info about the sequence */
gtk_list_store_set(store, &iter,
BLXCOL_SEQNAME, sequenceGetDisplayName(subjectSeq),
BLXCOL_SOURCE, NULL,
BLXCOL_SCORE, NULL,
BLXCOL_ID, NULL,
BLXCOL_START, NULL,
......@@ -267,20 +269,14 @@ static void addSequenceStructToRow(gpointer listItemData, gpointer data)
void addSequencesToTree(GtkWidget *tree, gpointer data)
{
GtkListStore *store = gtk_list_store_new(N_COLUMNS,
G_TYPE_STRING,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_POINTER,
G_TYPE_INT);
/* Set the sort functions for each column */
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), BLXCOL_SEQNAME, sortColumnCompareFunc, tree, NULL);
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), BLXCOL_ID, sortColumnCompareFunc, tree, NULL);
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), BLXCOL_SCORE, sortColumnCompareFunc, tree, NULL);
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), BLXCOL_START, sortColumnCompareFunc, tree, NULL);
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), BLXCOL_SEQUENCE, sortColumnCompareFunc, tree, NULL);
GtkListStore *store = gtk_list_store_new(BLXCOL_NUM_COLUMNS, TREE_COLUMN_TYPE_LIST);
/* Set the sort function for each column */
int colNum = 0;
for ( ; colNum < BLXCOL_NUM_COLUMNS; ++colNum)
{
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), colNum, sortColumnCompareFunc, tree, NULL);
}
/* Add the rows - one row per sequence. Use the list we've already compiled of all
* sequences as BlxSequences */
......@@ -537,14 +533,10 @@ static void resizeTreeHeaders(GtkWidget *tree, gpointer data)
{
int firstColId = GPOINTER_TO_INT(headerInfo->columnIds->data);
if (firstColId == BLXCOL_SEQUENCE)
{
/* For the sequence column, don't set the size request, or we won't be
* able to shrink the window. The sequence col header will be resized
* dynamically to fit its text, which is the width that we want anyway. */
gtk_widget_set_size_request(headerInfo->headerWidget, SEQ_COLUMN_DEFAULT_WIDTH, -1);
}
else
/* For the sequence column, don't set the size request to the real size, or we
* won't be able to shrink the window. (The sequence col header will be resized
* dynamically anyway.) */
if (firstColId != BLXCOL_SEQUENCE)
{
/* For other columns, we can set the size request: they're small enough
* that we can live without the need to shrink below their sum widths. */
......@@ -1653,6 +1645,7 @@ static void addMspToTreeRow(MSP *msp, GtkWidget *tree)
gtk_list_store_set(store, &iter,
BLXCOL_SEQNAME, msp->sname,
BLXCOL_SOURCE, msp->source,
BLXCOL_SCORE, msp->score,
BLXCOL_ID, msp->id,
BLXCOL_START, msp->sRange.min,
......@@ -1905,7 +1898,17 @@ static GtkTreeViewColumn* createTreeColumn(GtkWidget *tree,
}
/* Set the column properties and add the column to the tree */
gtk_tree_view_column_set_fixed_width(column, width);
if (width > 0)
{
gtk_tree_view_column_set_visible(column, TRUE);
gtk_tree_view_column_set_fixed_width(column, width);
}
else
{
/* Can't have 0 width, so hide the column instead */
gtk_tree_view_column_set_visible(column, FALSE);
}
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_resizable(column, TRUE);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
......@@ -2124,7 +2127,7 @@ static TreeColumnHeaderInfo* createTreeColHeader(GList **columnHeaders,
* to show any info in those columns. */
columnHeader = createLabel("", 0.0, 1.0, TRUE, TRUE);
refreshFunc = refreshNameColHeader;
columnIds = g_list_append(columnIds, GINT_TO_POINTER(BLXCOL_SEQNAME));
columnIds = g_list_append(columnIds, GINT_TO_POINTER(columnInfo->columnId));
break;
}
......@@ -2287,7 +2290,15 @@ static gint sortColumnCompareFunc(GtkTreeModel *model, GtkTreeIter *iter1, GtkTr
result = strcmp(msp1->sname, msp2->sname);
break;
}
case BLXCOL_SOURCE:
{
MSP *msp1 = (MSP*)(mspGList1->data);
MSP *msp2 = (MSP*)(mspGList2->data);
result = strcmp(msp1->source, msp2->source);
break;
}
case BLXCOL_SCORE:
{
result = multipleMsps ? 0 : msp1->score - msp2->score;
......@@ -2374,20 +2385,14 @@ static gint sortColumnCompareFunc(GtkTreeModel *model, GtkTreeIter *iter1, GtkTr
void treeCreateBaseDataModel(GtkWidget *tree, gpointer data)
{
/* Create the data store for the tree view */
GtkListStore *store = gtk_list_store_new(N_COLUMNS,
G_TYPE_STRING,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_POINTER,
G_TYPE_INT);
/* Set the sort functions for each column */
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), BLXCOL_SEQNAME, sortColumnCompareFunc, tree, NULL);
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), BLXCOL_ID, sortColumnCompareFunc, tree, NULL);
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), BLXCOL_SCORE, sortColumnCompareFunc, tree, NULL);
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), BLXCOL_START, sortColumnCompareFunc, tree, NULL);
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), BLXCOL_SEQUENCE, sortColumnCompareFunc, tree, NULL);
GtkListStore *store = gtk_list_store_new(BLXCOL_NUM_COLUMNS, TREE_COLUMN_TYPE_LIST);
/* Set the sort function for each column */
int colNum = 0;
for ( ; colNum < BLXCOL_NUM_COLUMNS; ++colNum)
{
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), colNum, sortColumnCompareFunc, tree, NULL);
}
gtk_tree_view_set_model(GTK_TREE_VIEW(tree), GTK_TREE_MODEL(store));
g_object_unref(G_OBJECT(store));
......
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