static void Cn3D_ExportPDBNow(ButtoN b) { Char path[256]; FILE *pFile; Int2 iTest; Int4 iCount = 0; PDNMS pdnmsMain = NULL; Int2Ptr i2Vec = NULL; i2Vec = PickedModels(&iCount); if (iCount == 0) { ErrClear(); ErrPostEx(SEV_INFO, 0, 0, "Nothing to save!"); ErrShow(); Disable(Cn3D_bPDBOk); return; } GetTitle(Cn3D_tPDBSave, path, sizeof(path)); pdnmsMain = GetSelectedModelstruc(); #ifdef WIN_MAC FileCreate(path, "TEXT", "ttxt"); #endif WatchCursor(); pFile = FileOpen(path, "w"); if (pFile) { iTest = WritePDBModelList(pdnmsMain, pFile, iCount, i2Vec); I2VectorFree(i2Vec, 0); if (!iTest) { ErrClear(); ErrPostEx(SEV_FATAL, 0, 0, "Unable to Export\nPossibly Corrupt Data in Memory!\n"); ErrShow(); } fflush(pFile); fclose(pFile); } else { ErrClear(); ErrPostEx(SEV_INFO, 0, 0, "Sorry, Unable to Open File:\n %s", path); ErrShow(); Disable(Cn3D_bPDBOk); I2VectorFree(i2Vec, 0); SetTitle(Cn3D_tPDBSave, "\0"); ArrowCursor(); return; } Remove(Cn3D_wPDBSave); Cn3D_EnableFileOps(); Cn3D_Export_InUse = FALSE; ArrowCursor(); return; }
static void HistoClickProc (PaneL pn, PoinT pt) { VieweR v; Uint2 segID, primID, primCt; SegmenT s; PrimitivE p; GraphViewFormPtr gvp; SeqIntPtr sint; PntInfo pnt; segID = 0; primID = 0; primCt = 0; v = (VieweR) pn; s = FindSegment (v, pt, &segID, &primID, &primCt); gvp = GetObjectExtra (v); if (primID < 1) { WatchCursor (); ExploreSegment (s, v, UnHLSeg); ObjMgrDeSelectAll (); ArrowCursor (); } else { WatchCursor (); ExploreSegment (s, v, UnHLSeg); ObjMgrDeSelectAll (); ArrowCursor (); p = GetPrimitive (s, primCt); HighlightPrimitive (v, s, p, FRAME_PRIMITIVE); gvp->slp = (SeqLocPtr) ValNodeNew (NULL); sint = SeqIntNew (); sint->id = SeqIdDup (gvp->bsp->id); if (primID == 1) sint->strand = Seq_strand_plus; else sint->strand = Seq_strand_minus; MapViewerToWorld (v, pt, &pnt); gvp->start = pnt.x * gvp->zoom; gvp->stop = gvp->start+gvp->window; sint->from = gvp->start; sint->to = gvp->stop; gvp->slp->choice = SEQLOC_INT; gvp->slp->data.ptrvalue = (Pointer) sint; ObjMgrSelect (gvp->entityID, gvp->itemID, OBJ_BIOSEQ, OM_REGION_SEQLOC, gvp->slp); } return; }
static Int2 LIBCALLBACK VSMGenericAsnSave (OMProcControlPtr ompcp, CharPtr mode ) { Char filename[255]; SelStructPtr ssp, sel; #ifdef WIN_MAC FILE * fp; #endif ValNodePtr entity_list = NULL, vnp; SelectedSaveData ssd; ssp = ObjMgrGetSelected(); if (ssp == NULL) { return OM_MSG_RET_ERROR; } for (sel = ssp; sel != NULL; sel = sel->next) { for (vnp = entity_list; vnp != NULL && vnp->data.intvalue != sel->entityID; vnp = vnp->next) {} if (vnp == NULL) { ValNodeAddInt (&entity_list, 0, sel->entityID); } } ssd.omp = ObjMgrGet(); /* get file name to use */ filename[0] = '\0'; if (GetOutputFileName(filename, (size_t)254, NULL)) { WatchCursor(); #ifdef WIN_MAC fp = FileOpen (filename, "r"); if (fp != NULL) { FileClose (fp); } else { FileCreate (filename, "TEXT", "ttxt"); } #endif ssd.aip = AsnIoOpen(filename, mode); ssd.ssp = ssp; for (vnp = entity_list; vnp != NULL; vnp = vnp->next) { SaveSeqLocEntity (vnp->data.intvalue, &ssd); GatherObjectsInEntity (vnp->data.intvalue, 0, NULL, SaveOneSelectedItem, (Pointer) &ssd, NULL); } ValNodeFree (entity_list); AsnIoClose(ssd.aip); ArrowCursor(); } return OM_MSG_RET_DONE; }
Int2 LIBCALLBACK VSMGenericTextAsnOpen ( Pointer data ) { Char filename[255]; Pointer ptr = NULL; Uint2 entityID, datatype; Int2 retval = OM_MSG_RET_ERROR; OMProcControlPtr ompcp; ompcp = (OMProcControlPtr)data; filename[0] = '\0'; if (GetInputFileName(filename, (size_t)254, NULL, NULL)) { WatchCursor(); ptr = ObjMgrGenericAsnTextFileRead (filename, &datatype, &entityID); ArrowCursor(); if (ptr == NULL) goto erret; ompcp->output_data = ptr; ompcp->output_entityID = entityID; PromoteToSeqEntry (entityID, datatype, ptr); retval = OM_MSG_RET_DONE; } else retval = OM_MSG_RET_OK; ret: return retval; erret: goto ret; }
Int2 LIBCALLBACK VSMFastaSortedProtSave (Pointer data) { OMProcControlPtr ompcp; Char filename[255]; FILE * fp; ValNode vn; SeqEntryPtr sep = NULL; ompcp = (OMProcControlPtr)data; if (ompcp == NULL) return OM_MSG_RET_ERROR; switch(ompcp->input_itemtype) { case OBJ_SEQENTRY: case OBJ_BIOSEQ: case OBJ_BIOSEQSET: break; default: ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can only write Seq-entry, Bioseq, or Bioseq-set"); return OM_MSG_RET_ERROR; } if (ompcp->input_choicetype == OBJ_SEQENTRY) sep = (SeqEntryPtr)(ompcp->input_choice); else { vn.next = NULL; vn.data.ptrvalue = ompcp->input_data; if (ompcp->input_itemtype == OBJ_BIOSEQ) vn.choice = 1; else vn.choice = 2; sep = &vn; } filename[0] = '\0'; if (GetOutputFileName(filename, (size_t)254, NULL)) { WatchCursor(); #ifdef WIN_MAC fp = FileOpen (filename, "r"); if (fp != NULL) { FileClose (fp); } else { FileCreate (filename, "TEXT", "ttxt"); } #endif fp = FileOpen(filename, "w"); WriteSortedProteinsToFile (fp, sep); FileClose(fp); ArrowCursor(); } return OM_MSG_RET_DONE; }
static void DuplicateViewProc (IteM i) { BaseFormPtr bfp; Int2 handled; Uint4 itemID; #ifdef WIN_MAC bfp = currentFormDataPtr; #else bfp = GetObjectExtra (i); #endif if (bfp == NULL) return; if (bfp->input_itemtype == OBJ_BIOSEQ) { WatchCursor (); itemID = bfp->input_itemID; if (itemID == 0) { itemID = 1; } handled = GatherProcLaunch (OMPROC_VIEW, FALSE, bfp->input_entityID, itemID, OBJ_BIOSEQ, 0, 0, OBJ_BIOSEQ, 0); ArrowCursor (); if (handled != OM_MSG_RET_DONE || handled == OM_MSG_RET_NOPROC) { Message (MSG_ERROR, "Unable to launch additional viewer."); } } else if (bfp->input_itemtype == OBJ_MEDLINE_ENTRY) { WatchCursor (); itemID = bfp->input_itemID; if (itemID == 0) { itemID = 1; } handled = GatherProcLaunch (OMPROC_VIEW, FALSE, bfp->input_entityID, itemID, OBJ_MEDLINE_ENTRY, 0, 0, OBJ_MEDLINE_ENTRY, 0); ArrowCursor (); if (handled != OM_MSG_RET_DONE || handled == OM_MSG_RET_NOPROC) { Message (MSG_ERROR, "Unable to launch additional viewer."); } } }
Int2 LIBCALLBACK VSMSaveSetsAsFiles (Pointer data) { Char filename[255]; SelStructPtr ssp, sel; ValNodePtr entity_list = NULL, vnp; SetSaveData ssd; OMProcControlPtr ompcp; ompcp = (OMProcControlPtr) data; ssp = ObjMgrGetSelected(); if (ssp == NULL) { Message (MSG_ERROR, "Nothing selected!"); return OM_MSG_RET_ERROR; } /* get file name to use */ filename[0] = '\0'; if (GetOutputFileName(filename, (size_t)254, NULL)) { WatchCursor(); ssd.file_base = filename; ssd.file_num = 1; ssd.sel = ssp; /* get list of entity IDs */ for (sel = ssp; sel != NULL; sel = sel->next) { if (sel->itemtype != OBJ_BIOSEQSET) { continue; } for (vnp = entity_list; vnp != NULL && vnp->data.intvalue != sel->entityID; vnp = vnp->next) {} if (vnp == NULL) { ValNodeAddInt (&entity_list, 0, sel->entityID); GatherObjectsInEntity (sel->entityID, 0, NULL, SaveSetsInOneSelectedSet, (Pointer) &ssd, NULL); } } ValNodeFree (entity_list); ArrowCursor(); } return OM_MSG_RET_DONE; }
static int DoXOPAlert(short dlogID, const char* title, const char* message) { DialogPtr theDialog; WindowRef theWindow; short hit; unsigned char temp[256]; int result = 0; ArrowCursor(); paramtext(message, "", "", ""); theDialog = GetNewDialog(dlogID, NULL, (WindowPtr)-1L); // This must access Igor's data fork which contains the DLOG resources for these dialogs. if (theDialog == NULL) return -1; theWindow = GetDialogWindow(theDialog); if (theWindow == NULL) return -1; CopyCStringToPascal(title, temp); SetWTitle(theWindow, temp); ShowDialogWindow(theDialog); do { ModalDialog(NULL, &hit); switch(hit) { case 1: // OK or Yes. result = 1; break; case 2: // No or Cancel. if (dlogID == IGOR_OK_CANCEL_DLOG) result = -1; // Cancel result is -1. else result = 2; break; case 3: // Cancel. result = -1; break; } } while(result == 0); DisposeDialog(theDialog); return result; }
static Int2 LIBCALLBACK VSMGenericFastaOpen ( Boolean is_na ) { Char filename[255]; FILE * fp; SeqEntryPtr sep; filename[0] = '\0'; if (GetInputFileName(filename, (size_t)254, NULL, NULL)) { WatchCursor(); fp = FileOpen(filename, "r"); while ((sep = FastaToSeqEntry(fp, is_na)) != NULL) ObjMgrRegister(OBJ_SEQENTRY, (Pointer)sep); FileClose(fp); ArrowCursor(); } return OM_MSG_RET_DONE; }
void PopCursor(void) { if (cursorpos) { int cct; cct = cursortypestack[--cursorpos]; if (cct != cursortype) { switch(cursortype) { case ARROWCURSOR: ArrowCursor(); break; case BOXCURSOR: BoxCursor(); break; } } } }
Int2 Main (void) { EntrezInfoPtr eip; PaneL p; RecT r; Char str [16]; Int2 val; WindoW w; /* #if defined(WIN16) #else PRGD prgdDict; #endif */ ErrSetFatalLevel (SEV_MAX); ErrClearOptFlags (EO_SHOW_USERSTR); ProcessUpdatesFirst (FALSE); /* if (! GetAppParam ("NCBI", "NCBI", NULL, NULL, str, sizeof (str) - 1)) { if (Message (MSG_YN, configMessage) == ANS_YES) { ShowNetConfigForm (ConfigFormActivated, ConfigFormMessage, ConfigAccepted, ConfigCancelled); ProcessEvents (); return 0; } else { Message (MSG_FATAL, "Entrez cannot run without ncbi configuration file"); } return 0; } if (! GetAppParam ("NCBI", "NCBI", NULL, NULL, str, sizeof (str) - 1)) { Message (MSG_FATAL, "Entrez cannot find ncbi configuration file"); return 0; } */ UseLocalAsnloadDataAndErrMsg (); SetupAppProperties (); SetupCommonFonts (); entrezRelease [0] = '\0'; sprintf (entrezVersion, "Entrez Application Version %s", ENTREZ_APP_VERSION); w = FixedWindow (-50, -33, -10, -10, "Entrez", NULL); p = SimplePanel (w, AboutBoxWidth (), 14 * stdLineHeight, DrawAbout); Show (w); #ifdef WIN_MOTIF Select (w); ObjectRect (p, &r); Select (p); InsetRect (&r, 3, 3); InvalRect (&r); #endif Update (); WatchCursor (); SetTitle (w, "Finding Entrez Data"); if (! EntrezBioseqFetchEnable ("Entrez", TRUE)) { ArrowCursor (); /* Message (MSG_FATAL, "Unable to connect to Entrez databases"); */ if (Message (MSG_YN, configMessage) == ANS_YES) { ShowNetConfigForm (ConfigFormActivated, ConfigFormMessage, ConfigAccepted, ConfigCancelled, NULL, TRUE); ProcessEvents (); return 0; } else { Message (MSG_FATAL, "Entrez cannot run connection to the data server"); } return 0; } ID1BioseqFetchEnable ("Entrez", TRUE); LocalSeqFetchInit (FALSE); #ifdef WIN_MAC SetDeactivate (NULL, MacDeactProc); SetupMacMenus (); #endif eip = EntrezGetInfo (); if (eip != NULL) { /* { AsnIoPtr aip; aip = AsnIoOpen ("eip", "w"); if (aip != NULL) { EntrezInfoAsnWrite (eip, aip, NULL); AsnIoClose (aip); } } */ sprintf (entrezRelease, "Entrez Data Release %d.%d", (int) eip->version, (int) eip->issue); Select (p); ObjectRect (p, &r); InsetRect (&r, 3, 3); InvalRect (&r); Update (); } SetTitle (w, "Loading parse tables"); if (! AllObjLoad ()) { ArrowCursor (); Message (MSG_FATAL, "AllObjLoad failed"); return 0; } if (! SubmitAsnLoad ()) { ArrowCursor (); Message (MSG_FATAL, "SubmitAsnLoad failed"); return 0; } SetTitle (w, "Loading print templates"); if (! PrintTemplateSetLoad ("objprt.prt")) { ArrowCursor (); Message (MSG_FATAL, "PrintTemplateSetLoad objprt.prt failed"); return 0; } if (! PrintTemplateSetLoad ("asn2ff.prt")) { ArrowCursor (); Message (MSG_FATAL, "PrintTemplateSetLoad asn2ff.prt failed"); return 0; } /* if (! PrintTemplateSetLoad ("makerpt.prt")) { ArrowCursor (); Message (MSG_FATAL, "PrintTemplateSetLoad makerpt.prt failed"); return 0; } */ SetTitle (w, "Loading sequence alphabet converter"); if (! SeqCodeSetLoad ()) { ArrowCursor (); Message (MSG_FATAL, "SeqCodeSetLoad failed"); return 0; } SetTitle (w, "Loading feature definitions"); if (! FeatDefSetLoad ()) { ArrowCursor (); Message (MSG_FATAL, "FeatDefSetLoad failed"); return 0; } if (! SetupPrintOptions ()) { ArrowCursor (); Message (MSG_FATAL, "StdPrintOptionsNew failed"); return 0; } /* #ifndef WIN16 SetTitle (w, "Loading structure dictionary"); if (OpenMMDBAPI ((POWER_VIEW ^ FETCH_ENTREZ), NULL)) { prgdDict = GetPRGDDictionary (); Cn3DWin_Entrez(NULL, TRUE); } #endif */ SetTitle (w, "Creating menus"); REGISTER_MEDLINE_VIEW; REGISTER_NEW_SEQENTRY_VIEW; VSMFileInit (); VSeqMgrInit (FALSE); SetTitle (w, "Creating window"); InitMuskStyles (); if (GetEntrezAppParam ("PREFERENCES", "DEFAULTSTYLE", "", str, sizeof (str))) { if (StrToInt (str, &val) && val >= 0) { SetMuskCurrentSt (GetMuskStyleName (val)); } } /* SetTitle (w, "Creating help window"); if (helpForm == NULL) { helpForm = CreateHelpForm (-95, -5, "Entrez Help", "entrez.hlp", HideHelpForm, HelpActivateProc); } */ SetTitle (w, "Creating initial window"); termListForm = CreateTermListForm (-70, -70, "Entrez1 Query", TermSelectionActivateProc, TermSelectionFormMessage); Remove (w); ArrowCursor (); if (termListForm != NULL) { Show (termListForm); Select (termListForm); Update (); docSumForm = CreateDocSumForm (-90, -10, "Entrez1 Document", DocumentSummaryActivateProc, DocumentSummaryFormMessage); UseDelayedNeighbor (docSumForm, TRUE); if (docSumForm != NULL) { ProcessEvents (); } else { Message (MSG_FATAL, "Unable to create document window"); } } else { Message (MSG_FATAL, "Unable to create term list window"); } WatchCursor (); val = GetMuskCurrentSt (); if (val < 0) { val = 0; } if (val >= GetMuskTotalSt ()) { val = 0; } if (val > 0) { sprintf (str, "%d", (int) val); SetEntrezAppParam ("PREFERENCES", "DEFAULTSTYLE", str); } else { SetEntrezAppParam ("PREFERENCES", "DEFAULTSTYLE", "0"); } CleanupEntrez (); ArrowCursor (); return 0; }
static void ConsignProc (ButtoN b) { XOSPtr xosp; XISPtr xisp; ComPatPtr cpp, cpph; ValNodePtr orflist; SeqLocPtr slp, slpn; Int4 start, stop; Uint1 strand; SeqPortPtr spp; Uint1Ptr aaseq; Int4 ntpos, aapos; Uint1 cdn[3]; SeqAlignPtr sap, sapn; FloatHi probcut; Int4 clustmin, findmin; Int4 i, n, endpos, XLength, XScale, shift; Int4 iframe, frame, top, orftop[6]; FloatHiPtr score, expandscore; FloatHi maxscore; Int4Ptr tableGlobal; SeqGraphPtr sgp, sgpn; WindoW w; VieweR v; GrouP g; SegmenT seg; GraphSentPtr gsp; Char numberbuffer[32]; if ((xosp = (XOSPtr) GetObjectExtra (b)) == NULL) return; if (xosp->bsp == NULL) { ErrPostEx (SEV_ERROR, TOP_ERROR, 101, "No Bioseq"); ErrShow (); return; } WatchCursor (); cpph = cpp = ReadPrositePattern (xosp->pattern_file, TRUE, -1, NULL, NULL); if (cpph == NULL) { ErrPostEx (SEV_ERROR, TOP_ERROR, 101, "read failed %s", xosp->pattern_file); ErrShow (); ArrowCursor (); return; } xosp->orflist = GetOrfList (xosp->bsp, (Int2) (xosp->orfcut)); xosp->orflist = ClearNonMetOrfs (xosp->orflist); orflist = xosp->orflist; while (orflist != NULL) { slp = (SeqLocPtr) orflist->data.ptrvalue; if (slp->choice == 0) { orflist = orflist->next; continue; } if (slp->choice == SEQLOC_MIX) slp = (SeqLocPtr) slp->data.ptrvalue; start = SeqLocStart (slp); stop = SeqLocStop (slp); strand = SeqLocStrand (slp); if (strand != Seq_strand_both) strand = Seq_strand_both; if (stop - start + 1 >= xosp->minimumseed) { spp = SeqPortNew (xosp->bsp, start, stop, strand, Seq_code_ncbi4na); aaseq = (Uint1Ptr) MemNew ((size_t) (sizeof (Uint1) * (((stop-start)/3)+2))); ntpos = start; aapos = 0; while (ntpos < start+3) { cdn[0] = SeqPortGetResidue (spp); ntpos++; cdn[1] = SeqPortGetResidue (spp); ntpos++; cdn[2] = SeqPortGetResidue (spp); ntpos++; aaseq[aapos] = AAForCodon (cdn, xosp->gcdi); aapos++; } while (ntpos <= stop) { cdn[0] = SeqPortGetResidue (spp); ntpos++; cdn[1] = SeqPortGetResidue (spp); ntpos++; cdn[2] = SeqPortGetResidue (spp); ntpos++; aaseq[aapos] = AAForCodon (cdn, xosp->gcd); aapos++; } SeqPortFree (spp); aaseq[aapos] = 0; cpp = cpph; while (cpp != NULL) { sap = PatternMatch (aaseq, 0, Seq_strand_plus, SeqLocId (slp), cpp, 0, Seq_strand_unknown, FALSE); if (sap != NULL) break; cpp = cpp->nextpattern; } MemFree (aaseq); if (sap != NULL) { SeqLocLink (&(xosp->slps), SeqLocDup (slp)); } while (sap != NULL) { sapn = sap->next; SeqAlignFree (sap); sap = sapn; } } orflist = orflist->next; } ComPatFree (cpph); orflist = xosp->orflist; while (orflist != NULL) { slp = (SeqLocPtr) orflist->data.ptrvalue; if (slp->choice > 0) SeqLocLink (&(xosp->slpa), SeqLocDup (slp)); while (slp != NULL) { slpn = slp->next; SeqLocFree (slp); slp = slpn; } orflist->data.ptrvalue = NULL; orflist = orflist->next; } xosp->orflist = ValNodeFree (xosp->orflist); probcut = xosp->probcut; clustmin = xosp->clustmin; findmin = xosp->findmin; xosp->slpb = FindSimilarBiasOrfs (xosp->sep, probcut, clustmin, findmin, xosp->slps, xosp->slpa); tableGlobal = CodonTableFromSeqLoc (xosp->bsp, xosp->slpb); seg = NULL; top = 0; xisp = (XISPtr) MemNew (sizeof (XIS)); frame = 0; for (iframe = 0; iframe < 6; iframe++) { endpos = (xosp->bsp->length + 3 - frame - xosp->window) / 3; if (iframe < 3) score = BiasScoreBioseq (xosp->bsp, tableGlobal, xosp->window, frame, Seq_strand_plus); else score = BiasScoreBioseq (xosp->bsp, tableGlobal, xosp->window, frame, Seq_strand_minus); maxscore = 0.0; for (i = 0; i < endpos; i++) if (score[i] > maxscore) maxscore = score[i]; expandscore = (FloatHiPtr) MemNew (sizeof (FloatHi) * xosp->bsp->length); for (i = 0; i < xosp->window/2; i++) expandscore[i] = maxscore; n = 0; while (i < xosp->bsp->length) { if (n < endpos) expandscore[i] = score[n]; else expandscore[i] = maxscore; i++; if (i%3 == 0) n++; } MemFree (score); score = expandscore; sgp = SeqGraphNew (); if (xisp->sgp == NULL) { xisp->sgp = sgp; } else { sgpn = xisp->sgp; while (sgpn->next != NULL) sgpn = sgpn->next; sgpn->next = sgp; } XLength = xosp->bsp->length; if (XLength > 1200) XLength = 1200; XScale = xosp->bsp->length / XLength; if (xosp->bsp->length % XLength != 0) XScale++; sgp->loc = SeqLocIntNew (0, xosp->bsp->length-1, xosp->bsp->strand, xosp->bsp->id); sgp->flags[2] = 1; sgp->numval = xosp->bsp->length; sgp->values = (Pointer) score; sgp->max.realvalue = maxscore; sgp->min.realvalue = 0.0; sgp->flags[1] = 1; sgp->a = 4.0; sgp->b = 0.0; if (seg == NULL) seg = CreatePicture (); if ((gsp = AddGraphSentinelToPicture (sgp, xosp->bsp, seg, 0, top, 0, NULL)) != NULL) { sprintf (numberbuffer, "%ld", 1L); AddLabel (seg, gsp->box.left, gsp->bottom-20, numberbuffer, SMALL_TEXT, 0, MIDDLE_CENTER, 0); sprintf (numberbuffer, "%ld", (long) xosp->bsp->length); AddLabel (seg, gsp->box.left+xosp->bsp->length, gsp->bottom-20, numberbuffer, SMALL_TEXT, 0, MIDDLE_CENTER, 0); } shift = (Int4) (maxscore*sgp->a); orftop[iframe] = top - shift - 38; top -= (shift+56); frame++; if (frame == 3) { top -= 24; frame = 0; } } frame = 0; for (iframe = 0; iframe < 6; iframe++) { if (iframe < 3) strand = Seq_strand_plus; else strand = Seq_strand_minus; shift = 0; if (xosp->slpa != NULL) { AddOrfClass (xosp->slpa, seg, orftop, iframe, frame, shift, strand, YELLOW_COLOR, 5); shift += 4; } if (xosp->slpk != NULL) { AddOrfClass (xosp->slpk, seg, orftop, iframe, frame, shift, strand, GREEN_COLOR, 5); shift += 4; } if (xosp->slpb != NULL) { AddOrfClass (xosp->slpb, seg, orftop, iframe, frame, shift, strand, BLUE_COLOR, 5); shift += 4; } if (xosp->slps != NULL) { AddOrfClass (xosp->slps, seg, orftop, iframe, frame, shift, strand, RED_COLOR, 5); } frame++; if (frame == 3) frame = 0; } MemFree (tableGlobal); start = 20; stop = 20 + (50*XScale); top = orftop[5] - 40; if (xosp->slpa != NULL) { top -= 12; AddAttribute (seg, (COLOR_ATT|STYLE_ATT|SHADING_ATT|WIDTH_ATT), YELLOW_COLOR, SOLID_LINE, SOLID_SHADING, 5, 0); AddLine (seg, start, top, stop, top, FALSE, 0); AddAttribute (seg, (COLOR_ATT|STYLE_ATT|SHADING_ATT|WIDTH_ATT), BLACK_COLOR, SOLID_LINE, SOLID_SHADING, STD_PEN_WIDTH, 0); AddLabel (seg, stop+(20*XScale), top, "All Met-init'd ORFs equal to or greater than 50 codons", SMALL_TEXT, 0, MIDDLE_RIGHT, 0); } if (xosp->slpk != NULL) { top -= 12; AddAttribute (seg, (COLOR_ATT|STYLE_ATT|SHADING_ATT|WIDTH_ATT), GREEN_COLOR, SOLID_LINE, SOLID_SHADING, 5, 0); AddLine (seg, start, top, stop, top, FALSE, 0); AddAttribute (seg, (COLOR_ATT|STYLE_ATT|SHADING_ATT|WIDTH_ATT), BLACK_COLOR, SOLID_LINE, SOLID_SHADING, STD_PEN_WIDTH, 0); AddLabel (seg, stop+(20*XScale), top, "Annotated (reported) ORFs", SMALL_TEXT, 0, MIDDLE_RIGHT, 0); } if (xosp->slpb != NULL) { top -= 12; AddAttribute (seg, (COLOR_ATT|STYLE_ATT|SHADING_ATT|WIDTH_ATT), BLUE_COLOR, SOLID_LINE, SOLID_SHADING, 5, 0); AddLine (seg, start, top, stop, top, FALSE, 0); AddAttribute (seg, (COLOR_ATT|STYLE_ATT|SHADING_ATT|WIDTH_ATT), BLACK_COLOR, SOLID_LINE, SOLID_SHADING, STD_PEN_WIDTH, 0); AddLabel (seg, stop+(20*XScale), top, "Similar codon usage bias ORFs to seed ORFs", SMALL_TEXT, 0, MIDDLE_RIGHT, 0); } if (xosp->slps != NULL) { top -= 12; AddAttribute (seg, (COLOR_ATT|STYLE_ATT|SHADING_ATT|WIDTH_ATT), RED_COLOR, SOLID_LINE, SOLID_SHADING, 5, 0); AddLine (seg, start, top, stop, top, FALSE, 0); AddAttribute (seg, (COLOR_ATT|STYLE_ATT|SHADING_ATT|WIDTH_ATT), BLACK_COLOR, SOLID_LINE, SOLID_SHADING, STD_PEN_WIDTH, 0); AddLabel (seg, stop+(20*XScale), top, "Pattern match seed ORFs", SMALL_TEXT, 0, MIDDLE_RIGHT, 0); } xisp->picture = seg; w = FixedWindow (10, 10, 640, 720, "Consign", CloseGraphWindowProc); SetObjectExtra (w, xisp, CleanUpGraphWindow); g = HiddenGroup (w, -1, 0, NULL); v = CreateViewer (g, 560, 640, TRUE, TRUE); AttachPicture (v, seg, INT4_MIN, INT4_MAX, UPPER_LEFT, XScale, 1, NULL); PushButton (g, "Close", CloseGraphWindowButton); RealizeWindow (w); ArrowCursor (); Show (w); return; }
static void ConsortProc (ButtoN b) { XOSPtr xosp; XISPtr xisp; TreeNodePtr ptrNode; WindoW w; VieweR v; GrouP g; SegmenT seg; Int4 xmax, xmin; Int4 xoffset, yoffset; if ((xosp = (XOSPtr) GetObjectExtra (b)) == NULL) return; if (xosp->sep == NULL) { ErrPostEx (SEV_ERROR, TOP_ERROR, 101, "No SeqEntry"); ErrShow (); return; } WatchCursor (); xoffset = xosp->xdeltaval; yoffset = xosp->ydeltaval; ptrNode = ConsortSeqEntry (xosp->sep); SetAllLeftRightRootedTreeNeighbors (ptrNode); SetAllPivotNodes (ptrNode); switch (xosp->treestyle) { default: case 0: SetAllTheoreticalCoordinates (ptrNode, 300, 50); AdjustAllTheoreticalCoordinates (ptrNode, 300); ChangeTreeScale (ptrNode, 300, 50, (FloatHi) xoffset, (FloatHi) yoffset); break; case 1: SetAllCoordinates (ptrNode, 300, 50, xoffset, yoffset); break; } xmin = GetMinimumTreeXcoord (ptrNode); if (xmin-50 > 0) ShiftTree (ptrNode, (-1*(xmin-50)), 0); if (xmin < 0) ShiftTree (ptrNode, ((-1*xmin)+50), 0); xmin = GetMinimumTreeXcoord (ptrNode); xmax = GetMaximumTreeXcoord (ptrNode); if (xmin < 0) xmin *= -1; if (xmax < 0) xmax *= -1; xisp = (XISPtr) MemNew (sizeof (XIS)); if (xmax > xmin) xisp->Xdelta = (2*(xmax+100)) + 10; else xisp->Xdelta = (2*(xmin+100)) + 10; seg = DrawTree (ptrNode); xisp->picture = seg; w = FixedWindow (10, 10, 640, 640, "Consort", CloseGraphWindowProc); SetObjectExtra (w, xisp, CleanUpGraphWindow); g = HiddenGroup (w, -1, 0, NULL); v = CreateViewer (g, 560, 560, TRUE, TRUE); AttachPicture (v, seg, INT4_MIN, INT4_MAX, UPPER_LEFT, 1, 1, NULL); PushButton (g, "Close", CloseGraphWindowButton); RealizeWindow (w); ArrowCursor (); Show (w); return; }
static void Cn3D_ExportKinNow(ButtoN b) { Char path[256]; FILE *pFile; Int2 iTest; Int4 iCount = 0; PDNMS pdnmsMain = NULL; Int2 iColor = 0; Byte bRender = 0; Int2Ptr i2Vec = NULL; i2Vec = PickedModels(&iCount); if (iCount == 0) { ErrClear(); ErrPostEx(SEV_INFO, 0, 0, "Nothing to save!"); ErrShow(); Disable(Cn3D_bKinOk); return; } GetTitle(Cn3D_tKinSave, path, sizeof(path)); iColor = GetValue(Cn3D_gColorAtoms); bRender = KIN_DEFAULT; if (GetStatus(Cn3D_bRender[0]) == TRUE) bRender = bRender | (Byte) KIN_VIRTUAL; if (GetStatus(Cn3D_bRender[1]) == TRUE) bRender = bRender | (Byte) KIN_BACKBONE; if (GetStatus(Cn3D_bRender[2]) == TRUE) bRender = bRender | (Byte) KIN_RESIDUE; if (GetStatus(Cn3D_bRender[3]) == TRUE) bRender = bRender | (Byte) KIN_HET; if (GetStatus(Cn3D_bRender[4]) == TRUE) bRender = bRender | (Byte) KIN_ALTCONF; if (GetStatus(Cn3D_bRender[5]) == TRUE) bRender = bRender | (Byte) KIN_MULTANIM; pdnmsMain = GetSelectedModelstruc(); #ifdef WIN_MAC FileCreate(path, "TEXT", "ttxt"); #endif WatchCursor(); pFile = FileOpen(path, "w"); if (pFile) { iTest = WriteKinModelList(pdnmsMain, pFile, iColor, bRender, iCount, i2Vec); I2VectorFree(i2Vec, 0); if (!iTest) { ErrClear(); ErrPostEx(SEV_FATAL, 0, 0, "Unable to Export\nPossibly Corrupt Data in Memory!\n"); ErrShow(); } fflush(pFile); fclose(pFile); } else { ErrClear(); ErrPostEx(SEV_INFO, 0, 0, "Sorry, Unable to Open File:\n %s", path); ErrShow(); Disable(Cn3D_bKinOk); I2VectorFree(i2Vec, 0); SetTitle(Cn3D_tKinSave, "\0"); ArrowCursor(); return; } Remove(Cn3D_wKinSave); Cn3D_EnableFileOps(); Cn3D_Export_InUse = FALSE; ArrowCursor(); return; }
Int2 LIBCALLBACK VSMDescriptorAsnSave (Pointer data) { OMProcControlPtr ompcp; Char filename[255]; SelStructPtr ssp, sel; SeqDescrPtr sdp; BioseqPtr bsp; SeqEntryPtr sep; SeqMgrDescContext dcontext; #ifdef WIN_MAC FILE * fp; #endif ValNodePtr vnp; SaveSetSdpData sd; ValNodePtr obj_list = NULL; ompcp = (OMProcControlPtr)data; if (ompcp == NULL) return OM_MSG_RET_ERROR; sd.already_have_molinfo = FALSE; ssp = ObjMgrGetSelected(); if (ssp == NULL) { Message (MSG_ERROR, "You must select a sequence or set from which descriptors should be saved"); return OM_MSG_RET_DONE; } else { for (sel = ssp; sel != NULL; sel = sel->next) { GatherItem (sel->entityID, sel->itemID, sel->itemtype, (Pointer) &obj_list, AddToSaveList); } } /* get file name to use */ filename[0] = '\0'; if (GetOutputFileName(filename, (size_t)254, NULL)) { WatchCursor(); #ifdef WIN_MAC fp = FileOpen (filename, "r"); if (fp != NULL) { FileClose (fp); } else { FileCreate (filename, "TEXT", "ttxt"); } #endif sd.aip = AsnIoOpen(filename, "w"); for (vnp = obj_list; vnp != NULL; vnp = vnp->next) { switch (vnp->choice) { case OBJ_SEQDESC: sdp = (SeqDescrPtr) vnp->data.ptrvalue; SeqDescAsnWrite (sdp, sd.aip, NULL); AsnPrintNewLine (sd.aip); AsnIoFlush (sd.aip); break; case OBJ_BIOSEQ: bsp = (BioseqPtr) vnp->data.ptrvalue; for (sdp = SeqMgrGetNextDescriptor (bsp, NULL, 0, &dcontext); sdp != NULL; sdp = SeqMgrGetNextDescriptor (bsp, sdp, 0, &dcontext)) { if (sdp->choice != Seq_descr_source && sdp->choice != Seq_descr_pub && sdp->choice != Seq_descr_molinfo && sdp->choice != Seq_descr_comment) continue; SeqDescAsnWrite (sdp, sd.aip, NULL); AsnPrintNewLine (sd.aip); AsnIoFlush (sd.aip); } break; case OBJ_BIOSEQSET: sep = SeqMgrGetSeqEntryForData (vnp->data.ptrvalue); VisitDescriptorsInSep (sep, &sd, SaveSetDescriptors); break; } } AsnIoClose(sd.aip); ArrowCursor(); } return OM_MSG_RET_DONE; }
static Int2 LIBCALLBACK MatrixMsgFunc (OMMsgStructPtr ommsp) { OMUserDataPtr omudp; GraphViewFormPtr gvp; SeqGraphPtr sgp; VieweR v; PoinT pt; PntInfo pw; Uint2 segID, primID, primCt; SegmenT s; PrimitivE p; Int4 pos; FloatHi maxVal; if ((omudp = (OMUserDataPtr) (ommsp->omuserdata)) == NULL) return OM_MSG_RET_ERROR; if ((gvp = (GraphViewFormPtr) (omudp->userdata.ptrvalue)) == NULL) return OM_MSG_RET_ERROR; switch (ommsp->message) { case OM_MSG_SELECT: if (ommsp->itemtype == OBJ_BIOSEQ) { if (ommsp->regiontype == OM_REGION_SEQLOC) { if ((sgp = gvp->sgp) == NULL) return OM_MSG_RET_ERROR; switch (sgp->flags[2]) { default: case 1: maxVal = sgp->max.realvalue; break; case 2: case 3: maxVal = (FloatHi) sgp->max.intvalue; break; } if (gvp->slp != NULL) { v = gvp->viewer; pt.x = 0; pt.y = 0; s = FindSegment (v, pt, &segID, &primID, &primCt); ExploreSegment (s, v, UnHLSeg); /* ObjMgrDeSelectAll (); gvp->slp = NULL; */ } pos = SeqLocStart ((SeqLocPtr) ommsp->region); pos += SeqLocStop ((SeqLocPtr) ommsp->region); pos /= 2; pos /= gvp->zoom; pw.x = (Int2) pos; if (SeqLocStrand ((SeqLocPtr) ommsp->region) == Seq_strand_plus) { pw.y = (Int2) (gvp->margin + ((Int4) (1.0 + (maxVal/2)) * sgp->a) + (Int4) sgp->b); } else { pw.y = (Int2) (gvp->margin + ((Int4) (maxVal - 1.0 - (maxVal/2)) * sgp->a) + (Int4) sgp->b); } v = gvp->viewer; primID = 0; MapWorldToViewer (v, pw, &pt); s = FindSegment (v, pt, &segID, &primID, &primCt); if (primID < 1 || s == NULL) return OM_MSG_RET_ERROR; p = GetPrimitive (s, primCt); WatchCursor (); ExploreSegment (s, v, UnHLSeg); ArrowCursor (); HighlightPrimitive (v, s, p, FRAME_PRIMITIVE); /* DUP/memcp and delta id gvp->slp = (Pointer) (ommsp->region); */ /* ObjMgrSelect (gvp->entityID, gvp->itemID, OBJ_BIOSEQ, OM_REGION_SEQLOC, gvp->slp); */ } } break; case OM_MSG_DESELECT: if (ommsp->itemtype == OBJ_BIOSEQ) { if (ommsp->regiontype == OM_REGION_SEQLOC) { if (gvp->slp != NULL) { /* v = gvp->viewer; pt.x = 0; pt.y = 0; s = FindSegment (v, pt, &segID, &primID, &primCt); ExploreSegment (s, v, UnHLSeg); ObjMgrDeSelectAll (); gvp->slp = NULL; */ } } } break; case OM_MSG_DEL: case OM_MSG_CREATE: case OM_MSG_UPDATE: case OM_MSG_CACHED: case OM_MSG_UNCACHED: case OM_MSG_TO_CLIPBOARD: break; default: break; } return OM_MSG_RET_OK; }
Int2 LIBCALLBACK VSMFastaProtSaveWithProduct ( Pointer data ) { Char filename[255]; FastaExportOptionsData fe; ValNode vn; SeqEntryPtr sep = NULL; SeqFeatPtr sfp; SeqLocPtr slp; Uint1 code; BioseqPtr bsp; OMProcControlPtr ompcp; if ((ompcp = (OMProcControlPtr) data) == NULL) { return OM_MSG_RET_ERROR; } sfp = NULL; switch(ompcp->input_itemtype) { case OBJ_SEQENTRY: case OBJ_BIOSEQ: case OBJ_BIOSEQSET: break; case OBJ_SEQFEAT: sfp = (SeqFeatPtr) ompcp->input_data; if (sfp == NULL || (sfp->data.choice != SEQFEAT_CDREGION && sfp->data.choice != SEQFEAT_PROT)) return OM_MSG_RET_ERROR; break; default: ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can only write Seq-entry, Bioseq, or Bioseq-set"); return OM_MSG_RET_ERROR; } if (sfp != NULL) { } else if (ompcp->input_choicetype == OBJ_SEQENTRY) sep = (SeqEntryPtr)(ompcp->input_choice); else { vn.next = NULL; vn.data.ptrvalue = ompcp->input_data; if (ompcp->input_itemtype == OBJ_BIOSEQ) vn.choice = 1; else vn.choice = 2; sep = &vn; } filename[0] = '\0'; if (GetOutputFileName(filename, (size_t)254, NULL)) { WatchCursor(); #ifdef WIN_MAC fe.fp = FileOpen (filename, "r"); if (fe.fp != NULL) { FileClose (fe.fp); } else { FileCreate (filename, "TEXT", "ttxt"); } #endif fe.fp = FileOpen(filename, "w"); if (sfp != NULL) { code = Seq_code_ncbieaa; slp = sfp->location; if (sfp->data.choice == SEQFEAT_CDREGION) { slp = sfp->product; } bsp = GetBioseqGivenSeqLoc (slp, ompcp->input_entityID); if (slp != NULL && bsp != NULL) { SeqLocFastaStream (slp, fe.fp, STREAM_EXPAND_GAPS | STREAM_CORRECT_INVAL, 70, 0, 0); } } else { fe.flags = STREAM_EXPAND_GAPS | STREAM_CORRECT_INVAL; fe.linelen = 70; fe.blocklen = 0; fe.grouplen = 0; VisitBioseqsInSep (sep, &fe, WriteOneProteinWithProduct); } FileClose(fe.fp); ArrowCursor(); } return OM_MSG_RET_DONE; }
static Int2 LIBCALLBACK VSMGenericFastaSave (OMProcControlPtr ompcp, Boolean is_na) { Char filename[255]; FILE * fp; ValNode vn; SeqEntryPtr sep = NULL; SeqFeatPtr sfp; SeqLocPtr slp; Uint1 code; BioseqPtr bsp; sfp = NULL; switch(ompcp->input_itemtype) { case OBJ_SEQENTRY: case OBJ_BIOSEQ: case OBJ_BIOSEQSET: break; case OBJ_SEQFEAT: sfp = (SeqFeatPtr) ompcp->input_data; if (sfp == NULL) return OM_MSG_RET_ERROR; break; default: ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can only write Seq-entry, Bioseq, or Bioseq-set"); return OM_MSG_RET_ERROR; } if (sfp != NULL) { } else if (ompcp->input_choicetype == OBJ_SEQENTRY) sep = (SeqEntryPtr)(ompcp->input_choice); else { vn.next = NULL; vn.data.ptrvalue = ompcp->input_data; if (ompcp->input_itemtype == OBJ_BIOSEQ) vn.choice = 1; else vn.choice = 2; sep = &vn; } filename[0] = '\0'; if (GetOutputFileName(filename, (size_t)254, NULL)) { WatchCursor(); #ifdef WIN_MAC fp = FileOpen (filename, "r"); if (fp != NULL) { FileClose (fp); } else { FileCreate (filename, "TEXT", "ttxt"); } #endif fp = FileOpen(filename, "w"); if (sfp != NULL) { if (is_na) code = Seq_code_iupacna; else code = Seq_code_ncbieaa; slp = sfp->location; if (sfp->data.choice == SEQFEAT_CDREGION && (! is_na)) { slp = sfp->product; } /* spp = SeqPortNewByLoc (slp, code); */ bsp = GetBioseqGivenSeqLoc (slp, ompcp->input_entityID); /* if (spp != NULL && bsp != NULL) { while (FastaSeqLine(spp, buf, 70, is_na)) FastaFileFunc(bsp, FASTA_SEQLINE, buf, sizeof (buf), (Pointer)fp); SeqPortFree(spp); FastaFileFunc(bsp, FASTA_EOS, buf, sizeof (buf), (Pointer)fp); } */ if (slp != NULL && bsp != NULL) { SeqLocFastaStream (slp, fp, STREAM_EXPAND_GAPS | STREAM_CORRECT_INVAL, 70, 0, 0); } } else { /* SeqEntryToFasta(sep, fp, is_na); */ SeqEntryFastaStreamEx (sep, fp, STREAM_EXPAND_GAPS | STREAM_CORRECT_INVAL, 70, 0, 0, is_na, !is_na, FALSE, !is_na, FALSE); } FileClose(fp); ArrowCursor(); } return OM_MSG_RET_DONE; }
Int2 LIBCALLBACK VSMGenericBinAsnOpen ( Pointer data ) { Char filename[255]; AsnIoPtr aip; Pointer ptr; Uint2 entityID; Int2 ct, i, retval = OM_MSG_RET_OK; ObjMgrPtr omp; ObjMgrTypePtr omtp = NULL; OMProcControlPtr ompcp; WindoW w; GrouP g; ButtoN b; VSMReadBinStr vrb; VSeqMgrPtr vsmp; ompcp = (OMProcControlPtr)data; vsmp = VSeqMgrGet(); omp = vsmp->omp; filename[0] = '\0'; if (GetInputFileName(filename, (size_t)254, NULL, NULL)) { vrb.do_it = FALSE; vrb.window_done = FALSE; vrb.the_type = 0; w = ModalWindow (-50, -33, -10, -10, NULL); SetWindowExtra(w, &vrb, NULL); g = HiddenGroup(w, 0, 2, NULL); StaticPrompt(g, "Select ASN.1 type:", 0,0,systemFont,'l'); vrb.p = PopupList(g, TRUE, NULL); i = 0; ct = 0; omtp = NULL; while ((omtp = ObjMgrTypeFindNext(omp, omtp)) != NULL) { if (omtp->asnname != NULL) { i++; PopupItem(vrb.p, omtp->asnname); if (! StringCmp(vsmp->lastASNtype, omtp->asnname)) ct = i; } } if (! i) { ErrPostEx(SEV_ERROR,0,0, "No ASN.1 types are registered"); Remove(w); return OM_MSG_RET_ERROR; } if (! ct) ct = 1; SetValue(vrb.p, ct); g = HiddenGroup(w, 2, 0, NULL); DefaultButton(g, "Accept", AsnBinAcceptProc); b = PushButton(g, "Cancel", AsnBinCancelProc); Show(w); Nlm_WaitForCondition (! vrb.window_done); ProcessAnEvent(); if (! vrb.do_it) return retval; i = 0; omtp = NULL; while ((omtp = ObjMgrTypeFindNext(omp, omtp)) != NULL) { i++; if (i == vrb.the_type) break; } if (omtp == NULL) { ErrPostEx(SEV_ERROR,0,0,"Couldn't find vrb.the_type"); return OM_MSG_RET_ERROR; } StringMove(vsmp->lastASNtype, omtp->asnname); WatchCursor(); aip = AsnIoOpen(filename, "rb"); ptr = (*(omtp->asnread))(aip, NULL); AsnIoClose(aip); if (ptr == NULL) { ErrPostEx(SEV_ERROR,0,0,"Couldn't read [%s], type [%s]", filename, omtp->asnname); retval = OM_MSG_RET_ERROR; } else { entityID = ObjMgrRegister(omtp->datatype, ptr); ompcp->output_data = ptr; ompcp->output_entityID = entityID; PromoteToSeqEntry (entityID, omtp->datatype, ptr); retval = OM_MSG_RET_DONE; } ArrowCursor(); } else retval = OM_MSG_RET_OK; return retval; }
static Int2 LIBCALLBACK FilterMsgFunc (OMMsgStructPtr ommsp) { OMUserDataPtr omudp; GraphViewFormPtr gvp; SeqGraphPtr sgp; VieweR v; PoinT pt; PntInfo pw; Uint2 segID, primID, primCt, start, end, i; SegmenT s; PrimitivE p; FloatHi fval; Int4 pos; FloatHi maxVal, minVal; if ((omudp = (OMUserDataPtr) (ommsp->omuserdata)) == NULL) return OM_MSG_RET_ERROR; if ((gvp = (GraphViewFormPtr) (omudp->userdata.ptrvalue)) == NULL) return OM_MSG_RET_ERROR; switch (ommsp->message) { case OM_MSG_SELECT: if (ommsp->itemtype == OBJ_BIOSEQ) { if (ommsp->regiontype == OM_REGION_SEQLOC) { if ((sgp = gvp->sgp) == NULL) return OM_MSG_RET_ERROR; switch (sgp->flags[2]) { default: case 1: maxVal = sgp->max.realvalue; minVal = sgp->min.realvalue; break; case 2: case 3: maxVal = (FloatHi) sgp->max.intvalue; minVal = (FloatHi) sgp->min.intvalue; break; } if (gvp->slp != NULL) { v = gvp->viewer; pt.x = 0; pt.y = 0; s = FindSegment (v, pt, &segID, &primID, &primCt); ExploreSegment (s, v, UnHLSeg); /* ObjMgrDeSelectAll (); gvp->slp = NULL; */ } pos = SeqLocStart ((SeqLocPtr) ommsp->region); pos /= gvp->zoom; pw.x = (Int2) pos; v = gvp->viewer; primID = 0; fval = minVal - 1; while (primID < 1 && fval < maxVal) { fval++; pw.y = (Int2) (gvp->margin + ((Int4) (fval * sgp->a)) + (Int4) sgp->b); MapWorldToViewer (v, pw, &pt); s = FindSegment (v, pt, &segID, &primID, &primCt); } if (primCt == 0 && fval == maxVal) return OM_MSG_RET_ERROR; if (s == NULL) return OM_MSG_RET_ERROR; start = primCt; pos = SeqLocStop ((SeqLocPtr) ommsp->region); pos /= gvp->zoom; pw.x = (Int2) pos; primID = 0; fval = minVal - 1; while (primID < 1 && fval < maxVal) { fval++; pw.y = (Int2) (gvp->margin + ((Int4) (fval * sgp->a)) + (Int4) sgp->b); MapWorldToViewer (v, pw, &pt); s = FindSegment (v, pt, &segID, &primID, &primCt); } if (primCt == 0 || fval == maxVal) return OM_MSG_RET_ERROR; if (s == NULL) return OM_MSG_RET_ERROR; end = primCt; if (start > end) return OM_MSG_RET_ERROR; WatchCursor (); ExploreSegment (s, v, UnHLSeg); ArrowCursor (); for (i = start; i < end; i++) { p = GetPrimitive (s, i); HighlightPrimitive (v, s, p, FRAME_PRIMITIVE); } /* DUP/memcp and delta id gvp->slp = (Pointer) (ommsp->region); */ /* ObjMgrSelect (gvp->entityID, gvp->itemID, OBJ_BIOSEQ, OM_REGION_SEQLOC, gvp->slp); */ } } break; case OM_MSG_DESELECT: if (ommsp->itemtype == OBJ_BIOSEQ) { if (ommsp->regiontype == OM_REGION_SEQLOC) { if (gvp->slp != NULL) { /* v = gvp->viewer; pt.x = 0; pt.y = 0; s = FindSegment (v, pt, &segID, &primID, &primCt); ExploreSegment (s, v, UnHLSeg); ObjMgrDeSelectAll (); gvp->slp = NULL; */ } } } break; case OM_MSG_DEL: case OM_MSG_CREATE: case OM_MSG_UPDATE: case OM_MSG_CACHED: case OM_MSG_UNCACHED: case OM_MSG_TO_CLIPBOARD: break; default: break; } return OM_MSG_RET_OK; }
static void GraphClickProc (PaneL pn, PoinT pt) { VieweR v; Uint2 segID, primID, primCt, start, end, i; SegmenT s; PrimitivE p; GraphViewFormPtr gvp; SeqIntPtr sint; PntInfo pnt; segID = 0; primID = 0; primCt = 0; v = (VieweR) pn; s = FindSegment (v, pt, &segID, &primID, &primCt); p = GetPrimitive (s, primCt); if (primID == 0) return; gvp = GetObjectExtra (v); if (gvp->flagNewClick) { WatchCursor (); ExploreSegment (s, v, UnHLSeg); ArrowCursor (); HighlightPrimitive (v, s, p, FRAME_PRIMITIVE); gvp->flagNewClick = FALSE; gvp->HLRange = primCt; MapViewerToWorld (v, pt, &pnt); gvp->start = pnt.x * gvp->zoom; } else { start = gvp->HLRange; if (start < primCt) end = (Uint2) (primCt + 1); else { start = primCt; end = (Uint2) (gvp->HLRange + 1); } for (i = start; i < end; i++) { p = GetPrimitive (s, i); HighlightPrimitive (v, s, p, FRAME_PRIMITIVE); } if (gvp->slp != NULL) { ObjMgrDeSelect (gvp->entityID, gvp->itemID, OBJ_BIOSEQ, OM_REGION_SEQLOC, gvp->slp); /* gvp->slp = SeqLocFree (gvp->slp); */ gvp->slp = NULL; } gvp->slp = (SeqLocPtr) ValNodeNew (NULL); sint = SeqIntNew (); sint->id = SeqIdDup (gvp->bsp->id); sint->strand = Seq_strand_plus; MapViewerToWorld (v, pt, &pnt); gvp->stop = pnt.x * gvp->zoom; if (gvp->start < gvp->stop) { sint->from = gvp->start; sint->to = gvp->stop; } else { sint->from = gvp->stop; sint->to = gvp->start; } gvp->slp->choice = SEQLOC_INT; gvp->slp->data.ptrvalue = (Pointer) sint; ObjMgrSelect (gvp->entityID, gvp->itemID, OBJ_BIOSEQ, OM_REGION_SEQLOC, gvp->slp); /* ObjMgrAlsoSelect for loop thru slp's */ /* have to clone each slp added to chain and pass clone to OM */ gvp->flagNewClick = TRUE; } return; }
Int2 LIBCALLBACK FilterDustFunc (Pointer data) { OMProcControlPtr ompcp; BioseqPtr bsp; GraphViewFormPtr gvp; WindoW w; OMUserDataPtr omudp; SeqPortPtr spp; Int4 exval[4]; ompcp = (OMProcControlPtr) data; if (ompcp == NULL || ompcp->input_itemtype == 0) return OM_MSG_RET_ERROR; switch (ompcp->input_itemtype) { case OBJ_BIOSEQ: bsp = (BioseqPtr) ompcp->input_data; break; default: return OM_MSG_RET_ERROR; } if (bsp != NULL) { if (!ISA_na (bsp->mol)) return OM_MSG_RET_ERROR; w = (WindoW) CreateGraphViewForm (-50, -33, "Dust Filter", bsp, GRAPH_FILTER); } else { return OM_MSG_RET_ERROR; } if ((gvp = (GraphViewFormPtr) GetObjectExtra (w)) == NULL) { /* w = Remove (w); */ return OM_MSG_RET_ERROR; } else { SetObjectExtra (w, gvp, CleanupGCFilterForm); gvp->graphtype = GRAPH_FILTER; gvp->window = 64; exval[0] = 64; exval[1] = 20; exval[2] = 4; exval[3] = 1; gvp->type = NA_FILTER_DUST; gvp->entityID = ompcp->input_entityID; gvp->itemID = ompcp->input_itemID; gvp->procID = ompcp->proc->procid; /* msg stuff */ gvp->userKEY = OMGetNextUserKey (); if ((omudp = ObjMgrAddUserData (gvp->entityID, gvp->procID, OMPROC_FILTER, gvp->userKEY)) != NULL) { omudp->userdata.ptrvalue = (Pointer) gvp; omudp->messagefunc = FilterMsgFunc; /* omudp->messagefunc = NULL; */ } WatchCursor (); spp = SeqPortNew (bsp, 0, bsp->length-1, 0, Seq_code_ncbi2na); gvp->sgp = FilterSeq (spp, 0, bsp->length-1, NULL, NULL, exval, gvp->type); SeqPortFree (spp); if (gvp->sgp == NULL) { /* w = Remove (w); */ ArrowCursor (); return OM_MSG_RET_ERROR; } else { BioseqPtrToGraphViewForm (gvp->form, gvp->sgp); } } /* put the screen up */ Show (w); Select (w); return OM_MSG_RET_DONE; }
static Int2 VSMExportFeatureTable (OMProcControlPtr ompcp, Boolean show_nucs, Boolean show_prots, Boolean hide_sources, Boolean suppress_protein_ids, Boolean export_only_selected) { Char filename[255]; ValNode vn; SeqEntryPtr sep = NULL; FeatureTableData ftd; SeqAnnotPtr sap = NULL; BioseqPtr fake_bsp = NULL; SeqFeatPtr first_feat = NULL; switch(ompcp->input_itemtype) { case OBJ_SEQENTRY: case OBJ_BIOSEQ: case OBJ_BIOSEQSET: case OBJ_SEQFEAT: break; case OBJ_SEQANNOT: sap = (SeqAnnotPtr) ompcp->input_data; if (sap== NULL) { ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can't write NULL Seq-annot"); return OM_MSG_RET_ERROR; } else if (sap->type != 1) { ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can only write Feature Table Seq-annot"); return OM_MSG_RET_ERROR; } else if (sap->data == NULL) { ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can't write empty Feature Table Seq-annot"); return OM_MSG_RET_ERROR; } break; default: ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can only write Seq-entry, Feature Table Seq-annot, Bioseq, or Bioseq-set"); return OM_MSG_RET_ERROR; } ftd.show_nucs = show_nucs; ftd.show_prots = show_prots; ftd.hide_sources = hide_sources; ftd.suppress_protein_ids = suppress_protein_ids; ftd.export_only_selected = export_only_selected; if (ompcp->input_itemtype == OBJ_SEQFEAT) { sep = GetTopSeqEntryForEntityID (ompcp->input_entityID); } else if (ompcp->input_choicetype == OBJ_SEQENTRY) { sep = (SeqEntryPtr)(ompcp->input_choice); } else if (ompcp->input_itemtype == OBJ_SEQANNOT) { sep = GetTopSeqEntryForEntityID (ompcp->input_entityID); if (sep == NULL) { if (sap != NULL) { fake_bsp = BioseqNew(); first_feat = (SeqFeatPtr) sap->data; fake_bsp->id = SeqIdDup (SeqLocId (first_feat->location)); fake_bsp->annot = sap; if (first_feat->data.choice == SEQFEAT_PROT) { fake_bsp->mol = Seq_mol_aa; } else { fake_bsp->mol = Seq_mol_dna; } fake_bsp->repr = Seq_repr_raw; fake_bsp->length = FindNecessaryBioseqLength (first_feat); /* create SeqEntry for temporary bioseq to live in */ sep = SeqEntryNew (); sep->choice = 1; sep->data.ptrvalue = fake_bsp; SeqMgrSeqEntry (SM_BIOSEQ, (Pointer) fake_bsp, sep); } } } else { vn.next = NULL; vn.data.ptrvalue = ompcp->input_data; if (ompcp->input_itemtype == OBJ_BIOSEQ) vn.choice = 1; else vn.choice = 2; sep = &vn; } filename[0] = '\0'; if (GetOutputFileName(filename, (size_t)254, NULL)) { WatchCursor(); #ifdef WIN_MAC ftd.fp = FileOpen (filename, "r"); if (ftd.fp != NULL) { FileClose (ftd.fp); } else { FileCreate (filename, "TEXT", "ttxt"); } #endif ftd.fp = FileOpen(filename, "w"); VisitBioseqsInSep (sep, &ftd, VSMExportFeatureTableBioseqCallback); FileClose(ftd.fp); ArrowCursor(); } if (fake_bsp != NULL) { fake_bsp->annot = NULL; fake_bsp->idx.deleteme = TRUE; DeleteMarkedObjects (fake_bsp->idx.entityID, 0, NULL); } return OM_MSG_RET_DONE; }