diff options
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/biosrc.c | 6 | ||||
-rw-r--r-- | desktop/cdrgn.c | 19 | ||||
-rw-r--r-- | desktop/dlgutil1.c | 19 | ||||
-rw-r--r-- | desktop/dlgutil2.c | 10 | ||||
-rw-r--r-- | desktop/e2docsum.c | 26 | ||||
-rw-r--r-- | desktop/gbfview.c | 89 | ||||
-rw-r--r-- | desktop/salsa.c | 166 | ||||
-rw-r--r-- | desktop/seqpanel.c | 357 | ||||
-rw-r--r-- | desktop/vsm.c | 12 |
9 files changed, 494 insertions, 210 deletions
diff --git a/desktop/biosrc.c b/desktop/biosrc.c index e745fdcd..9f6802e1 100644 --- a/desktop/biosrc.c +++ b/desktop/biosrc.c @@ -29,7 +29,7 @@ * * Version Creation Date: 1/22/95 * -* $Revision: 6.48 $ +* $Revision: 6.49 $ * * File Description: * @@ -1907,11 +1907,11 @@ EnumFieldAssocPtr subsource_alists [] = { }; Uint2 orgmod_widths [] = { - 0, 15 + 0, 25 }; Uint2 subsource_widths [] = { - 0, 15 + 0, 25 }; Uint2 orgmod_types [] = { diff --git a/desktop/cdrgn.c b/desktop/cdrgn.c index 587ced29..59282919 100644 --- a/desktop/cdrgn.c +++ b/desktop/cdrgn.c @@ -29,7 +29,7 @@ * * Version Creation Date: 1/22/95 * -* $Revision: 6.57 $ +* $Revision: 6.60 $ * * File Description: * @@ -2272,9 +2272,9 @@ static DialoG CreateCdRgnDialog (GrouP h, CharPtr title, Int2 genCode, x = HiddenGroup (cfp->protTextGrp, 2, 0, NULL); SetGroupSpacing (x, 3, 5); StaticPrompt (x, "Name", 0, dialogTextHeight, programFont, 'l'); - cfp->protNameText = DialogText (x, "", 15, NULL); + cfp->protNameText = DialogText (x, "", 25, NULL); StaticPrompt (x, "Description", 0, dialogTextHeight, programFont, 'l'); - cfp->protDescText = DialogText (x, "", 15, NULL); + cfp->protDescText = DialogText (x, "", 25, NULL); cfp->protPromptGrp = HiddenGroup (f, -1, 0, NULL); StaticPrompt (cfp->protPromptGrp, "Press Edit Protein Feature to change protein name", @@ -2841,7 +2841,7 @@ extern ForM CreateCdRgnForm (Int2 left, Int2 top, CharPtr title, StdFeatIntEdPartialCallback); cfp->pages [LOCATION_PAGE] = s; Hide (cfp->pages [LOCATION_PAGE]); - cfp->locvisited = FALSE; + cfp->locvisited = TRUE; AlignObjects (ALIGN_CENTER, (HANDLE) cfp->pages [CODING_REGION_PAGE], (HANDLE) cfp->pages [COMMON_PAGE], @@ -4210,11 +4210,11 @@ static DialoG CreateProtDialog (GrouP h, CharPtr title, ProtRefPtr prp, SeqFeatP ppp->protGrp [0] = HiddenGroup (k, -1, 0, NULL); g = HiddenGroup (ppp->protGrp [0], 0, 10, NULL); StaticPrompt (g, "Protein Names", 0, 0, programFont, 'c'); - ppp->name = CreateVisibleStringDialog (g, 3, -1, 15); + ppp->name = CreateVisibleStringDialog (g, 3, -1, 25); f = HiddenGroup (ppp->protGrp [0], 0, 4, NULL); StaticPrompt (f, "Description", 0, dialogTextHeight, programFont, 'c'); - ppp->desc = DialogText (f, "", 20, NULL); + ppp->desc = DialogText (f, "", 25, NULL); r = HiddenGroup (ppp->protGrp [0], 2, 0, NULL); StaticPrompt (r, "Processing", 0, dialogTextHeight, programFont, 'l'); @@ -4242,7 +4242,7 @@ static DialoG CreateProtDialog (GrouP h, CharPtr title, ProtRefPtr prp, SeqFeatP ppp->protGrp [2] = HiddenGroup (k, 0, 10, NULL); StaticPrompt (ppp->protGrp [2], "Activity", 0, 0, programFont, 'c'); - ppp->activity = CreateVisibleStringDialog (ppp->protGrp [2], 3, -1, 15); + ppp->activity = CreateVisibleStringDialog (ppp->protGrp [2], 3, -1, 25); Hide (ppp->protGrp [2]); ppp->protGrp [3] = HiddenGroup (k, -1, 0, NULL); @@ -5219,11 +5219,6 @@ static void PopulateAAPopup (PopuP AAitem) sprintf (item, "%c %s", ch, str); PopupItem (AAitem, item); } - i = '*'; - ch = GetSymbolForResidue (sctp, i); - str = (CharPtr) GetNameForResidue (sctp, i); - sprintf (item, "%c %s", ch, str); - PopupItem (AAitem, item); SetValue (AAitem, 1); } diff --git a/desktop/dlgutil1.c b/desktop/dlgutil1.c index dbb332dd..86167dd2 100644 --- a/desktop/dlgutil1.c +++ b/desktop/dlgutil1.c @@ -29,7 +29,7 @@ * * Version Creation Date: 1/22/95 * -* $Revision: 6.43 $ +* $Revision: 6.44 $ * * File Description: * @@ -50,6 +50,7 @@ #include <gbfeat.h> #include <gbftdef.h> #include <edutil.h> +#include <explore.h> #define NUMBER_OF_SUFFIXES 8 @@ -1008,9 +1009,12 @@ extern Boolean FeatFormReplaceWithoutUpdateProc (ForM f) Char ch; Char desc [128]; Int2 expev; + SeqMgrFeatContext fcontext; FeatureFormPtr ffp; + SeqFeatPtr gene; GeneGatherList ggl; GeneRefPtr grp; + GeneRefPtr grpfeat; GatherScope gs; SeqLocPtr gslp; Boolean hasNulls; @@ -1029,6 +1033,7 @@ extern Boolean FeatFormReplaceWithoutUpdateProc (ForM f) SeqEntryPtr sep; SeqFeatPtr sfp; SeqLocPtr slp; + CharPtr str; Char symbol [128]; Int2 usexref; Int2 val; @@ -1152,7 +1157,17 @@ extern Boolean FeatFormReplaceWithoutUpdateProc (ForM f) } if (vnp != NULL) { if (vnp->choice == 1) { - grp = CreateNewGeneRef ((CharPtr) vnp->data.ptrvalue, NULL, NULL, FALSE); + str = (CharPtr) vnp->data.ptrvalue; + if (StringDoesHaveText (str)) { + grp = CreateNewGeneRef (str, NULL, NULL, FALSE); + gene = SeqMgrGetFeatureByLabel (bsp, str, SEQFEAT_GENE, 0, &fcontext); + if (gene != NULL && gene->data.choice == SEQFEAT_GENE) { + grpfeat = (GeneRefPtr) gene->data.value.ptrvalue; + if (grpfeat != NULL) { + grp->locus_tag = StringSaveNoNull (grpfeat->locus_tag); + } + } + } } else if (vnp->choice == 3) { grp = GeneRefNew (); if (grp != NULL) { diff --git a/desktop/dlgutil2.c b/desktop/dlgutil2.c index a2a38bd8..30548432 100644 --- a/desktop/dlgutil2.c +++ b/desktop/dlgutil2.c @@ -29,7 +29,7 @@ * * Version Creation Date: 1/22/95 * -* $Revision: 6.48 $ +* $Revision: 6.49 $ * * File Description: * @@ -1264,7 +1264,7 @@ static void ChangeCannedMessage (PopuP p) SetStatus (ffp->exception, TRUE); break; case 5 : - SetTitle (ffp->exceptText, "trans splicing"); + SetTitle (ffp->exceptText, "trans-splicing"); SetStatus (ffp->exception, TRUE); break; case 6 : @@ -1419,7 +1419,7 @@ extern GrouP CreateCommonFeatureGroupEx (GrouP h, FeatureFormPtr ffp, PopupItem (canned, "RNA editing"); PopupItem (canned, "reasons given in citation"); PopupItem (canned, "ribosomal slippage"); - PopupItem (canned, "trans splicing"); + PopupItem (canned, "trans-splicing"); PopupItem (canned, "artificial frameshift"); PopupItem (canned, "nonconsensus splice site"); PopupItem (canned, "rearrangement required"); @@ -1433,8 +1433,8 @@ extern GrouP CreateCommonFeatureGroupEx (GrouP h, FeatureFormPtr ffp, } else if (StringICmp (sfp->except_text, "ribosomal slippage") == 0 || StringICmp (sfp->except_text, "ribosome slippage") == 0) { SetValue (canned, 4); - } else if (StringICmp (sfp->except_text, "trans splicing") == 0 || - StringICmp (sfp->except_text, "trans-splicing") == 0) { + } else if (StringICmp (sfp->except_text, "trans-splicing") == 0 || + StringICmp (sfp->except_text, "trans splicing") == 0) { SetValue (canned, 5); } else if (StringICmp (sfp->except_text, "artificial frameshift") == 0) { SetValue (canned, 6); diff --git a/desktop/e2docsum.c b/desktop/e2docsum.c index 2875ff75..659011df 100644 --- a/desktop/e2docsum.c +++ b/desktop/e2docsum.c @@ -29,7 +29,7 @@ * * Version Creation Date: 10/30/01 * -* $Revision: 6.48 $ +* $Revision: 6.49 $ * * File Description: * @@ -1295,6 +1295,10 @@ static CharPtr Query_FetchFields (DoC d, Int2 item, Pointer ptr) /* */ /*==================================================================*/ +static CharPtr file_is_too_long_mssg = +"The record is too large to display in this format in the document summary window.\n\ +Please double click here to launch a separate viewer that can display this record."; + static CharPtr FileToString (CharPtr path) { @@ -1307,16 +1311,20 @@ static CharPtr FileToString (CharPtr path) ptr = NULL; len = FileLength (path); if (len > 0 && len < MAXALLOC) { - fp = FileOpen (path, "r"); - if (fp != NULL) { - ptr = MemNew (sizeof (Char) * (size_t) (len + 4)); - if (ptr != NULL) { - actual = FileRead (ptr, 1, (size_t) len, fp); - if (actual > 0 && actual <= len) { - ptr [actual] = '\0'; + if (len > 65000) { + ptr = StringSave (file_is_too_long_mssg); + } else { + fp = FileOpen (path, "r"); + if (fp != NULL) { + ptr = MemNew (sizeof (Char) * (size_t) (len + 4)); + if (ptr != NULL) { + actual = FileRead (ptr, 1, (size_t) len, fp); + if (actual > 0 && actual <= len) { + ptr [actual] = '\0'; + } } - } FileClose (fp); + } } } return ptr; diff --git a/desktop/gbfview.c b/desktop/gbfview.c index f6b8aaec..2671d9ce 100644 --- a/desktop/gbfview.c +++ b/desktop/gbfview.c @@ -29,7 +29,7 @@ * * Version Creation Date: 2/5/97 * -* $Revision: 6.73 $ +* $Revision: 6.75 $ * * File Description: * @@ -896,37 +896,40 @@ static void LookForTpa ( static void PopulateFlatFile (BioseqViewPtr bvp, FmtType format, FlgType flags) { - BioseqPtr bsp; - CstType custom = 0; - DoC doc; - Boolean doLockFarComponents = FALSE; - Uint2 entityID; - FonT fnt; - FILE *fp; - Boolean hastpaaligns; - Int2 into; - Boolean isAEorCH; - Boolean isGED; - Boolean isNTorNW; - Boolean isNC; - Boolean isTPA; - Int2 item; - ErrSev level; - Boolean lockFar = FALSE; - Boolean lookupFar = FALSE; - ModType mode = SEQUIN_MODE; - SeqEntryPtr oldsep; - Char path [PATH_MAX]; - BaR sb = NULL; - SeqEntryPtr sep; - Int4 startsAt; - CharPtr str; - StlType style = NORMAL_STYLE; - SeqViewProcsPtr svpp; - SeqEntryPtr topsep; - TexT txt; - SeqEntryPtr usethetop = NULL; - Int2 val; + BioseqPtr bsp; + SeqMgrFeatContext context; + CstType custom = 0; + DoC doc; + Boolean doLockFarComponents = FALSE; + Uint2 entityID; + Int4 feats_with_product_count; + FonT fnt; + FILE *fp; + Boolean hastpaaligns; + Int2 into; + Boolean isAEorCH; + Boolean isGED; + Boolean isNTorNW; + Boolean isNC; + Boolean isTPA; + Int2 item; + ErrSev level; + Boolean lockFar = FALSE; + Boolean lookupFar = FALSE; + ModType mode = SEQUIN_MODE; + SeqEntryPtr oldsep; + Char path [PATH_MAX]; + BaR sb = NULL; + SeqEntryPtr sep; + SeqFeatPtr sfp; + Int4 startsAt; + CharPtr str; + StlType style = NORMAL_STYLE; + SeqViewProcsPtr svpp; + SeqEntryPtr topsep; + TexT txt; + SeqEntryPtr usethetop = NULL; + Int2 val; if (bvp == NULL) return; if (bvp->hasTargetControl && bvp->ffModeCtrl != NULL) { @@ -1033,6 +1036,14 @@ static void PopulateFlatFile (BioseqViewPtr bvp, FmtType format, FlgType flags) doLockFarComponents = TRUE; } } + + if (mode == ENTREZ_MODE) { + doLockFarComponents = FALSE; + lockFar = FALSE; + lookupFar = FALSE; + flags = flags ^ (SHOW_CONTIG_FEATURES | SHOW_CONTIG_SOURCES | SHOW_FAR_TRANSLATION); + } + if (doLockFarComponents) { entityID = ObjMgrGetEntityIDForPointer (bsp); sep = GetTopSeqEntryForEntityID (entityID); @@ -1040,6 +1051,20 @@ static void PopulateFlatFile (BioseqViewPtr bvp, FmtType format, FlgType flags) bvp->bsplist = LockFarComponentsEx (sep, TRUE, FALSE, FALSE, NULL); } if (lookupFar) { + feats_with_product_count = 0; + sfp = SeqMgrGetNextFeature (bsp, NULL, 0, 0, &context); + while (sfp != NULL) { + if (sfp->product != NULL) { + feats_with_product_count++; + } + sfp = SeqMgrGetNextFeature (bsp, sfp, 0, 0, &context); + } + if (feats_with_product_count > 500) { + /* too many to lookup with current caching implementation */ + lookupFar = FALSE; + } + } + if (lookupFar) { hastpaaligns = FALSE; VisitDescriptorsInSep (sep, (Pointer) &hastpaaligns, LookForTpa); LookupFarSeqIDs (sep, TRUE, TRUE, TRUE, FALSE, hastpaaligns); diff --git a/desktop/salsa.c b/desktop/salsa.c index 9540fed9..90a3fa7f 100644 --- a/desktop/salsa.c +++ b/desktop/salsa.c @@ -28,7 +28,7 @@ * * Version Creation Date: 1/27/96 * -* $Revision: 6.159 $ +* $Revision: 6.160 $ * * File Description: * @@ -3418,6 +3418,7 @@ static Boolean SetupAlignDataSap (EditAlignDataPtr adp, SeqAlignPtr salp_origina if (adp == NULL || salp_original == NULL) return FALSE; + /*************************************/ /** check if all ->type are NOT 0 *** if all 0 -> all cached from CN3D viewer @@ -3428,6 +3429,12 @@ static Boolean SetupAlignDataSap (EditAlignDataPtr adp, SeqAlignPtr salp_origina if (newsalp== NULL) return FALSE; /**************************************/ + if (salp_original->segtype == SAS_DISC) + { + salp_original = (SeqAlignPtr) salp_original->segs; + } + + if ( salp_original->segtype == 1 ) { adp->blocks = create_list_alignedsegs (salp_original); @@ -4110,6 +4117,7 @@ static ForM CreateSeqAlignEditForm (Int2 left, Int2 top, CharPtr windowname, Seq if (salp==NULL) return NULL; + moltype = SeqAlignMolType(salp); if (moltype == 0) return NULL; @@ -5164,6 +5172,85 @@ extern Int2 LIBCALLBACK AlgEditFunc (Pointer data) return OM_MSG_RET_ERROR; } +/* opens window for editing alignment */ +static Int2 +FinishOpeningEditAlignmentWindow +(SeqAlignPtr salp, + OMProcControlPtr ompcp) +{ + SelStruct ss; + Char str [64]; + WindoW w; + SeqEditViewFormPtr wdp = NULL; + OMUserDataPtr omudp; + SeqAnnotPtr sap; + + ss.entityID = ompcp->input_entityID; + ss.itemID = ompcp->input_itemID; + ss.itemtype = ompcp->input_itemtype; + ss.regiontype =0; + ss.region = NULL; + + SeqIdWrite (SeqAlignId(salp, 0), str, PRINTID_REPORT, 64); + w = (WindoW) CreateSeqAlignEditForm (-40, -90, str, salp, &ss); + if (w != NULL) + { + wdp = (SeqEditViewFormPtr) GetObjectExtra (w); + if (wdp != NULL) + { + wdp->input_entityID = ompcp->input_entityID; + wdp->input_itemID = ompcp->input_itemID; + wdp->input_itemtype = ompcp->input_itemtype; + wdp->this_itemtype = OBJ_SEQALIGN; + wdp->this_subtype = 0; + wdp->procid = ompcp->proc->procid; + wdp->proctype = ompcp->proc->proctype; + wdp->userkey = OMGetNextUserKey (); + omudp = ObjMgrAddUserData (ompcp->input_entityID, ompcp->proc->procid, OMPROC_EDIT, wdp->userkey); + if (omudp != NULL) + { + omudp->userdata.ptrvalue = (Pointer) wdp; + omudp->messagefunc = BioseqEditMsgFunc; + } + checkEntityIDForMsg (wdp); + } + Show (w); + Update (); + CaptureSlateFocus ((SlatE) wdp->pnl); + Select (w); + + if (salp->segtype == 1) { + SeqAlignPtr tmp, newsalp; + Boolean ok; + EditAlignDataPtr adp; + + adp = GetAlignDataPanel(wdp->pnl); + for ( tmp=salp; tmp!=NULL; tmp=tmp->next) + { + if (tmp->type<1) + { + sap=adp->sap_original; + if (sap) + { + newsalp = (SeqAlignPtr)sap->data; + ok = SeqAlignIDCache (newsalp, SeqAlignId (tmp, 1)); + if (ok) + { +/* + if (adp->sap1_original) + SeqAlignIDCache ((SeqAlignPtr)adp->sap1_original->data, SeqIdFindBest (bsp->id, 0)); +*/ + repopulate_panel (w, adp, newsalp); + } + } + } + } + } + return OM_MSG_RET_DONE; + } + return OM_MSG_RET_ERROR; +} + /************************************************ *** *** AnnotAlgEditFunc : to launch SEQANNOT editor @@ -5171,14 +5258,10 @@ extern Int2 LIBCALLBACK AlgEditFunc (Pointer data) ************************************************/ extern Int2 LIBCALLBACK AnnotAlgEditFunc (Pointer data) { - WindoW w; SeqAnnotPtr sap; SeqAlignPtr salp = NULL; - SeqEditViewFormPtr wdp = NULL; OMProcControlPtr ompcp; - OMUserDataPtr omudp; - Char str [64]; - SelStruct ss; + Int2 rval = OM_MSG_RET_ERROR; ompcp = (OMProcControlPtr) data; if (ompcp == NULL || ompcp->proc == NULL) { @@ -5217,70 +5300,19 @@ extern Int2 LIBCALLBACK AnnotAlgEditFunc (Pointer data) if (salp == NULL) return OM_MSG_RET_ERROR; - ss.entityID = ompcp->input_entityID; - ss.itemID = ompcp->input_itemID; - ss.itemtype = ompcp->input_itemtype; - ss.regiontype =0; - ss.region = NULL; - - SeqIdWrite (SeqAlignId(salp, 0), str, PRINTID_REPORT, 64); - w = (WindoW) CreateSeqAlignEditForm (-40, -90, str, salp, &ss); - if (w != NULL) - { - wdp = (SeqEditViewFormPtr) GetObjectExtra (w); - if (wdp != NULL) - { - wdp->input_entityID = ompcp->input_entityID; - wdp->input_itemID = ompcp->input_itemID; - wdp->input_itemtype = ompcp->input_itemtype; - wdp->this_itemtype = OBJ_SEQALIGN; - wdp->this_subtype = 0; - wdp->procid = ompcp->proc->procid; - wdp->proctype = ompcp->proc->proctype; - wdp->userkey = OMGetNextUserKey (); - omudp = ObjMgrAddUserData (ompcp->input_entityID, ompcp->proc->procid, OMPROC_EDIT, wdp->userkey); - if (omudp != NULL) - { - omudp->userdata.ptrvalue = (Pointer) wdp; - omudp->messagefunc = BioseqEditMsgFunc; - } - checkEntityIDForMsg (wdp); - } - Show (w); - Update (); - CaptureSlateFocus ((SlatE) wdp->pnl); - Select (w); - -if (salp->segtype == 1) { -SeqAlignPtr tmp, newsalp; -Boolean ok; -EditAlignDataPtr adp; - - adp = GetAlignDataPanel(wdp->pnl); - for ( tmp=salp; tmp!=NULL; tmp=tmp->next) + if (salp->dim == 2) { - if (tmp->type<1) - { - sap=adp->sap_original; - if (sap) - { - newsalp = (SeqAlignPtr)sap->data; - ok = SeqAlignIDCache (newsalp, SeqAlignId (tmp, 1)); - if (ok) - { -/* - if (adp->sap1_original) - SeqAlignIDCache ((SeqAlignPtr)adp->sap1_original->data, SeqIdFindBest (bsp->id, 0)); -*/ - repopulate_panel (w, adp, newsalp); - } - } - } + rval = FinishOpeningEditAlignmentWindow (salp, ompcp); } -} - return OM_MSG_RET_DONE; + else + { + while (salp != NULL) + { + rval = FinishOpeningEditAlignmentWindow (salp, ompcp); + salp = salp->next; + } } - return OM_MSG_RET_ERROR; + return rval; } extern Int2 LIBCALLBACK AlgViewFunc (Pointer data) diff --git a/desktop/seqpanel.c b/desktop/seqpanel.c index 0d7797b2..3727bd00 100644 --- a/desktop/seqpanel.c +++ b/desktop/seqpanel.c @@ -1,4 +1,4 @@ -/* $Id: seqpanel.c,v 6.34 2004/04/13 16:52:26 bollin Exp $ +/* $Id: seqpanel.c,v 6.35 2004/05/20 20:10:20 bollin Exp $ * =========================================================================== * * PUBLIC DOMAIN NOTICE @@ -42,7 +42,7 @@ enum ESeqNum { eNumNone=1, eNumSide=2, eNumTop=3 }; enum ELineType { eTypeTopSeqNumbers, eTypeTopScaleMarks, eTypeSequence, - eTypeAlignSequence, eTypeFeature }; + eTypeAlignSequence, eTypeFeature, eTypeAlignDivider }; enum EDrawGrid { eDrawGridOn=1, eDrawGridOff=2 }; enum EShowFeatures { eShowFeaturesOn=1, eShowFeaturesOff=2, eShowFeaturesAll=3 }; @@ -214,22 +214,57 @@ static SeqPanLinePtr PNTR CreateSeqPanelLines(Int2 lineLength, BioseqViewPtr bvp Int4 lCount = 0, i, j; Int4 pCount; /* Total number of paragraphs */ Int4 alnRows = -1; - Int4 alnValidRows = 0; + Int4Ptr alnValidRows = NULL; Int4 featRows = 1; + SeqAlignPtr tmp_salp; + Int4Ptr lines_per_alignment = NULL; + Int4 num_alignments; + Int4 aln_idx; + SeqParaGPtr PNTR ref_offset; if (bvp->seqAlignMode) { - fLines = GetValue(bvp->newNumControl) == eNumTop ? 2 : 0; alnRows = AlnMgr2GetNumRows(bvp->salp); /* size of the alignment */ - if (bvp->viewWholeEntity || GetValue(bvp->newFeatControl) == eShowFeaturesAll) featRows = alnRows; /* show features for all rows */ - pCount = floor((AlnMgr2GetAlnLength(bvp->salp, FALSE)-1) / lineLength) + 1; /* alignment length */ - for (j = 1; j != alnRows + 1; j++) { /* AlnMgr counts from 1, not 0 */ - SeqIdPtr tmp_sip = AlnMgr2GetNthSeqIdPtr(bvp->salp, j); - BioseqPtr tmp_bsp = BioseqLockById(tmp_sip); - if (tmp_bsp != NULL) { - alnValidRows++; /* count avaliable alignments */ - BioseqUnlock (tmp_bsp); + fLines = GetValue(bvp->newNumControl) == eNumTop ? 2 : 0; + pCount = 0; + num_alignments = 0; + for (tmp_salp = bvp->salp; tmp_salp != NULL; tmp_salp = tmp_salp->next) + { + num_alignments ++; + } + lines_per_alignment = (Int4Ptr) MemNew (sizeof (Int4) * num_alignments); + if (lines_per_alignment == NULL) return; + alnValidRows = (Int4Ptr) MemNew (sizeof (Int4) * num_alignments); + if (alnValidRows == NULL) + { + MemFree (lines_per_alignment); + return; + } + for (i=0; i < num_alignments; i++) + { + lines_per_alignment [i] = 0; + alnValidRows [i] = 0; + } + for (tmp_salp = bvp->salp, aln_idx = 0; tmp_salp != NULL; tmp_salp = tmp_salp->next, aln_idx++) + { + lines_per_alignment [aln_idx] = floor((AlnMgr2GetAlnLength(tmp_salp, FALSE)-1) / lineLength) + 1; /* alignment length */ + pCount += lines_per_alignment [aln_idx]; + if (bvp->viewWholeEntity || GetValue(bvp->newFeatControl) == eShowFeaturesAll) + { + if (featRows == 1) + featRows = alnRows; + else + featRows += alnRows; + } /* show features for all rows */ + + for (j = 1; j != alnRows + 1; j++) { /* AlnMgr counts from 1, not 0 */ + SeqIdPtr tmp_sip = AlnMgr2GetNthSeqIdPtr(tmp_salp, j); + BioseqPtr tmp_bsp = BioseqLockById(tmp_sip); + if (tmp_bsp != NULL) { + alnValidRows [aln_idx]++; /* count avaliable alignments */ + BioseqUnlock (tmp_bsp); + } + SeqIdFree (tmp_sip); } - SeqIdFree (tmp_sip); } } else { fLines = GetValue(bvp->newNumControl) == eNumTop ? 3 : 1; @@ -241,68 +276,112 @@ static SeqPanLinePtr PNTR CreateSeqPanelLines(Int2 lineLength, BioseqViewPtr bvp ref[i] = (SeqParaGPtr) MemNew(sizeof(SeqParaG)); ref[i]->pFeatList = (ValNodePtr*) MemNew( (size_t)(sizeof(ValNodePtr)*featRows) ); } + ref_offset = ref; if (GetValue(bvp->newFeatControl) != eShowFeaturesOff) { if (bvp->seqAlignMode) { /* in alignment mode */ - for (i = 1; i != alnRows + 1; i++) { - SeqIdPtr sip_tmp = AlnMgr2GetNthSeqIdPtr(bvp->salp, i); - BioseqPtr bsp_tmp = BioseqLockById(sip_tmp); - - if (bsp_tmp != NULL) { - if (bvp->viewWholeEntity || GetValue(bvp->newFeatControl) == eShowFeaturesAll) { - FillFeatureInfo(bvp, bsp_tmp, lineLength, pCount, i, i - 1, ref); /* show features for each seq in alignment */ - } else if (i == bvp->TargetRow) { - FillFeatureInfo(bvp, bsp_tmp, lineLength, pCount, i, 0, ref); /* show features for target seq in alignment */ - } - BioseqUnlock (bsp_tmp); - } /* bsp_tmp != NULL */ - SeqIdFree (sip_tmp); - } /* for */ + for (tmp_salp = bvp->salp, aln_idx = 0; tmp_salp != NULL; tmp_salp = tmp_salp->next, aln_idx ++) + { + for (i = 1; i != alnRows + 1; i++) { + SeqIdPtr sip_tmp = AlnMgr2GetNthSeqIdPtr(tmp_salp, i); + BioseqPtr bsp_tmp = BioseqLockById(sip_tmp); + + if (bsp_tmp != NULL) { + /* TODO: Need to calculate better values for passing to FillFeatureInfo */ + if (bvp->viewWholeEntity || GetValue(bvp->newFeatControl) == eShowFeaturesAll) { + FillFeatureInfo(bvp, bsp_tmp, lineLength, lines_per_alignment [aln_idx], i, i - 1, ref_offset); /* show features for each seq in alignment */ + } else if (i == bvp->TargetRow) { + FillFeatureInfo(bvp, bsp_tmp, lineLength, lines_per_alignment [aln_idx], i, 0, ref_offset); /* show features for target seq in alignment */ + } + BioseqUnlock (bsp_tmp); + } /* bsp_tmp != NULL */ + SeqIdFree (sip_tmp); + } /* for */ + ref_offset += lines_per_alignment [aln_idx]; + } } else { FillFeatureInfo(bvp, bsp, lineLength, pCount, 0, 0, ref); } } /* done with features */ - bvp->TotalLines = 0; /* go through all pararaphs and count total */ - for (i = 0; i < pCount; i++) { - Int4 sub_total = 0; - for (j = 0; j < featRows; j++) sub_total += ValNodeLen(ref[i]->pFeatList[j]); - bvp->TotalLines += fLines + sub_total + (alnRows == -1 ? 0 : alnValidRows); /* reserve space for alignment */ + if (bvp->seqAlignMode) + { + for (tmp_salp = bvp->salp, aln_idx = 0; tmp_salp != NULL; tmp_salp = tmp_salp->next, aln_idx ++) + { + for (i = 0; i < lines_per_alignment [aln_idx]; i++) { + Int4 sub_total = 0; + for (j = 0; j < featRows; j++) sub_total += ValNodeLen(ref[i]->pFeatList[j]); + bvp->TotalLines += fLines + sub_total + (alnRows == -1 ? 0 : alnValidRows[aln_idx]); /* reserve space for alignment */ + } + /* add one more for divider */ + if (tmp_salp->next != NULL) bvp->TotalLines ++; + } + + } + else + { + for (i = 0; i < pCount; i++) { + Int4 sub_total = 0; + for (j = 0; j < featRows; j++) sub_total += ValNodeLen(ref[i]->pFeatList[j]); + bvp->TotalLines += fLines + sub_total; + } } + splp = (SeqPanLinePtr*) MemNew( (size_t)(sizeof(SeqPanLinePtr)*bvp->TotalLines) ); - for (i = 0; i < pCount; i++) { - if (fLines > 1) { /* Numbers on top */ - splp[lCount++] = MakeSeqPanLine(eTypeTopSeqNumbers, i); - splp[lCount++] = MakeSeqPanLine(eTypeTopScaleMarks, i); - } + if (bvp->seqAlignMode) + { + ref_offset = ref; + for (tmp_salp = bvp->salp, aln_idx = 0; tmp_salp != NULL; tmp_salp = tmp_salp->next, aln_idx ++) + { + for (i = 0; i < lines_per_alignment [aln_idx]; i++) + { + if (fLines > 1) { /* Numbers on top */ + splp[lCount++] = MakeSeqPanLine(eTypeTopSeqNumbers, i); + splp[lCount++] = MakeSeqPanLine(eTypeTopScaleMarks, i); + } - if (bvp->seqAlignMode) { - for (j = 1; j != alnRows + 1; j++) { /* AlnMgr counts from 1, not 0 */ - SeqIdPtr tmp_sip = AlnMgr2GetNthSeqIdPtr(bvp->salp, j); - BioseqPtr tmp_bsp = BioseqLockById(tmp_sip); + for (j = 1; j != alnRows + 1; j++) { /* AlnMgr counts from 1, not 0 */ + SeqIdPtr tmp_sip = AlnMgr2GetNthSeqIdPtr(tmp_salp, j); + BioseqPtr tmp_bsp = BioseqLockById(tmp_sip); - if (tmp_bsp != NULL) { - SeqPanLinePtr plp = MakeSeqPanLine(eTypeAlignSequence, i); /* Add align sequence line*/ - plp->row = j; /* Index position in the alignment (row) */ - splp[lCount++] = plp; - BioseqUnlock (tmp_bsp); + if (tmp_bsp != NULL) { + SeqPanLinePtr plp = MakeSeqPanLine(eTypeAlignSequence, i); /* Add align sequence line*/ + plp->row = j; /* Index position in the alignment (row) */ + splp[lCount++] = plp; + BioseqUnlock (tmp_bsp); - if (bvp->viewWholeEntity || GetValue(bvp->newFeatControl) == eShowFeaturesAll) { - MakeFeatureLine(&lCount, i, j, j - 1, ref, splp); /* Add feature line */ - } else if (j == bvp->TargetRow) { - MakeFeatureLine(&lCount, i, j, 0, ref, splp); + if (bvp->viewWholeEntity || GetValue(bvp->newFeatControl) == eShowFeaturesAll) { + MakeFeatureLine(&lCount, i, j, j - 1, ref_offset, splp); /* Add feature line */ + } else if (j == bvp->TargetRow) { + MakeFeatureLine(&lCount, i, j, 0, ref_offset, splp); + } } - } - SeqIdFree(tmp_sip); + SeqIdFree(tmp_sip); + } + } + /* add divider line between alignments */ + if (tmp_salp->next != NULL) + { + splp[lCount++] = MakeSeqPanLine (eTypeAlignDivider, i); + } + ref_offset += lines_per_alignment [aln_idx]; + } + + } + else + { + for (i = 0; i < pCount; i++) { + if (fLines > 1) { /* Numbers on top */ + splp[lCount++] = MakeSeqPanLine(eTypeTopSeqNumbers, i); + splp[lCount++] = MakeSeqPanLine(eTypeTopScaleMarks, i); } - } else { /* Add usual sequence and features if not in alignment mode */ splp[lCount++] = MakeSeqPanLine(eTypeSequence, i); /* Add sequence line */ - MakeFeatureLine(&lCount, i, 0, 0, ref, splp); /* Add feature line */ - } /* bvp->seqAlignMode */ - } /* for */ + MakeFeatureLine(&lCount, i, 0, 0, ref, splp); /* Add feature line */ + } + }/* bvp->seqAlignMode */ for (i = 0; i < pCount; i++) { for (j = 0; j < featRows; j++) ValNodeFree (ref[i]->pFeatList[j]); @@ -310,6 +389,8 @@ static SeqPanLinePtr PNTR CreateSeqPanelLines(Int2 lineLength, BioseqViewPtr bvp MemFree (ref[i]); } MemFree (ref); + MemFree (lines_per_alignment); + MemFree (alnValidRows); return splp; } @@ -488,30 +569,111 @@ static void PopulateSeqView (BioseqViewPtr bvp) PopulateSeqAlnView(bvp); } - static void PopulateAlnView (BioseqViewPtr bvp) { SeqIdPtr sip = bvp->bsp->id; + SeqIdPtr tmpsip; + SeqLocPtr slp; + SeqEntryPtr sep; + SeqAlignPtr tmp_salp, next_salp; + bvp->seqAlignMode = TRUE; bvp->SeqStartPosX = 150; + + /* if we're switching between segments we might need to load a + * different alignment */ + if (bvp->salp != NULL) + { + if ((bvp->bsp->repr != Seq_repr_seg && bvp->salp->next != NULL) + || (bvp->TargetRow = AlnMgr2GetFirstNForSip (bvp->salp, sip)) == -1) + { + bvp->salp = SeqAlignFree (bvp->salp); + } + else + { + PopulateSeqAlnView(bvp); + return; + } + } + if (bvp->salp == NULL && bvp->seqAlignMode) { /* Try to find an alignment */ - bvp->salp = SeqAlignListDup((SeqAlignPtr) FindSeqAlignInSeqEntry(bvp->bsp->seqentry, OBJ_SEQALIGN)); + /* need conglomerate view if we're looking at a segmented sequence */ + if (bvp->bsp->repr == Seq_repr_seg) + { + slp = (SeqLocPtr) bvp->bsp->seq_ext; + while (slp != NULL && bvp->salp == NULL) + { + tmpsip = SeqLocId (slp); + sep = SeqEntryFind (tmpsip); + bvp->salp = SeqAlignListDup((SeqAlignPtr) FindSeqAlignInSeqEntry(sep, OBJ_SEQALIGN)); + slp = slp->next; + } + } + else + { + bvp->salp = SeqAlignListDup((SeqAlignPtr) FindSeqAlignInSeqEntry(bvp->bsp->seqentry, OBJ_SEQALIGN)); + } + if (bvp->salp == NULL) { /* No alignment found or bug in AlignMgr (which is more likely). Switch to sequence mode */ PopulateSeqView(bvp); return; } - if (bvp->salp->segtype == SAS_DENSEG && bvp->salp->next == NULL) { - AlnMgr2IndexSingleChildSeqAlign(bvp->salp); - } else { - AlnMgr2IndexSeqAlign(bvp->salp); + + if (bvp->bsp->repr == Seq_repr_seg) + { + /* if segmented set, index each segment individually */ + tmp_salp = bvp->salp; + while (tmp_salp != NULL) + { + next_salp = tmp_salp->next; + tmp_salp->next = NULL; + if (tmp_salp->segtype == SAS_DENSEG) { + AlnMgr2IndexSingleChildSeqAlign(tmp_salp); + } else { + AlnMgr2IndexSeqAlign(tmp_salp); + } + tmp_salp->next = next_salp; + tmp_salp = next_salp; + } + } + else + { + /* do not incorporate other segments in segmented alignment */ + if (!is_dim2seqalign (bvp->salp) && bvp->salp->next != NULL) + { + bvp->salp->next = SeqAlignFree (bvp->salp->next); + } + + if (bvp->salp->segtype == SAS_DENSEG && bvp->salp->next == NULL) { + AlnMgr2IndexSingleChildSeqAlign(bvp->salp); + } else { + AlnMgr2IndexSeqAlign(bvp->salp); + } } } bvp->TargetRow = ROW_UNDEFINED; - while (sip && bvp->TargetRow == ROW_UNDEFINED) { - bvp->TargetRow = AlnMgr2GetFirstNForSip(bvp->salp, sip); - sip = sip->next; + if (bvp->bsp->repr == Seq_repr_seg) + { + slp = (SeqLocPtr) bvp->bsp->seq_ext; + while (slp != NULL && bvp->TargetRow == ROW_UNDEFINED) + { + tmpsip = SeqLocId (slp); + while (tmpsip && bvp->TargetRow == ROW_UNDEFINED) + { + bvp->TargetRow = AlnMgr2GetFirstNForSip(bvp->salp, tmpsip); + tmpsip = tmpsip->next; + } + slp = slp->next; + } } - + else + { + while (sip && bvp->TargetRow == ROW_UNDEFINED) { + bvp->TargetRow = AlnMgr2GetFirstNForSip(bvp->salp, sip); + sip = sip->next; + } + } + PopulateSeqAlnView(bvp); } @@ -557,6 +719,17 @@ static void DrawTopSeqNums(Int2 x, Int2 y, Int4 line, BioseqViewPtr bvp) } } +static void DrawAlignmentDivider (Int2 x, Int2 y, BioseqViewPtr bvp) +{ + Int2 block, ctr=0; + char buf[20]; + + Magenta (); + for (block = 0; block != bvp->BlocksAtLine && ctr >= 0; block++) { + sprintf(buf, "~~~~~~~~~~"); + PaintStringEx (buf, x+SEQ_X_OFFSET+bvp->SeqStartPosX+(block+1)*SEQ_GROUP_SIZE*bvp->CharWidth+block*bvp->CharWidth - bvp->CharWidth*StrLen(buf), y); + } +} static void DrawSeqSideLineNumbers(Int2 x, Int2 y, Int4 line, BioseqViewPtr bvp) { @@ -718,6 +891,7 @@ AlignmentIntervalToString MemSet(alnbuf, '-', alnbuf_len); /* assume all gaps and fill the sequence later */ MemSet(seqbuf, 0, alnbuf_len); + if (target_row < 0) return; if (stop > aln_len) { MemSet (alnbuf + aln_len - start, 0, stop - aln_len); @@ -847,20 +1021,28 @@ AlignmentIntervalToString } } -static void DrawAlignment(Int2 x, Int2 y, Int4 line, Int4 row, Uint1Ptr buf, Uint1Ptr seqbuf, Uint1Ptr alnbuf, BioseqViewPtr bvp) +static void DrawAlignment +(Int2 x, Int2 y, Int4 line, Int4 row, Uint1Ptr buf, Uint1Ptr seqbuf, + Uint1Ptr alnbuf, BioseqViewPtr bvp, Int4 aln_idx) { - Int2 block; - Char alnlabel[13]; - SeqIdPtr sip = AlnMgr2GetNthSeqIdPtr(bvp->salp, row); - BioseqPtr bsp = BioseqLockById(sip); - Int4 start = line * bvp->CharsAtLine; - Int4 stop = start + bvp->BlocksAtLine * SEQ_GROUP_SIZE; - Int4 alnbuf_len; - SeqIdPtr best_id; + Int2 block; + Char alnlabel[13]; + SeqIdPtr sip = AlnMgr2GetNthSeqIdPtr(bvp->salp, row); + BioseqPtr bsp = BioseqLockById(sip); + Int4 start = line * bvp->CharsAtLine; + Int4 stop = start + bvp->BlocksAtLine * SEQ_GROUP_SIZE; + Int4 alnbuf_len; + SeqIdPtr best_id; + SeqAlignPtr tmp_salp; + Int4 i; + + for (i=0, tmp_salp = bvp->salp; i < aln_idx && tmp_salp != NULL; i++, tmp_salp = tmp_salp->next) + { + } + if (tmp_salp == NULL) return; - AlignmentIntervalToString (bvp->salp, row, start, stop, bvp->TargetRow, + AlignmentIntervalToString (tmp_salp, row, start, stop, bvp->TargetRow, bvp->viewWholeEntity, seqbuf, alnbuf, &alnbuf_len); - /* finally draw everything */ best_id = SeqIdFindBestAccession (bsp->id); @@ -1148,6 +1330,8 @@ static void onDrawSeqPanel (PaneL p) RecT r; Int4 line; Int2 x, y; + Int4 aln_idx; + Int4 start; bvp = GetBioseqViewPtr (p); bsp = bvp->bsp; @@ -1165,7 +1349,18 @@ static void onDrawSeqPanel (PaneL p) y = r.top + bvp->CharHeight + SEQ_Y_OFFSET; SelectFont ((FonT)(bvp->displayFont)); - for (line = GetBarValue(sb); line < bvp->TotalLines && y <= r.bottom-2*SEQ_Y_OFFSET; line++) { + aln_idx = 0; + start = GetBarValue (sb); + for (line = 0; line < start && line < bvp->TotalLines; line++) + { + splp = bvp->SeqPanLines[line]; + if (splp->lineType == eTypeAlignDivider) + { + aln_idx++; + } + } + + for (line = start; line < bvp->TotalLines && y <= r.bottom-2*SEQ_Y_OFFSET; line++) { if (IsInRange(y, updateRect.top,updateRect.bottom) || IsInRange(y+bvp->LineHeight,updateRect.top,updateRect.bottom)) { @@ -1187,9 +1382,13 @@ static void onDrawSeqPanel (PaneL p) break; case eTypeAlignSequence: DrawAlignSideLineNumbers(x, y, splp->bioSeqLine, splp->row, bvp); - DrawAlignment(x, y, splp->bioSeqLine, splp->row, buf, seqbuf, alnbuf, bvp); /* Draw the alignment */ + DrawAlignment(x, y, splp->bioSeqLine, splp->row, buf, seqbuf, alnbuf, bvp, aln_idx); /* Draw the alignment */ if (bvp->DrawGrid) DrawLtGrid(x, y+bvp->LineSpace/2, r.right, y+bvp->LineSpace/2); break; + case eTypeAlignDivider: + DrawAlignmentDivider (x, y, bvp); + aln_idx++; + break; case eTypeFeature: if (bvp->DrawGrid) DrawLtGrid(x, y+bvp->LineSpace/2, r.right, y+bvp->LineSpace/2); DrawFeature(x, y, splp->bioSeqLine, splp->row, splp->idx, splp->protProduct, bsp, bvp); /* Draw Features */ diff --git a/desktop/vsm.c b/desktop/vsm.c index 01adaf06..a30aa559 100644 --- a/desktop/vsm.c +++ b/desktop/vsm.c @@ -29,7 +29,7 @@ * * Version Creation Date: 11-29-94 * -* $Revision: 6.15 $ +* $Revision: 6.16 $ * * File Description: * @@ -1062,12 +1062,22 @@ static void VSMDragAndDrop(VSMWinPtr vsmwp, Uint2 entityID, Uint2 itemID, Uint2 ompc.input_itemtype = vsmwp->itemtype1; ompc.do_not_reload_from_cache = TRUE; + if (! DetachDataForProc(&ompc, FALSE)) { ErrShow(); return; } + if (ompc.input_choicetype) + { + WarnIfAlignment (ompc.input_choicetype, ompc.input_choice, ompc.input_entityID); + } + else + { + WarnIfAlignment (ompc.input_itemtype, ompc.input_data, ompc.input_entityID); + } + if (! ompc.whole_entity) /* just a part gone, so need an update */ ObjMgrSendMsg(OM_MSG_DEL, ompc.input_entityID, ompc.input_itemID, ompc.input_itemtype); |