1 /*   seqview.h
2 * ===========================================================================
3 *
4 *                            PUBLIC DOMAIN NOTICE
5 *            National Center for Biotechnology Information (NCBI)
6 *
7 *  This software/database is a "United States Government Work" under the
8 *  terms of the United States Copyright Act.  It was written as part of
9 *  the author's official duties as a United States Government employee and
10 *  thus cannot be copyrighted.  This software/database is freely available
11 *  to the public for use. The National Library of Medicine and the U.S.
12 *  Government do not place any restriction on its use or reproduction.
13 *  We would, however, appreciate having the NCBI and the author cited in
14 *  any work or product based on this material
15 *
16 *  Although all reasonable efforts have been taken to ensure the accuracy
17 *  and reliability of the software and data, the NLM and the U.S.
18 *  Government do not and cannot warrant the performance or results that
19 *  may be obtained by using this software or data. The NLM and the U.S.
20 *  Government disclaim all warranties, express or implied, including
21 *  warranties of performance, merchantability or fitness for any particular
22 *  purpose.
23 *
24 * ===========================================================================
25 *
26 * File Name:  seqview.h
27 *
28 * Author:  Jonathan Kans
29 *
30 * Version Creation Date:   4/30/95
31 *
32 * $Revision: 6.70 $
33 *
34 * File Description:
35 *
36 * Modifications:
37 * --------------------------------------------------------------------------
38 * Date     Name        Description of modification
39 * -------  ----------  -----------------------------------------------------
40 *
41 *
42 * ==========================================================================
43 */
44 
45 #ifndef _SEQVIEW_
46 #define _SEQVIEW_
47 
48 #include <dlogutil.h>
49 #include <document.h>
50 #include <viewer.h>
51 #include <glbpic.h>
52 
53 
54 #undef NLM_EXTERN
55 #ifdef NLM_IMPORT
56 #define NLM_EXTERN NLM_IMPORT
57 #else
58 #define NLM_EXTERN extern
59 #endif
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 typedef struct seqPanelLines {
66   Int4    bioSeqLine;   /* this line refers to bioseq line           */
67   Int2    lineType;     /* what to draw on this line (see ELineType) */
68   Uint4   idx;          /* feature index                             */
69   Int4    row;          /* index in alignment                        */
70   Boolean protProduct;  /* indicates whether product sequence should be drawn */
71   Boolean on_the_fly;   /* indicates whether translation of feature location should be drawn */
72 } SeqPanLine, PNTR SeqPanLinePtr;
73 
74 
75 /* bioseqviewdata pointer is passed to callbacks to display views */
76 
77 typedef struct bioseqviewdata {
78   BioseqPtr       bsp;
79 
80   VieweR          vwr;
81   SegmenT         pict;
82   DoC             doc;
83   TexT            text;
84   PaneL           pnl;
85 
86   PaneL           udv;
87   PaneL           ddv;
88 
89   GrouP           styleControlGrp;
90   GrouP           scaleControlGrp;
91   GrouP           findGeneGrp;
92   GrouP           docTxtControlGrp;
93   GrouP           baseCtgControlGrp;
94   GrouP           modeControlGrp;
95   GrouP           extraControlGrp;
96   GrouP           newGphControlGrp;
97   GrouP           pnlParentGrp;
98 
99   PaneL           seqView;
100   GrouP           seqViewParentGrp;
101   PopuP           newFeatControl;
102   PopuP           newNumControl;
103   PopuP           newGridControl;
104 
105   /* for new sequence and alignment viewers */
106   Int4            LineHeight, LineSpace, CharHeight, CharWidth, BlocksAtLine, CharsAtLine, TotalLines, TargetRow;
107   Int2            SeqStartPosX;  /* Draw Sequence from this x pos */
108   SeqAlignPtr     salp;
109   Boolean         DrawGrid, seqAlignMode;
110   SeqPanLinePtr   PNTR SeqPanLines;
111   SelStructPtr    sel_list;
112   ValNodePtr      Selection;
113   Boolean         frames[6]; /* indicates which frames should be displayed */
114   Boolean         ShowComplement;
115   ValNodePtr      chapter_list; /* list of chapters for SeqEd */
116   ValNodePtr PNTR feature_lists; /* storage for feature lists for SeqEd */
117   Int4            frame_for_codon_draw;   /* This indicates which frame (1-6) to draw
118                                            * codons for. */
119   Boolean         show_translation_errors; /* This indicates whether
120                                             * protein amino acids that
121                                             * do not match the sequence
122                                             * translation should be shown
123                                             * in red.
124                                             */
125   Boolean         on_the_fly;              /* This indicates whether an on-the-fly
126                                             * translation of coding regions should
127                                             * be shown.
128                                             */
129   Boolean         showAlnSubstitutions;    /* This indicates whether dots
130                                             * should be used to indicate
131                                             * matching characters.
132                                             */
133   Int4            last_aln_row_clicked;    /* This indicates the last alignment
134                                             * row clicked by the user.  If this
135                                             * value is 0, no row has been selected.
136                                             * This is used for drawing the alignment
137                                             * cursor and generating the position text.
138                                             */
139 
140   GrouP           udvParentGrp;
141   /*
142   GrouP           ddvParentGrp;
143   */
144   PrompT          clickMe;
145 
146   Boolean         useScrollText;
147   Boolean         launchEditors;
148   Boolean         launchSubviewers;
149   Boolean         sendSelectMessages;
150   Boolean         highlightSelections;
151   Boolean         hasTargetControl;
152 
153   Boolean         viewWholeEntity;
154   Boolean         scaleNotCalculated;
155   Boolean         moveToOldPos;
156 
157   PopuP           style;
158   PopuP           scale;
159   IteM            legendItem;
160   Boolean         legendOK;
161   Int4            maxScale;
162   Int4            minIndex;
163 
164   PopuP           seqControl;
165   PopuP           featControl;
166   PopuP           numControl;
167 
168   PopuP           ffModeCtrl;
169   PopuP           ffStyleCtrl;
170   PopuP           ffCustomBtn;
171   PopuP           ffRifCtrl;
172 
173   PopuP           newGphStyle;
174   PopuP           newGphFilter;
175   PopuP           newGphScale;
176   PopuP           newGphAlnScore;
177   PopuP           newGphAlnCutoff;
178   ChoicE          newGphLayout;
179 
180   ValNodePtr      slp_list;
181   ValNodePtr      g_list;
182   ValNodePtr      anp_node;
183   ValNodePtr      ftype_list;
184   Uint2           seq_entityID;
185   GlobalDrawPtr   gdraw_p;
186   Boolean         isGenome;
187 
188   Int2            expansion;
189 
190   Int2            itemClicked;
191   Boolean         wasDoubleClick;
192   Boolean         wasShiftKey;
193   PoinT           pnt_start;
194   PoinT           pnt_stop;
195   Boolean         old_rect_shown;
196 
197   ValNodePtr      bsplist;
198 
199   FonT            displayFont;
200   ValNodePtr      sentinelList;
201   ValNodePtr      entityList;       /* for parts of genome record */
202   ValNodePtr      tempResultList;   /* to view results before attaching */
203   ForM            form;
204 } BioseqViewData, PNTR BioseqViewPtr;
205 
206 /* callback prototypes for implementing operations on a given page in a viewer */
207 
208 typedef void (*BioseqViewProc) (BioseqViewPtr bvp);
209 typedef void (*BioseqShowHideProc) (BioseqViewPtr bvp, Boolean show);
210 typedef void (*BioseqExportProc) (BioseqViewPtr bvp, CharPtr filename, CharPtr dfault);
211 typedef void (*BioseqSelectProc) (BioseqViewPtr bvp, Uint2 entityID, Uint4 itemID, Uint2 itemtype, SeqLocPtr region, Boolean select, Boolean scrollto);
212 
213 /* bioseqpagedata pointer array allows flexible control of pages in viewer */
214 
215 typedef struct bioseqpagedata {
216   CharPtr                label;
217   Boolean                nucOK;
218   Boolean                protOK;
219   Boolean                genomeOK;
220   Boolean                needAlignment;
221   Int4                   maxLength;
222   BioseqViewProc         populate;
223   BioseqShowHideProc     show;
224   BioseqSelectProc       highlight;
225   BioseqViewProc         toClipboard;
226   BioseqViewProc         print;
227   BioseqExportProc       exprt;
228   BioseqExportProc       togif;
229   BioseqViewProc         resize;
230   struct bioseqpagedata  PNTR next;
231 } BioseqPageData, PNTR BioseqPagePtr;
232 
233 /* bioseqpagedata records are available for all pre-defined report types */
234 
235 extern BioseqPageData mapPageData;
236 extern BioseqPageData sumPageData;
237 extern BioseqPageData gphPageData;
238 extern BioseqPageData alnPageData;
239 extern BioseqPageData seqPageData;
240 /*
241 extern BioseqPageData udvPageData;
242 extern BioseqPageData ddvPageData;
243 */
244 
245 extern BioseqPageData gbgnPageData;
246 extern BioseqPageData gnbkPageData;
247 extern BioseqPageData emblPageData;
248 extern BioseqPageData ddbjPageData;
249 extern BioseqPageData gnptPageData;
250 extern BioseqPageData ftblPageData;
251 
252 extern BioseqPageData fstaPageData;
253 extern BioseqPageData qualPageData;
254 extern BioseqPageData asnPageData;
255 extern BioseqPageData xmlPageData;
256 extern BioseqPageData gbseqPageData;
257 extern BioseqPageData dskPageData;
258 
259 extern BioseqPageData asn2gphGphPageData;
260 extern BioseqPageData seqpnlPageData;
261 extern BioseqPageData seqAlnPnlPageData;
262 
263 /*
264 *  The SeqViewProcsPtr may be registered with a call to SetAppProperty
265 *  e.g., SetAppProperty ("SeqDisplayForm", &viewprocs), where viewprocs
266 *  is a persistent structure filled with callback function pointers
267 *  specific for a given application.
268 */
269 
270 /* seqviewprocs is registered to allow communication to library functions */
271 
272 typedef GrouP (*SeqViewControlsProc) (GrouP prnt, BaseFormPtr bfp, Int2 doctype, Int4 uid);
273 typedef GrouP (*SeqViewFetchAlignsProc) (GrouP prnt, BaseFormPtr bfp);
274 typedef Boolean (*SeqViewUpdateFetchCounts) (GrouP g, SeqEntryPtr sep);
275 
276 typedef struct seqviewprocs {
277   Boolean          hasTargetControl;
278   Boolean          hasDoneButton;
279   Boolean          hasDuplicateButton;
280   Boolean          allowScrollText;
281   Boolean          startInScrollText;
282   Boolean          launchEditors;
283   Boolean          launchSubviewers;
284   Boolean          sendSelectMessages;
285   Boolean          highlightSelections;
286   Boolean          forceSeparateViewer;
287   Boolean          keepSmartViewerVisible;
288 
289   Boolean          cleanupObjectPtr;
290   WndActnProc      activateForm;
291   WndActnProc      closeForm;
292   WndActnProc      createMenus;
293   GrpActnProc      createToolBar;
294 
295   FormMessageFunc  handleMessages;
296 
297   Int2             minPixelWidth;
298   Int2             minPixelHeight;
299   Int2             initNucPage;
300   Int2             initProtPage;
301   CharPtr          initNucLabel;
302   CharPtr          initProtLabel;
303   CharPtr          initGenomeLabel;
304   Int2             useFolderTabs;
305 
306   FonT             displayFont;
307   CharPtr          filepath;
308 
309   Char             screenMode;
310 
311   BioseqPagePtr    pageSpecs;
312 
313   SeqViewControlsProc  makeControls;
314   GrpActnProc updateControls;
315   SeqViewFetchAlignsProc  makeAlignBtn;
316   SeqViewUpdateFetchCounts  updateCounts;
317 
318   IteM             alignWithChecked;  /* application sets to EntrezGlobalsPtr->alignWithChecked */
319   Boolean          alignDefault;  /* application sets to EntrezGlobalsPtr->alignDefault */
320 
321   Boolean          lockFarComponents;
322 } SeqViewProcs, PNTR SeqViewProcsPtr;
323 
324 typedef struct bioseqviewform {
325   FORM_MESSAGE_BLOCK
326 
327   BioseqPagePtr   bioseqNucPageList;
328   BioseqPagePtr   bioseqProtPageList;
329   BioseqPagePtr   currentBioseqPage;
330   ButtoN          pubseq;
331 
332   Int2            currentNucPage;
333   Int2            currentProtPage;
334 
335   Handle          nucViewControl;
336   Handle          protViewControl;
337   Handle          targetControl;
338   EnumFieldAssoc  PNTR targetAlist;
339   Boolean         usePopupForTarget;
340   Int4            numTargets;
341   Int4            targetScratchSpace;
342   GrouP           controls;
343   GrpActnProc     updateControls;
344   GrouP           retrieveAlignments;
345   SeqViewUpdateFetchCounts  updateCounts;
346   Boolean         hasaligns;
347 
348   EnumFieldAssoc  PNTR workingAlist;
349   Int4            workingCount;
350   Int4            workingTargets;
351 
352   BioseqViewData  bvd;
353 
354   Boolean         cleanupObjectPtr;
355   WndActnProc     activateForm;
356 
357   ForM            toolForm;
358 } BioseqViewForm, PNTR BioseqViewFormPtr;
359 
360 #define REGISTER_NEW_SEQENTRY_VIEW ObjMgrProcLoad(OMPROC_VIEW,"View Bioseq Report","Bioseq Report",OBJ_BIOSEQ,0,OBJ_BIOSEQ,0,NULL,NewSeqEntryViewGenFunc,PROC_PRIORITY_DEFAULT)
361 #define REGISTER_SMART_SEQENTRY_VIEW ObjMgrProcLoad(OMPROC_VIEW,"View Smart Bioseq Report","Bioseq Report",OBJ_BIOSEQ,0,OBJ_BIOSEQ,0,NULL,SmartSeqEntryViewGenFunc,PROC_PRIORITY_DEFAULT)
362 
363 extern ForM LIBCALL CreateNewSeqEntryViewForm (Int2 left, Int2 top, CharPtr title,
364                                             BioseqPtr bsp, SeqViewProcsPtr svpp);
365 
366 /* RemoveSeqEntryViewer will hide and reuse the last window in Smart mode */
367 extern ForM RemoveSeqEntryViewer (ForM f);
368 
369 extern Int2 LIBCALLBACK NewSeqEntryViewGenFunc (Pointer data);
370 extern Int2 LIBCALLBACK SmartSeqEntryViewGenFunc (Pointer data);
371 
372 extern void LIBCALL NewSaveBioseqViewFormGifItemTable (Pointer formDataPtr, CharPtr filename);
373 
374 extern void LIBCALL AddBioseqPageToList (BioseqPagePtr PNTR head, BioseqPagePtr bpp);
375 extern BioseqPagePtr LIBCALL BioseqPageListFree (BioseqPagePtr bpp);
376 
377 extern IteM CreateLegendItem (MenU m, BaseFormPtr bfp);
378 
379 extern ForM MakeToolFormForBioseqView (BaseFormPtr bfp, GrpActnProc createToolBar);
380 extern ForM ReplaceToolFormForBioseqView (BaseFormPtr bafp, GrpActnProc createToolBar);
381 
382 typedef void (*BuildToolbarProc) PROTO((Nlm_GrouP, Pointer));
383 extern ForM ReplaceToolFormWithDataForBioseqView (BaseFormPtr bafp, BuildToolbarProc createToolBar, Pointer data);
384 
385 extern void SetBioseqViewTarget (BaseFormPtr fp, CharPtr seqId);
386 extern BioseqPtr GetBioseqViewTarget (BaseFormPtr fp);
387 
388 NLM_EXTERN void HideBioseqView (WindoW w);
389 
390 extern BioseqViewPtr GetBioseqViewPtrFromBaseFormPtr (BaseFormPtr fp);
391 NLM_EXTERN void Nlm_LaunchWebPage (Char *url);
392 
393 extern Boolean BioseqViewCanSaveFasta (ForM f, Boolean nucs, Boolean prots, Boolean onlyTarget);
394 extern Boolean ExportBioseqViewFasta (ForM f, CharPtr filename, Boolean nucs, Boolean prots, Boolean onlyTarget);
395 
396 extern Boolean SeqnSeqEntrysToFasta (SeqEntryPtr sep, FILE *fp, Boolean is_na, Uint1 group_segs);
397 
398 /* The following functions are normally for internal use */
399 
400 extern Int2 LIBCALLBACK BioseqViewMsgFunc (OMMsgStructPtr ommsp);
401 
402 extern Boolean InBioseqViewEntityList (Uint2 entityID, BioseqViewPtr bvp);
403 extern void LIBCALL LaunchNewBioseqViewer (BioseqPtr bsp, Uint2 entityID, Uint4 itemID, Uint2 itemtype);
404 extern Boolean LIBCALL IsAGenomeRecord (SeqEntryPtr sep);
405 extern Boolean LIBCALL IsANamedAlignment (Uint2 entityID, Uint4 itemID, Uint2 itemtype);
406 extern Boolean IsSegmentedBioseqWithoutParts (SeqEntryPtr sep);
407 extern Boolean IsADeltaBioseq (SeqEntryPtr sep);
408 extern Boolean LIBCALL LaunchViewerNotEditor (BioseqViewPtr bvp, SeqEntryPtr sep,
409                                               Uint2 entityID, Uint4 itemID, Uint2 itemtype);
410 
411 extern ValNodePtr LIBCALL GetUidsForSeqEntryAligns (SeqEntryPtr sep);
412 extern ValNodePtr LIBCALL GetIdStringsForSeqEntryAligns (SeqEntryPtr sep);
413 extern void LIBCALL GetUidsForOneSeqAnnot (SeqAnnotPtr sap, ValNodePtr PNTR vnpp, Uint1 align_type);
414 extern int LIBCALLBACK SortByVnpDataIntvalue (VoidPtr ptr1, VoidPtr ptr2);
415 
416 extern void ShowGeneList (ButtoN b);
417 extern void EnableDisableLegendItem (BioseqViewPtr bvp, Boolean enable);
418 
419 NLM_EXTERN void RunAutoFixScript (BaseFormPtr bfp, Boolean add_object, Nlm_ChangeNotifyProc change_notify, Pointer change_data);
420 NLM_EXTERN void AutofixOnStartup (BaseFormPtr bfp, Nlm_ChangeNotifyProc change_notify, Pointer change_data);
421 
422 
423 #ifdef __cplusplus
424 }
425 #endif
426 
427 #undef NLM_EXTERN
428 #ifdef NLM_EXPORT
429 #define NLM_EXTERN NLM_EXPORT
430 #else
431 #define NLM_EXTERN
432 #endif
433 
434 #endif /* ndef _SEQVIEW_ */
435 
436