[med-svn] r235 - trunk/packages/seaview/branches/upstream/current
Charles Plessy
charles-guest at alioth.debian.org
Sat Mar 31 03:27:47 CET 2007
Author: charles-guest
Date: 2007-03-31 02:27:46 +0000 (Sat, 31 Mar 2007)
New Revision: 235
Modified:
trunk/packages/seaview/branches/upstream/current/align.cxx
trunk/packages/seaview/branches/upstream/current/load_seq.cxx
trunk/packages/seaview/branches/upstream/current/resource.cxx
trunk/packages/seaview/branches/upstream/current/seaview.cxx
trunk/packages/seaview/branches/upstream/current/seaview.h
trunk/packages/seaview/branches/upstream/current/seaview.help
Log:
Load /tmp/tmp.ndOo6r/seaview-20070215 into
trunk/packages/seaview/branches/upstream/current.
Modified: trunk/packages/seaview/branches/upstream/current/align.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/align.cxx 2007-03-22 14:31:35 UTC (rev 234)
+++ trunk/packages/seaview/branches/upstream/current/align.cxx 2007-03-31 02:27:46 UTC (rev 235)
@@ -85,7 +85,7 @@
l_line = 0;
}
line[l_line++] = sequence[num][pos];
- if(protein && sequence[num][pos] == '*') line[l_line - 1] = 'X';
+ if(sequence[num][pos] == '*') line[l_line - 1] = 'X';
*empty_seq = FALSE;
}
line[l_line] = 0;
@@ -398,9 +398,7 @@
}
lfrag = strlen(seq[0]); /* long alignement de clustalw */
lpart = fin - debut + 1; /*long region traitee de l'ancien alignement multiple*/
-if(view->protein) {
- if( reset_stars(view, debut, lpart, seq, lfrag) ) return TRUE;
- }
+if( reset_stars(view, debut, lpart, seq, lfrag) ) return TRUE;
/* num1 = rang dans align clustalw de num_longest dans align multiple */
num1 = -1;
for(i = 0; i < view->tot_seqs; i++) {
@@ -634,7 +632,7 @@
fl_cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_BLACK);
status = ask_with_custom_yesno(
"Wait for alignment completion in Terminal window.",
- "Alignment completed","Ignore of interrupt alignment") ? 0 : 1 ;
+ "Alignment completed","Ignore or interrupt alignment") ? 0 : 1 ;
// try to kill only a newly started Terminal and not something else
if( FSCompareFSRefs(&frontproc, &myterm) == noErr) KillProcess(&newpsn);
}
Modified: trunk/packages/seaview/branches/upstream/current/load_seq.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/load_seq.cxx 2007-03-22 14:31:35 UTC (rev 234)
+++ trunk/packages/seaview/branches/upstream/current/load_seq.cxx 2007-03-31 02:27:46 UTC (rev 235)
@@ -1,6 +1,8 @@
#include "seaview.h"
#include <ctype.h>
+#include <FL/Fl_Multiline_Input.H>
+#define ISSEQCHAR(c) (isalpha(c) || c=='-' || c=='*' )
typedef struct {
SEA_VIEW *view;
@@ -21,6 +23,12 @@
int lenseq);
char complement_base(char old);
void edit_comments_dialog(SEA_VIEW *view);
+void edit_sequence_dialog(SEA_VIEW *view);
+void close_editseqwin_callback(Fl_Widget *ob, void *data);
+int load_sequence_for_edit(struct editseq *editdata);
+char *renumber_seq(char *seq);
+void renumber_callback(Fl_Widget *ob, void *data);
+void edit_sequence_callback(Fl_Widget *ob, void *data);
void update_comments_callback(Fl_Widget *ob, void *data);
int load_comments(SEA_VIEW *view, Fl_Input *input, Fl_Widget *name);
char *cre_consensus(SEA_VIEW *view, char *newname);
@@ -28,6 +36,11 @@
char *label);
+/* external prototypes */
+extern void allonge_seqs(char **seq, int totseqs, int maxlen, int *eachlength,
+ int tot_comment_lines, char **comment_line);
+
+
void clear_callback(Fl_Widget *ob, void *data)
{
Fl_Input *seq_input, *seq_name_input;
@@ -264,7 +277,7 @@
seq_name_input->value("");
seq_input->value("");
#if defined(__APPLE__)
- seq_input->value("\n\n\n\n\n\nType sequence or paste it with CRTL-V\n\n\n");
+ seq_input->value("\n\n\n\n\n\nType sequence or paste it with cmd-V\n\n\n");
seq_input->position(seq_input->size(), 0);
#endif
seq_input->take_focus();
@@ -276,7 +289,7 @@
int lenseq)
{
int num, *newsel, numset;
-void *newcol;
+char ***newcol;
static char defname[]="newfile";
char **new_s, **new_n, **new_c;
@@ -334,16 +347,17 @@
((Fl_Slider*)view->horsli)->bounds(1,l);
}
if(view->numb_dnacolors > 1) {
- if( (newcol = (void *)malloc(num*sizeof(void *))) == NULL)
+ if( (newcol = (char ***)malloc(num*sizeof(char **))) == NULL)
goto nomem;
- memcpy(newcol, view->col_seq, (num-1)*sizeof(void *) );
- free(view->col_seq);
- view->col_seq = (char ***)newcol;
- view->col_seq[num-1] = * prepcolseqs(view->sequence+num-1, 1,
+ memcpy(newcol, view->col_seq, (num-1)*sizeof(char **) );
+ newcol[num-1] = * prepcolseqs(view->sequence+num-1, 1,
view->max_seq_length,
view->each_length+num-1,
( view->protein ? get_color_for_aa : get_color_for_base ),
view->numb_gc, view->allow_lower);
+ if(newcol[num - 1] == NULL) out_of_memory();
+ free(view->col_seq);
+ view->col_seq = newcol;
}
if( (newsel = (int *)malloc(num*sizeof(int))) == NULL) goto nomem;
memcpy(newsel, view->sel_seqs, (num-1)*sizeof(int) );
@@ -447,7 +461,195 @@
comments_form->show();
}
+struct editseq {
+ Fl_Window *form;
+ Fl_Multiline_Input *input;
+ Fl_Widget *name;
+ Fl_Widget *apply;
+ Fl_Widget *renumber;
+ SEA_VIEW *view;
+ int seqnum;
+ };
+
+void edit_sequence_dialog(SEA_VIEW *view)
+{
+struct editseq *editdata;
+int fin, width, num;
+
+for(num = 0; num <view->tot_seqs; num++) { if(view->sel_seqs[num]) break; }
+if(num >= view->tot_seqs) return;
+editdata = (struct editseq *)malloc(sizeof(struct editseq));
+if(editdata == NULL) return;
+editdata->seqnum = num;
+editdata->view = view;
+editdata->form = new Fl_Window(770,530);
+editdata->form->label("Sequence Editing");
+editdata->form->box(FL_FLAT_BOX);
+editdata->form->callback(close_editseqwin_callback, editdata);
+
+Fl_Group *top_group = new Fl_Group(5,5,editdata->form->w() - 10, 25);
+fin = 5;
+editdata->apply = cre_adjusted_button(fin,5,&width,25, "Apply");
+editdata->apply->callback(edit_sequence_callback, 0);
+fin += width + 5;
+
+editdata->renumber = cre_adjusted_button(fin,5,&width,25,"Renumber");
+editdata->renumber->callback(renumber_callback, 0);
+fin += width + 5;
+
+Fl_Widget *obj = cre_adjusted_button(fin,5,&width,25,"Cancel");
+obj->callback(close_editseqwin_callback, editdata);
+fin += width + 5;
+
+editdata->name = new Fl_Box(FL_DOWN_BOX, fin, 5,
+ top_group->x() +top_group->w() - fin, 25, "");
+editdata->name->align(FL_ALIGN_CENTER);
+editdata->name->labelfont(FL_COURIER);
+editdata->name->labelsize(FL_NORMAL_SIZE);
+
+top_group->resizable(editdata->name);
+top_group->end();
+
+editdata->input = new Fl_Multiline_Input(5,35,top_group->w(),
+ editdata->form->h() - 5 - 35, "");
+editdata->input->type(FL_MULTILINE_INPUT);
+editdata->input->textfont(FL_COURIER);
+editdata->input->textsize(12);
+editdata->form->resizable(editdata->input);
+editdata->form->end();
+editdata->form->position( (Fl::w() - editdata->form->w())/2,
+ (Fl::h() - editdata->form->h())/2 );
+
+if(load_sequence_for_edit(editdata)) {
+ fl_alert("Not enough memory");
+ return;
+ }
+editdata->form->show();
+editdata->input->take_focus();
+}
+
+
+void close_editseqwin_callback(Fl_Widget *ob, void *data)
+{
+free(data);
+Fl_Window *w = ob->window();
+delete (w == NULL ? ob : w);
+}
+
+
+int load_sequence_for_edit(struct editseq *editdata)
+{
+char *temp;
+
+editdata->name->label(editdata->view->seqname[editdata->seqnum]);
+editdata->name->redraw();
+
+temp = renumber_seq(editdata->view->sequence[editdata->seqnum]);
+if(temp == NULL) return TRUE;
+editdata->input->value(temp);
+free(temp);
+editdata->input->position(0);
+return FALSE;
+}
+
+
+char *renumber_seq(char *seq)
+{
+int l, nl, pos;
+char *p, *q, *temp;
+const int w = 100;
+
+p = seq - 1;
+l = 0;
+while(*(++p) != 0) {
+ if(ISSEQCHAR(*p)) l++;
+ }
+nl = l / w + 2;
+temp = (char *)malloc(l + 7 * nl + 100);
+if(temp == NULL) return NULL;
+p = seq - 1;
+q = temp;
+pos = 0;
+while(*(++p) != 0) {
+ if( ! ISSEQCHAR(*p)) continue;
+ *q++ = *p; pos++;
+ if(pos % w == 0) {
+ sprintf(q, "%6d\n", pos);
+ q += strlen(q);
+ }
+ }
+strcpy(q, "\n");
+return temp;
+}
+
+
+void renumber_callback(Fl_Widget *ob, void *data)
+{
+char *temp;
+struct editseq *editdata = (struct editseq *)ob->window()->user_data();
+
+temp = renumber_seq((char *)editdata->input->value());
+if(temp == NULL) return;
+editdata->input->value(temp);
+free(temp);
+}
+
+
+void edit_sequence_callback(Fl_Widget *ob, void *data)
+{
+struct editseq *editdata = (struct editseq *)ob->window()->user_data();
+char *p, *newseq, *q, *r, **newcolseq;
+SEA_VIEW *view;
+int num, l, col;
+
+view = editdata->view;
+num = editdata->seqnum;
+
+newseq = (char *)malloc(view->max_seq_length + 1);
+if(newseq == NULL) return;
+q = newseq;
+p = (char *)editdata->input->value() - 1;
+while(*(++p) != 0) {
+ if( ! ISSEQCHAR(*p) ) continue;
+ if(q - newseq >= view->max_seq_length) {
+ fl_alert("Warning: sequence was truncated to current max sequence length %d", view->max_seq_length);
+ break;
+ }
+ *(q++) = *p;
+ }
+*q = 0;
+l = strlen(newseq);
+if(view->numb_gc > 1) {
+ newcolseq = * prepcolseqs(&newseq, 1,
+ view->max_seq_length, &l,
+ ( view->protein ? get_color_for_aa : get_color_for_base ),
+ view->numb_gc, view->allow_lower);
+ if(newcolseq == NULL) return;
+ for(col = 0; col < view->numb_gc; col++) free(view->col_seq[num][col]);
+ free(view->col_seq[num]);
+ view->col_seq[num] = newcolseq;
+ }
+free(view->sequence[num]);
+view->sequence[num] = newseq;
+view->each_length[num] = l;
+view->modif_but_not_saved = TRUE;
+if(l > view->seq_length) {
+ double x;
+ view->seq_length = l;
+ x = ( (double) view->tot_sites ) / ( view->seq_length + 3 );
+ if(x>1) x=1;
+ ((Fl_Slider*)view->horsli)->slider_size(x);
+ l = view->seq_length - view->tot_sites+3;
+ if(l<1) l=1;
+ ((Fl_Slider*)view->horsli)->bounds(1,l);
+ }
+else view->mod_seq = num;
+view->DNA_obj->redraw();
+ob->window()->do_callback();
+}
+
+
void update_comments_callback(Fl_Widget *ob, void *data)
{
Fl_Input *comments_input;
Modified: trunk/packages/seaview/branches/upstream/current/resource.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/resource.cxx 2007-03-22 14:31:35 UTC (rev 234)
+++ trunk/packages/seaview/branches/upstream/current/resource.cxx 2007-03-31 02:27:46 UTC (rev 235)
@@ -12,14 +12,47 @@
int save_resources(void);
-#if defined(__APPLE__) && ! TARGET_RT_MAC_MACHO
+#if defined(__APPLE__)
+#if TARGET_RT_MAC_MACHO
+/* for Mac OS X */
+char *get_res_value(char *name, char *def_value, void *unused)
+{
+OSStatus err;
+CFStringRef cfname;
+CFPropertyListRef cfvalue;
+static char value[100];
+
+cfname = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingASCII);
+cfvalue = CFPreferencesCopyAppValue(cfname, kCFPreferencesCurrentApplication);
+if(cfvalue == NULL) return def_value;
+CFStringGetCString( (CFStringRef)cfvalue, value, sizeof(value), kCFStringEncodingASCII);
+CFRelease(cfname); CFRelease(cfvalue);
+return value;
+}
+
+
+int set_res_value(const char *name, const char *value)
+{
+char *p;
+CFStringRef cfname, cfvalue;
+
+cfname = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingASCII);
+cfvalue = CFStringCreateWithCString(kCFAllocatorDefault, value, kCFStringEncodingASCII);
+CFPreferencesSetAppValue(cfname, cfvalue, kCFPreferencesCurrentApplication);
+CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+CFRelease(cfname); CFRelease(cfvalue);
+return 0;
+}
+
+#else
+/* for Classic MaCOS */
extern "C" {
extern void PtoC(const void *in, void *out);
extern void CtoP(const void *in, void *out);
}
-char *load1res(char *resname)
+static char *load1res(char *resname)
{
char **h, *p, pname[256];
int l;
@@ -42,12 +75,6 @@
return p;
}
-void *load_resources(char *progname)
-{
-return NULL;
-}
-
-
char *get_res_value(char *name, char *def_value, void *v_db)
{
char *p;
@@ -101,14 +128,20 @@
return err != noErr ;
}
+#endif
int save_resources(void)
{ // nothing to do, taken care of by the system
}
+void *load_resources(char *progname)
+{ // nothing to do, taken care of by the system
+return NULL;
+}
-#else /* for X11 and win32 and MacOS-machO */
+#else /* for X11 and win32 */
+
typedef struct _item {
struct _item *before;
char *name;
@@ -120,9 +153,6 @@
extern "C" {
char *get_prog_dir(void);
-#if defined(__APPLE__) && TARGET_RT_MAC_MACHO
- char *MG_GetBundleResourcesDir(void);
-#endif
}
char *res_filename(void)
@@ -135,10 +165,6 @@
if(p == NULL) return NULL;
strcpy(fname, p);
strcat(fname, "\\seaview.ini");
-#elif defined(__APPLE__) && TARGET_RT_MAC_MACHO
-p = MG_GetBundleResourcesDir();
-strcpy(fname, p);
-strcat(fname, "/seaview.ini");
#else
p = getenv("HOME");
if(p == NULL) return NULL;
Modified: trunk/packages/seaview/branches/upstream/current/seaview.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/seaview.cxx 2007-03-22 14:31:35 UTC (rev 234)
+++ trunk/packages/seaview/branches/upstream/current/seaview.cxx 2007-03-31 02:27:46 UTC (rev 235)
@@ -225,7 +225,13 @@
}
/* access to resources */
-quick_and_dirty = bool_res_value("fast", 0, resources);
+quick_and_dirty = bool_res_value("fast",
+#if defined(__APPLE__) && TARGET_RT_MAC_MACHO
+ TRUE, //double buffer is done by the system, useless to add one more layer
+#else
+ FALSE,
+#endif
+ resources);
inverted = bool_res_value("inverted", TRUE, resources);
strcpy(save_format, get_res_value("save", possible_formats[NEXUS_FORMAT], resources) );
strcpy(stdcolorgroups,
@@ -324,9 +330,8 @@
#ifdef __APPLE__
MGinit_apple_events(view);
add_apropos(progname, help_file);
-#else
+#endif
if(masename != NULL) use_initial_file(view, masename);
-#endif
view->dnawin->show();
view->DNA_obj->take_focus();
fl_reset_cursor(view->dnawin);
@@ -567,14 +572,14 @@
char ***colseq;
if(totseqs == 0 || numb_gc == 1) return NULL;
colseq=(char ***)malloc(totseqs*sizeof(char **));
-if(colseq == NULL) out_of_memory();
+if(colseq == NULL) return NULL;
for(num=0; num<totseqs; num++) {
colseq[num] = (char **)malloc(numb_gc * sizeof(char *));
- if(colseq[num] == NULL) out_of_memory();
+ if(colseq[num] == NULL) return NULL;
l = eachlength[num];
for(col=0; col < numb_gc; col++) {
colseq[num][col]=(char *)malloc(maxlen+1);
- if(colseq[num][col] == NULL) out_of_memory();
+ if(colseq[num][col] == NULL) return NULL;
memset(colseq[num][col], ' ', l);
colseq[num][col][l]=0;
}
@@ -1226,6 +1231,7 @@
view->max_seq_length, view->each_length,
( view->protein ? get_color_for_aa : get_color_for_base ),
view->numb_gc, view->allow_lower);
+ if(view->col_seq == NULL) out_of_memory();
view->alt_col_seq = NULL;
}
view->first_seq = view->first_site = 1;
@@ -1249,6 +1255,7 @@
Fl_Menu_Item *items = (Fl_Menu_Item *)obj->menu();
items[RENAME_SEQ].deactivate();
items[EDIT_COMMENTS].deactivate();
+ items[EDIT_SEQ].deactivate();
items[DUPLICATE_SEQ].deactivate();
items[DELETE_SEQ].deactivate();
items[COMPLEMENT_SEQ].deactivate();
@@ -1675,6 +1682,7 @@
view->max_seq_length, view->each_length,
(view->protein ? get_color_for_aa : get_color_for_base),
view->numb_gc, view->allow_lower);
+if(view->col_seq == NULL) out_of_memory();
if(view->alt_colors != NO_ALT_COLORS) {
if(reponse >= Protein) view->alt_colors =
(color_choice)reponse;
@@ -2027,6 +2035,9 @@
else if(reponse == EDIT_COMMENTS) {
edit_comments_dialog(view);
}
+else if(reponse == EDIT_SEQ) {
+ edit_sequence_dialog(view);
+ }
else if(reponse == DELETE_SEQ) { /* delete selected sequences from alignment */
char temp[100];
sprintf(temp,"Confirm request of deletion of %d sequence(s)",
@@ -3289,6 +3300,7 @@
items[RENAME_SEQ].activate();
items[DUPLICATE_SEQ].activate();
items[EDIT_COMMENTS].activate();
+ items[EDIT_SEQ].activate();
if(view->protein) {
items[COMPLEMENT_SEQ].deactivate();
items[REVERSE_SEQ].deactivate();
@@ -3303,6 +3315,7 @@
items[RENAME_SEQ].deactivate();
items[DUPLICATE_SEQ].deactivate();
items[EDIT_COMMENTS].deactivate();
+ items[EDIT_SEQ].deactivate();
items[COMPLEMENT_SEQ].deactivate();
items[REVERSE_SEQ].deactivate();
}
@@ -4442,7 +4455,7 @@
/* menu Edit */
menu_edit = obj = add_menu("Edit");
((Fl_Menu_Button*)obj)->add(
- "Rename sequence|Edit comments|Delete sequence(s)|Create sequence|"
+ "Rename sequence|Edit comments|Edit sequence|Delete sequence(s)|Create sequence|"
"Load sequence|Duplicate sequence|"
"Complement sequence|Reverse sequence|Exchange Us and Ts|Align sites|"
"Dot plot|Consensus sequence|Del. gap-only sites");
Modified: trunk/packages/seaview/branches/upstream/current/seaview.h
===================================================================
--- trunk/packages/seaview/branches/upstream/current/seaview.h 2007-03-22 14:31:35 UTC (rev 234)
+++ trunk/packages/seaview/branches/upstream/current/seaview.h 2007-03-31 02:27:46 UTC (rev 235)
@@ -99,7 +99,7 @@
typedef enum {NO_ALT_COLORS, USING_STANDARD_COLORS, USING_ALT_COLORS}
color_choice;
-typedef enum {RENAME_SEQ, EDIT_COMMENTS, DELETE_SEQ, CREATE_SEQ, LOAD_SEQ,
+typedef enum {RENAME_SEQ, EDIT_COMMENTS, EDIT_SEQ, DELETE_SEQ, CREATE_SEQ, LOAD_SEQ,
DUPLICATE_SEQ,
COMPLEMENT_SEQ, REVERSE_SEQ, EXCHANGE_UT, ALIGN_SEQS, DOT_PLOT,
CONSENSUS_SEQ, DELETE_GAP_ONLY_SITES}
@@ -272,6 +272,7 @@
extern void draw_region_background(SEA_VIEW *view, int f_seq0, int l_seq0);
extern void load_seq_dialog(SEA_VIEW *view);
extern void edit_comments_dialog(SEA_VIEW *view);
+extern void edit_sequence_dialog(SEA_VIEW *view);
extern void add_seq_to_align(SEA_VIEW *view, char *newname, char *newseq,
int lenseq);
extern int get_color_for_base( int key );
Modified: trunk/packages/seaview/branches/upstream/current/seaview.help
===================================================================
--- trunk/packages/seaview/branches/upstream/current/seaview.help 2007-03-22 14:31:35 UTC (rev 234)
+++ trunk/packages/seaview/branches/upstream/current/seaview.help 2007-03-31 02:27:46 UTC (rev 235)
@@ -269,6 +269,10 @@
Edit comments To see or change comments of the currently selected
sequence (Comments can only be saved in mase/NEXUS).
+
+Edit sequence To edit the selected sequence, typically by pasting
+ external data, or by opening two edit sequence
+ windows and transferring sequence data between them.
Delete sequence(s) Deletes all selected sequences from the alignment.
@@ -278,12 +282,10 @@
Load sequence Allows to load a new sequence in the alignment.
The sequence can be typed in or pasted from a
- selection made in another window: drag on the
- sequence data, and paste it with the middle mouse
- button in the `Sequence loading' window.
+ selection made in another window.
Duplicate sequence Allows to duplicate the currently selected sequence
- wih prefix D_ in its name.
+ with prefix D_ in its name.
Complement sequence Creates a new sequence equal to the complementary
strand of the currently selected sequence with prefix
@@ -447,8 +449,7 @@
>>>Customization
#ifdef __APPLE__
-Custom settings are stored as program resources; so settings require write access
-to the seaview program to be permanently changed.
+Custom settings are stored in the user's Library/Preferences folder.
#elif __WIN32__
Custom settings are stored in file seaview.ini in the same directory as seaview program.
#else
More information about the debian-med-commit
mailing list