Commit 39458774 authored by luc.moulinier's avatar luc.moulinier

pleins de bugs ...

parent 26aae2a3
......@@ -24,9 +24,9 @@ BiotextSelectionCmd(Biotext *BiotextPtr,
int objc,
Tcl_Obj * const objv[])
{
int cmdIndex, r, c;
static CONST84 char *selCmdNames[] = {
"clear", "from", "to", (char *)NULL
};
......@@ -277,7 +277,7 @@ BiotextSequencesCmd(Biotext *BiotextPtr,
*--------------------------------------------------------------
*/
int
BiotextMappingCmd(Biotext *BiotextPtr,
BiotextMappingCmd(register Biotext *BiotextPtr,
Tcl_Interp *interp,
int objc,
Tcl_Obj * const objv[])
......@@ -285,14 +285,17 @@ BiotextMappingCmd(Biotext *BiotextPtr,
char *tmp;
int i, j, k, nmap;
Tcl_Obj **OMap, **OneE ;
Tk_Window tkwin = BiotextPtr->tkwin;
XColor *Cfg, *Cbg;
XGCValues gcValues;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg...?");
return TCL_ERROR;
}
Tcl_ListObjGetElements(interp,objv[2],&nmap,&OMap);
BiotextPtr->nbMapping=nmap;
BiotextPtr->nbMapping = nmap;
if (BiotextPtr->Mapping != NULL)
ckfree((char *)BiotextPtr->Mapping);
BiotextPtr->Mapping = (Tag *)ckalloc(nmap*sizeof(Tag));
......@@ -300,13 +303,30 @@ BiotextMappingCmd(Biotext *BiotextPtr,
for (i=0;i<nmap;i++) {
Tcl_ListObjGetElements(interp,OMap[i],&j,&OneE);
tmp = Tcl_GetString(OneE[0]);
BiotextPtr->Mapping[i].smap=tmp[0];
BiotextPtr->Mapping[i].fg = Tk_3DBorderColor(Tk_Alloc3DBorderFromObj(interp,BiotextPtr->tkwin,OneE[1]))->pixel;
BiotextPtr->Mapping[i].bg = Tk_3DBorderColor(Tk_Alloc3DBorderFromObj(interp,BiotextPtr->tkwin,OneE[2]))->pixel;
BiotextPtr->Mapping[i].bgBorder = Tk_Get3DBorderFromObj(BiotextPtr->tkwin, OneE[2]);
}
BiotextPtr->Mapping[i].smap = tmp[0];
BiotextPtr->Mapping[i].bgBorder = Tk_Get3DBorder(interp, tkwin, Tcl_GetString(OneE[2]));
Biotext_AssignColors(BiotextPtr, 2);
Cfg = Tk_AllocColorFromObj(interp, tkwin, OneE[1]);
Cbg = Tk_AllocColorFromObj(interp, tkwin, OneE[2]);
BiotextPtr->Mapping[i].Cfg = Cfg;
BiotextPtr->Mapping[i].Cbg = Cbg;
BiotextPtr->Mapping[i].fg = Cfg->pixel;
BiotextPtr->Mapping[i].bg = Cbg->pixel;
BiotextPtr->Mapping[i].gc = NULL;
/* Create a graphical context for the tag */
gcValues.graphics_exposures = False;
gcValues.font = Tk_FontId(BiotextPtr->tkfont);
gcValues.foreground = BiotextPtr->Mapping[i].fg;
//gcValues.background = Tk_3DBorderColor(BiotextPtr->fgBorder)->pixel;
gcValues.background = BiotextPtr->Mapping[i].bg;
BiotextPtr->Mapping[i].gc = Tk_GetGC(tkwin, GCFont|GCForeground|GCBackground, &gcValues);
//BiotextPtr->Mapping[i].gc = Tk_GetGC(tkwin, GCGraphicsExposures|GCFont|GCForeground|GCBackground, &gcValues);
}
Biotext_AssignMappingColors(BiotextPtr);
if (BiotextPtr->SeqMat != NULL) {
if (BiotextPtr->MapSeq == NULL) {
......@@ -328,11 +348,7 @@ BiotextMappingCmd(Biotext *BiotextPtr,
}
}
if (! pt) {
for (j=0;j<BiotextPtr->lgSeqs;j++) {
if (BiotextPtr->MapSeq[i][j] < 0 || BiotextPtr->MapSeq[i][j] >= BiotextPtr->nbMapping) {
break;
}
}
BiotextPtr->MapSeq[i][j] = -1;
}
}
}
......@@ -382,12 +398,14 @@ BiotextMapCmd(Biotext *BiotextPtr,
} else {
Tcl_GetBooleanFromObj(interp,objv[2],&bool);
if (bool) {
/* map ON */
if (BiotextPtr->flags & MAP_RESIDUES) {
return TCL_OK;
} else {
BiotextPtr->flags |= MAP_RESIDUES;
}
} else {
/* map OFF */
if (BiotextPtr->flags & MAP_RESIDUES) {
BiotextPtr->flags &= ~MAP_RESIDUES;
} else {
......@@ -444,7 +462,7 @@ BiotextTagCmd(Biotext *BiotextPtr,
switch ((enum tagCommand) cmdIndex) {
case CMD_TAG_CONFIG:
if (objc != 8) {
Tcl_WrongNumArgs(interp, 1, objv, "tag configure tagName -foreground fgCol -background bgCol");
Tcl_WrongNumArgs(interp, 1, objv, "tag configure tagName -foreground fgColor -background bgColor");
return TCL_ERROR;
}
......@@ -452,18 +470,28 @@ BiotextTagCmd(Biotext *BiotextPtr,
/* Now take the tag definition */
bg = fg = -1;
bgBorder = NULL;
for (i=4;i<7;i+=2) {
XColor *Cfg, *Cbg;
Cfg = Cbg = NULL;
for (i=4;i<8;i+=2) {
if (strcasecmp(Tcl_GetString(objv[i]),"-foreground") == 0 || strcasecmp(Tcl_GetString(objv[i]),"-fg") == 0) {
fg = Tk_3DBorderColor(Tk_Alloc3DBorderFromObj(interp,BiotextPtr->tkwin,objv[i+1]))->pixel;
Cfg = Tk_AllocColorFromObj(interp, BiotextPtr->tkwin, objv[i+1]);
fg = Cfg->pixel;
}
if (strcasecmp(Tcl_GetString(objv[i]),"-background") == 0 || strcasecmp(Tcl_GetString(objv[i]),"-bg") == 0) {
bg = Tk_3DBorderColor(Tk_Alloc3DBorderFromObj(interp,BiotextPtr->tkwin,objv[i+1]))->pixel;
Cbg = Tk_AllocColorFromObj(interp, BiotextPtr->tkwin, objv[i+1]);
bg = Cbg->pixel;
bgBorder = Tk_Get3DBorderFromObj(BiotextPtr->tkwin,objv[i+1]);
}
}
/* Are colors OK ? */
if (bg == -1 || fg == -1) {
/* bad colors names */
return TCL_ERROR;
}
/* check if tag already exists */
iTag=0;
iTag = 0;
for (i=0;i<BiotextPtr->nbTags;i++) {
if (strcmp(tagName,BiotextPtr->Tags[i].tagName) == 0)
break;
......@@ -483,30 +511,32 @@ BiotextTagCmd(Biotext *BiotextPtr,
/* now initialize */
RemoveTaggedPositionsInAlignment(BiotextPtr,-1);
}
if (bg == -1 || fg == -1)
return TCL_ERROR;
/* fill the tag structure */
BiotextPtr->Tags[iTag].tagName=(char *)ckalloc((strlen(tagName)+1)*sizeof(char));
strcpy(BiotextPtr->Tags[iTag].tagName,tagName);
BiotextPtr->Tags[iTag].Cfg = Cfg;
BiotextPtr->Tags[iTag].Cbg = Cbg;
BiotextPtr->Tags[iTag].fg = fg;
BiotextPtr->Tags[iTag].bg = bg;
BiotextPtr->Tags[iTag].bgBorder = bgBorder;
Biotext_AssignColors(BiotextPtr, 3);
Biotext_AssignTagColors(BiotextPtr, iTag);
break;
case CMD_TAG_ADD:
tagName = Tcl_GetString(objv[3]);
/* check if tag exists */
/* the tag must have been defined previously */
for(i=0;i<BiotextPtr->nbTags;i++) {
if (strcmp(BiotextPtr->Tags[i].tagName,tagName) == 0)
break;
}
if (i==BiotextPtr->nbTags)
if (i==BiotextPtr->nbTags) {
/* unknown tag */
return TCL_ERROR;
iTag=i;
}
iTag = i;
/* now check the indexes -
* There must be an even number of indexes
......@@ -535,7 +565,7 @@ BiotextTagCmd(Biotext *BiotextPtr,
for(k=col1;k<=col2;k++)
BiotextPtr->TagSeq[i][k]=iTag;
}
break;
case CMD_TAG_REMOVE:
if (objc == 3) {
......@@ -595,7 +625,6 @@ BiotextTagCmd(Biotext *BiotextPtr,
break;
}
BiotextPtr->flags |= UPDATE_SCROLLBAR;
BiotextEventuallyRedraw(BiotextPtr);
return TCL_OK;
......@@ -707,9 +736,9 @@ BiotextYViewCmd(register Biotext *BiotextPtr,
int objc,
Tcl_Obj * const objv[])
{
int index, charsPerPage;
int index, linesPerPage;
index = charsPerPage = 0;
index = linesPerPage = 0;
if (objc == 2) {
double first, last;
char buf[TCL_DOUBLE_SPACE];
......@@ -727,7 +756,7 @@ BiotextYViewCmd(register Biotext *BiotextPtr,
double fraction;
int count;
charsPerPage = BiotextPtr->heightChar;
linesPerPage = BiotextPtr->heightChar;
index = BiotextPtr->topIndex;
switch (Tk_GetScrollInfoObj(interp, objc, objv, &fraction,&count)) {
......@@ -737,7 +766,7 @@ BiotextYViewCmd(register Biotext *BiotextPtr,
index = (int) (fraction*BiotextPtr->nbSeqs + 0.5);
break;
case TK_SCROLL_PAGES: {
index += count * charsPerPage;
index += count * linesPerPage;
break;
}
case TK_SCROLL_UNITS:
......@@ -747,11 +776,8 @@ BiotextYViewCmd(register Biotext *BiotextPtr,
return TCL_ERROR;
}
}
if (index >= BiotextPtr->nbSeqs) {
index = BiotextPtr->nbSeqs - 1;
}
if (index >= BiotextPtr->nbSeqs - charsPerPage ) {
index = BiotextPtr->nbSeqs - charsPerPage;
if (index > (BiotextPtr->nbSeqs - linesPerPage) ) {
index = BiotextPtr->nbSeqs - linesPerPage;
}
if (index < 0) {
index = 0;
......@@ -1228,9 +1254,6 @@ BiotextInsertCols(register Biotext *BiotextPtr,
start = index + 1;
stop2 = index + count + 1;
}
//fprintf(stderr,"InsertCols: index %d lgs %d stop1 %d start %d stop2 %d\n",index,lgs,stop1,start,stop2);
//fflush(stderr);
for (j=0;j<nseq;j++) {
for (i=lgs-1;i>stop1;i--) {
......@@ -1360,7 +1383,7 @@ BiotextDeleteCmd(register Biotext *BiotextPtr,
Tcl_Obj * const objv[])
{
char *what, *iStr, dummy;
int i, is, if, result;
int i, ids, idf, result;
if (objc < 4 && (strcmp(Tcl_GetString(objv[2]),"colsgaps"))) {
Tcl_WrongNumArgs(interp, 1, objv, " delete <colsgaps|cols|rows> ?all|end|index?");
......@@ -1383,6 +1406,7 @@ BiotextDeleteCmd(register Biotext *BiotextPtr,
return TCL_ERROR;
}
result = TCL_OK;
if (strcasecmp(what,"cols") == 0) {
if (strcasecmp(iStr, "end") == 0) {
i = BiotextPtr->lgSeqs - 1;
......@@ -1392,16 +1416,16 @@ BiotextDeleteCmd(register Biotext *BiotextPtr,
result = BiotextDeleteCols(BiotextPtr, i);
} else if (strcasecmp(what, "rows") == 0) {
if (strcasecmp(iStr, "end") == 0) {
is = BiotextPtr->nbSeqs - 1;
if = is+1;
} else if {strcasecmp(iStr, "all") == 0) {
is = 0;
if = BiotextPtr->nbSeqs;
ids = BiotextPtr->nbSeqs - 1;
idf = ids+1;
} else if (strcasecmp(iStr, "all") == 0) {
ids = 0;
idf = BiotextPtr->nbSeqs;
} else {
sscanf(iStr, "%d", &is);
if = is+1;
sscanf(iStr, "%d", &ids);
idf = ids+1;
}
for (i=is;i<if;i++) {
for (i=ids;i<idf;i++) {
result = BiotextDeleteRows(BiotextPtr, i);
}
} else {
......@@ -1457,10 +1481,7 @@ BiotextDeleteColsGaps(register Biotext *BiotextPtr)
BiotextDeleteCols(BiotextPtr, i);
ckfree((char *)colToDel);
//fprintf(stdout,"\nRemColsGaps : lgs %d currC %d\n",BiotextPtr->lgSeqs, BiotextPtr->currentC);
//fflush(stdout);
return TCL_OK;
}
......@@ -1549,9 +1570,9 @@ BiotextDeleteRows(register Biotext *BiotextPtr,
BiotextPtr->TagSeq = (int **)ckrealloc((char *)BiotextPtr->TagSeq,nbs*sizeof(int *));
BiotextPtr->SeqGrp = (int *)ckrealloc((char *)BiotextPtr->SeqGrp, nbs*sizeof(int));
BiotextPtr->nbSeqs = nbs - 1;
return TCL_OK;
}
......@@ -1581,7 +1602,7 @@ BiotextGroupCmd(register Biotext *BiotextPtr,
char *smode;
int nseq, i, idx, nmGrp, inm, isq, mode;
Tcl_Obj **OIdx;
/*
* !! GROUP NAME IS HANDLED BY THE TCL CALLER !!!
*
......@@ -1589,7 +1610,7 @@ BiotextGroupCmd(register Biotext *BiotextPtr,
* Find a group name. Loop through existing names
* and find the first missing one
*/
/*
isIn = 1;
nmGrp = 0;
......@@ -1603,7 +1624,7 @@ BiotextGroupCmd(register Biotext *BiotextPtr,
}
}
*/
/*
* Syntax: <pathname> group ?-new|-merge? name index
*
......@@ -1879,10 +1900,7 @@ BiotextPushCmd(register Biotext *BiotextPtr,
r = BiotextPtr->currentR;
c = BiotextPtr->currentC;
icol = c;
//fprintf(stdout,"Push : r= %3d, c= %3d\n",r,c);
//fflush(stdout);
/*
* Find the closest gap to the left/right
*/
......@@ -1922,13 +1940,9 @@ BiotextPushCmd(register Biotext *BiotextPtr,
/* we have to update the scrollbars */
BiotextPtr->flags |= UPDATE_SCROLLBAR;
} else if (nextGap == BiotextPtr->lgSeqs) {
//fprintf(stdout,"--> lgs AV Ins %d\n",BiotextPtr->lgSeqs);
//fflush(stdout);
BiotextInsertCols(BiotextPtr, BiotextPtr->lgSeqs-1, 1);
nextGap = BiotextPtr->lgSeqs-1;
//fprintf(stdout,"--> lgs AP ins %d\n",BiotextPtr->lgSeqs);
//fflush(stdout);
/* we have to update the scrollbars */
BiotextPtr->flags |= UPDATE_SCROLLBAR;
}
......@@ -1936,8 +1950,6 @@ BiotextPushCmd(register Biotext *BiotextPtr,
/*
* We can then push the sequence
*/
//fprintf(stderr,"av do Push : c=%3d lgs= %3d\n",BiotextPtr->currentC, BiotextPtr->lgSeqs);
//fflush(stderr);
if (nGrp != 0 && BiotextPtr->nbrGrps > 0) {
for(i=0;i<BiotextPtr->nbSeqs;i++)
if (BiotextPtr->SeqGrp[i] == nGrp)
......@@ -1951,15 +1963,8 @@ BiotextPushCmd(register Biotext *BiotextPtr,
else
BiotextPtr->currentC++;
//fprintf(stderr,"fin Push : c=%3d lgs= %3d\n",BiotextPtr->currentC, BiotextPtr->lgSeqs);
//fflush(stderr);
//BiotextPtr->flags |= UPDATE_SCROLLBAR;
BiotextEventuallyRedraw(BiotextPtr);
//fprintf(stderr,"fin Push : c=%3d lgs= %3d\n\n",BiotextPtr->currentC, BiotextPtr->lgSeqs);
//fflush(stderr);
return TCL_OK;
}
......
......@@ -1062,6 +1062,14 @@ proc SetupPDBObject {} {
}
oo::define Structure method _typeChn {chn} {
my TypRes
set L [DenombreLaListe $TypRes($c)]
return [lindex [lindex $L 0] 0]
}
oo::define Structure method selcolor {col} {
my variable ResSel ResCol
......
......@@ -314,21 +314,6 @@ proc DetruitUnPDB {pdbid} {
}
proc UpdateVisibleAnnotations {} {
global db Anno
set Lanno [ManageAnnotation getall [MacCourant]]
set Anno(Lnoms) [list]
set Anno(Lnoms) [list "None" "All"]
foreach {pka pks nom col zone} $Lanno {
lappend Anno(Lanno) [list $pka $nom $col $zone]
lappend Anno(Lnoms) $nom
}
return
}
proc AjoutePDB {{what ok}} {
global WAP LNOrdali ListePDB
......@@ -612,10 +597,10 @@ proc AskAddSeqs {} {
set TAddS(KeepClus) 0
}
if {0} {
set TAddS(File) "add_jaris.tfa"
if {1} {
set TAddS(File) "2zbk_b.tfa"
set TAddS(Position) "end"
set TAddS(seqInsert) "Q5ZAV6"
set TAddS(seqInsert) "A9TJG7"
set TAddS(Align) 1
}
set res [array get TAddS]
......@@ -3389,243 +3374,6 @@ proc CherchePCI {w args} {
}
proc ShowAnnotation {args} {
foreach {pka pks nom text col zone} [ManageAnnotation get $::Anno(Nom)] {
$NomTextSeq tag configure Anno_$pka -bg $col
$NomTextSeq tag add Anno_$pka {*}$zone
}
return
}
proc EditeAnnotation {} {
set ::Anno
return
}
proc ManageAnnotation {what pk {nom ""} {txt ""} {col ""} {zon ""}} {
set Lann [list]
switch $what {
"record" {
lappend ::Anno(Lanno) [list $::Anno(iAnno) -1 $txt $col $zon]
incr ::Anno(iAnno)
}
"edit" {
$::db eval {update annotation set annotation=$txt, color=$col, zone=$zon where pk_annotation=$pk}
}
}
return $Lann
}
proc AjouteAnnotation {} {
set zon [$::NomTextSeq tag ranges selZone]
if {$zon == {} } {
FaireLire "No alignment zones defined !"
return
}
$::NomTextSeq tag remove selZone 1.0 end
set txt [$::Anno(WText) get 1.0 end]
set txt [string map {"'" " "} $txt]
$::Anno(WText) delete 1.0 end
set col $::Anno(Color)
set colAff [CouleurO2Ordali $::Anno(Color)]
set nom $::Anno(Nom)
set txt "$::Anno(iAnno) - $txt"
set txtnsp [string map {_ @ " " _} $txt]
set Ntag "FDisp_$txtnsp"
$::NomTextSeq tag configure $Ntag -background $colAff
$::NomTextSeq tag add $Ntag {*}$zon
ManageAnnotation "record" [MacCourant] $nom $txt $col $zon
return
}
proc FindTagPatch {tag x y} {
global NomTextSeq
set Lranges [$NomTextSeq tag ranges $tag]
set LgoodX [list]
foreach {p1 p2} $Lranges {
lassign [split $p1 .] y1 x1
lassign [split $p2 .] y2 x2
if {$x >= $x1 && $x < $x2} {
lappend LgoodX $y1
lappend Lx1 $x1
lappend Lx2 $x2
}
}
set LggodX [lsort -integer $LgoodX]
set jprev [lindex $LgoodX 0]
set jstart $jprev ; set jfin -1
if {$jprev == $y} {
set jy 1
} else {
set jy 0
}
foreach j [lrange $LgoodX 1 end] {
if {$j == $y} {set jy 1}
if {$j != ($jprev + 1)} {
if {$jy} {
set jfin $jprev
break
} else {
set jstart $j
}
}
set jprev $j
}
if {$jfin == -1} {
set jfin $jprev
}
# cree liste du patch
set x1 [lsort -unique -integer $Lx1]
set x2 [lsort -unique -integer $Lx2]
set Lres [list]
for {set y $jstart} {$y <= $jfin} {incr y} {
lappend Lres $y.$x1 $y.$x2
}
return $Lres
}
proc PositionAnnotation {w xp yp {quoi ""}} {
lassign [split [$w index @$xp,$yp] .] y x
$::NomTextSeq configure -state normal
switch $quoi {
"debut" {
set Lt [$::NomTextSeq tag names $y.$x]
set disp [lsearch -inline -regexp $Lt {^FDisp\_[0-9]+\_}]
if {$disp ne ""} {
regexp {FDisp_([0-9]+)_(.+)} $disp tmp ian txt
set anno [lsearch -inline -exact -index 0 $::Anno(Lanno) $ian]
lassign $anno ian pka txt col zone
$::Anno(WText) delete 1.0 end
$::Anno(WText) insert end $txt
set Lcol [$::WOrdali(ComboColAnno) cget -values]
set icol [lsearch -exact $Lcol $::Anno(Color)]
$::WOrdali(ComboColAnno) index $icol
$::NomTextSeq configure -state disabled
return
}
set ::Anno(xdebut) $x
set ::Anno(ydebut) $y
}
"move" {
set xd [set ::Anno(xdebut)]
set yd [set ::Anno(ydebut)]
if {$x < $xd} {
set xt $xd
set xd $x
set x $xt
}
if {$y < $yd} {
set yt $yd
set yd $y
set y $yt
}
set Lt {}
for {set i $yd} {$i <= $y} {incr i} {
lappend Lt $i.$xd $i.$x
}
if {$Lt != {}} {
$w tag add selZone {*}$Lt
}
}
"termine" {
if {0} {
#$w configure -state disabled
set xd $::Anno(xdebut)
set yd $::Anno(ydebut)
if {$xd < $x} {
set xm $xd ; set xx $x
} else {
set xm $x ; set xx $xd
}
if {$yd < $y} {
set ym $yd ; set yx $y
} else {
set ym $y ; set yx $yd
}
set tx [expr {$xx-$xm+1}]
set ty [expr {$yx-$ym+1}]
text .tmsg -bg yellow -fg blue -font "Helvetica 22 bold"
place .tmsg \
-x $xp -y $yp \
-in $::NomTextSeq
}
}
"delete" {
set Lt [$::NomTextSeq tag names $y.$x]
set disp [lsearch -inline -regexp $Lt {^FDisp\_[0-9]+\_}]
if {$disp ne ""} {
regexp {FDisp_([0-9]+)} $disp tmp ian
set iLanno [lsearch -exact -index 0 $::Anno(Lanno) $ian]
set anno [lindex $::Anno(Lanno) $iLanno]
lassign $anno ian pka txt col zone
set Lr [FindTagPatch $disp $x y]
$::NomTextSeq tag remove $disp {*}$Lr
foreach p $Lr {
set i [lsearch -exact $zone $p]
if {$i == -1} {
puts "$p not in zone"
} else {