2
* ===========================================================================
5
* National Center for Biotechnology Information (NCBI)
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
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
24
* ===========================================================================
26
* File Name: cn3dopen.c
28
* Author: Christopher Hogue, Yanli Wang, Lewis Geer
30
* First Version Creation Date: 1/31/96
34
* File Description: Cn3d file opening routines
38
* --------------------------------------------------------------------------
39
* Date Name Description of modification
40
* ------- ---------- -----------------------------------------------------
41
* $Log: cn3dopen.c,v $
42
* Revision 6.112 2000/07/24 22:30:20 thiessen
45
* Revision 6.111 2000/07/21 18:55:14 thiessen
46
* allow dynamic slave->master transformation
48
* Revision 6.110 2000/06/16 14:57:03 lewisg
49
* move entrez calls out of desktop
51
* Revision 6.109 2000/05/16 20:24:23 thiessen
52
* don't display alignseq
54
* Revision 6.108 2000/05/16 18:13:32 lewisg
57
* Revision 6.107 2000/05/16 12:44:55 lewisg
58
* fix coloring bug for strucseqs
60
* Revision 6.106 2000/05/16 11:08:44 wheelan
61
* changed sap to salp in SAM_ReplaceGI call at line 505
63
* Revision 6.105 2000/05/15 23:39:34 lewisg
64
* shred cblast, add menu items for gapped/ungapped, fix pdbheaders
66
* Revision 6.104 2000/04/20 23:27:45 lewisg
69
* Revision 6.103 2000/04/11 20:05:39 lewisg
70
* fix freeing bug on bioseq import, misc. tweaks
72
* Revision 6.102 2000/04/10 20:33:40 lewisg
73
* fix show/hide for blast multiple, make blast multiple API generic
75
* Revision 6.101 2000/04/08 00:37:30 lewisg
76
* multiple seqentries, NEWSEQ message, etc.
78
* Revision 6.100 2000/04/07 17:48:39 thiessen
79
* make 'identity' color default for strucseqs
81
* Revision 6.99 2000/04/04 22:18:42 lewisg
82
* add defline to ddv, fix seq import bugs, set boundbox
84
* Revision 6.98 2000/04/04 17:51:54 lewisg
85
* fix various seq import bugs
87
* Revision 6.97 2000/04/03 21:05:53 lewisg
88
* fix launch of cn3d from sequin
90
* Revision 6.96 2000/04/03 14:56:22 lewisg
91
* fix sequence import hang
93
* Revision 6.95 2000/03/28 21:18:54 lewisg
94
* more bug fixes for strucseqs
96
* Revision 6.94 2000/03/28 19:28:13 lewisg
97
* prep new imported sa
99
* Revision 6.93 2000/03/28 16:23:04 thiessen
100
* store row number in MMD after BLAST import
102
* Revision 6.92 2000/03/27 22:15:04 lewisg
103
* add show/hide row dialog
105
* Revision 6.91 2000/03/27 17:15:42 thiessen
106
* fix layer display bug
108
* Revision 6.90 2000/03/24 20:34:56 lewisg
109
* add blast from file, bug fixes, get rid of redundant code, etc.
111
* Revision 6.89 2000/03/23 21:01:07 thiessen
112
* add row number (1) to structure of strucseqs mime type
114
* Revision 6.88 2000/03/22 23:17:49 thiessen
115
* added ability to save ARS in ASN1
117
* Revision 6.87 2000/03/20 18:18:33 thiessen
118
* fixed header problem causing network unavailability
120
* Revision 6.86 2000/03/18 22:39:50 lewisg
121
* copy blast3 headers in makeall.unx, add blast3 to entrez link
123
* Revision 6.84 2000/03/18 00:06:00 lewisg
124
* add blast, new help, new menus
126
* Revision 6.83 2000/03/15 04:43:55 thiessen
127
* various minor fixes
129
* Revision 6.82 2000/03/14 18:03:13 thiessen
130
* add target row to MMD; remove rowmgr
132
* Revision 6.81 2000/03/13 22:03:21 lewisg
133
* add globalpars to network biostruc open
135
* Revision 6.80 2000/03/09 20:32:26 lewisg
136
* fix saving strucseq
138
* Revision 6.79 2000/03/09 17:56:58 thiessen
139
* changes to palette handling, feature implementation, PARS storage
141
* Revision 6.78 2000/03/08 21:46:14 lewisg
142
* cn3d saves viewport, misc bugs
144
* Revision 6.77 2000/03/02 21:11:06 lewisg
145
* use bandalign for import sequence, make standalone ddv use viewmgr, make dialogs modal, send color update
147
* Revision 6.76 2000/03/01 22:49:41 lewisg
148
* import bioseq, neatlyindex, get rid of dead code
150
* Revision 6.75 2000/03/01 16:17:55 thiessen
151
* improved handling of colors; many small fixes
153
* Revision 6.74 2000/02/19 21:25:57 thiessen
154
* split of cn3dmodl into cn3dmodl and cn3dstyl
156
* Revision 6.73 2000/02/15 22:40:57 lewisg
157
* add ability to launch udv so that it colors by row, fixes to colormgr, track rows from viewmgr, fix visual c projects
159
* Revision 6.72 2000/02/10 17:47:02 thiessen
160
* added: color-by-sequence-conservation menu item, zoom-out to OpenGL, misc fixes
162
* Revision 6.71 2000/02/05 01:32:21 lewisg
163
* add viewmgr, move place freeing is done in ddv, modify visual c++ projects
165
* Revision 6.70 2000/01/21 15:59:05 lewisg
166
* add check for binary/ascii files
168
* Revision 6.69 2000/01/14 21:40:41 lewisg
169
* add translucent spheres, ion labels, new cpk, fix misc bugs
171
* Revision 6.68 2000/01/04 15:55:51 lewisg
172
* don't hang on disconnected network and fix memory leak/hang at exit
174
* Revision 6.67 1999/12/28 23:06:35 lewisg
175
* udv/cn3d communication
177
* Revision 6.66 1999/12/28 15:55:21 lewisg
178
* remove remaining mediainfo code
180
* Revision 6.65 1999/12/15 23:17:47 lewisg
181
* make cn3d launch udv, fix launching of non-autonomous udv, add mouseup message
183
* Revision 6.64 1999/12/13 23:20:44 lewisg
184
* bug fixes: duplicate color structures eliminated, clear color doesn't clear case
186
* Revision 6.63 1999/12/11 01:30:35 lewisg
187
* fix bugs with sharing colors between ddv and cn3d
189
* Revision 6.62 1999/12/01 16:15:54 lewisg
190
* interim checkin to fix blocking memory leak
192
* Revision 6.61 1999/11/24 15:23:19 lewisg
193
* added color selection dialogs for SS
195
* Revision 6.60 1999/11/15 18:30:08 lewisg
196
* get rid of extra redraws when selecting
198
* Revision 6.59 1999/11/10 23:19:41 lewisg
199
* rewrite of selection code for ddv
201
* Revision 6.58 1999/11/02 23:06:07 lewisg
202
* fix cn3d to launch correctly if there is no seqentry associated with bioseq
204
* Revision 6.57 1999/10/29 14:15:30 thiessen
205
* ran all Cn3D source through GNU Indent to prettify
207
* Revision 6.56 1999/10/18 16:01:09 lewisg
210
* Revision 6.55 1999/10/18 15:32:50 lewisg
211
* move ClearSequences() to cn3dshim.c
213
* Revision 6.54 1999/10/15 20:56:39 lewisg
214
* append DDV_ColorGlobal as userdata. free memory when cn3d terminates.
216
* Revision 6.53 1999/10/05 23:18:24 lewisg
217
* add ddv and udv to cn3d with memory management
219
* Revision 6.52 1999/09/16 17:16:21 ywang
220
* open multiple salsa window for data with multiple seq-annot data
222
* Revision 6.51 1999/08/04 21:18:01 lewisg
223
* modularized open operations to allow sequin to launch cn3d
225
* Revision 6.50 1999/07/12 19:37:44 ywang
228
* Revision 6.49 1999/07/07 20:45:37 ywang
229
* clear domaindata, mediadata, special feature before reading in new data in cn3d
231
* Revision 6.48 1999/07/07 16:41:30 ywang
232
* reset Num_Bioseq as 0 when sequences are freed
234
* Revision 6.47 1999/07/06 18:30:45 chappey
235
* Send FLUSH message on each Bioseq to close windows
237
* Revision 6.46 1999/07/06 17:18:38 ywang
238
* send OM_MSG_FLUSH message to salsa to close all its windows before new sequence window launched
240
* Revision 6.45 1999/07/02 20:58:37 ywang
241
* return NULL sep upon NULL pmsdThis in Cn3DFetchSeqEntry
243
* Revision 6.44 1999/07/02 19:57:43 ywang
244
* go through every node of SeqEntryPtr for free
246
* Revision 6.43 1999/07/02 14:39:14 ywang
247
* clean seq-entry fetching and OM register for netopen and local read(non mimetype) functioning
249
* Revision 6.42 1999/07/01 22:14:58 ywang
250
* back to previous version to use EntrezSeqEntryGet to get sequences for additional loading, before this free existant sequences
252
* Revision 6.41 1999/07/01 22:08:08 lewisg
253
* add resize before all redraws
255
* Revision 6.40 1999/07/01 21:44:30 ywang
256
* work around EntrezSeqEntryGet core dump on redunant sequence loading and free existant sequences before additional loading
258
* Revision 6.39 1999/07/01 14:07:25 ywang
261
* Revision 6.38 1999/06/15 19:08:17 kans
262
* instantiate Cn3D_useEntrez in library
264
* Revision 6.37 1999/06/15 17:57:54 ywang
265
* rename useEntrez as Cn3D_useEntrez
267
* Revision 6.36 1999/06/14 17:40:26 ywang
268
* assign mimetype to structure data read in locally or via network with respect to availability of sequences
270
* Revision 6.35 1999/04/06 20:14:09 lewisg
273
* Revision 6.34 1999/03/30 22:36:19 ywang
274
* add functions to color salsa for NcbiMimeAsn1_strucseqs & code reorganization
276
* Revision 6.33 1999/03/18 22:28:58 ywang
277
* add functions for saveout+readin+index user defined features
279
* Revision 6.32 1999/03/03 23:17:22 lewisg
280
* one master struct at a time, list slaves in structure info, bug fixes
282
* Revision 6.31 1999/02/25 23:14:31 ywang
283
* move around menu item and callback function, change menu item names
285
* Revision 6.30 1999/02/24 23:00:49 ywang
286
* record mime type at MSD node
288
* Revision 6.29 1999/01/20 18:21:20 ywang
289
* include salmedia.h due to the move around of MediaInfo from cn3dmsg.h to the new created salmedia.h
291
* Revision 6.28 1999/01/19 23:42:48 ywang
292
* fix bugs over improving color msg
294
* Revision 6.27 1999/01/14 19:07:17 kans
295
* network availability is configurable
297
* Revision 6.26 1998/12/22 15:40:32 ywang
298
* restore sequences pointer for strucseq
300
* Revision 6.25 1998/12/21 18:47:37 addess
301
* fixed strucseq bug found by Aron
303
* Revision 6.24 1998/12/16 17:02:57 ywang
304
* pick up strucseqs mime type
306
* Revision 6.23 1998/10/21 15:49:21 ywang
307
* attach the whole vast alignment data to master structure
309
* Revision 6.22 1998/09/23 18:38:50 ywang
310
* add functions to control display on domain level
312
* Revision 6.21 1998/06/30 23:29:22 ywang
313
* fix bugs regarding to read in more structures
315
* Revision 6.20 1998/06/30 14:48:04 ywang
316
* launch salsa automatically and accordingly when more structures are readin
318
* Revision 6.19 1998/06/29 19:28:00 lewisg
319
* on the fly update of conservation color
321
* Revision 6.17 1998/06/15 14:26:06 ywang
322
* automatic launch salsa when mime data got in either through command line or via local reading in
324
* Revision 6.16 1998/06/12 21:21:56 ywang
325
* change sCompare to make cn3d accept mime strucseq from local readin
327
* Revision 6.15 1998/06/04 16:48:36 ywang
328
* fix bug triggered by automatic salsa launch
330
* Revision 6.14 1998/05/27 22:15:16 ywang
331
* add Cn3dObjRegister() to several places
333
* Revision 6.13 1998/05/18 22:09:14 ywang
336
* Revision 6.12 1998/05/12 21:47:05 lewisg
337
* stricter conservation coloring
339
* Revision 6.11 1998/05/12 16:34:01 ywang
340
* take strucseq mime data
342
* Revision 6.10 1998/05/06 23:50:24 lewisg
343
* fixed launching problem with sequin
345
* Revision 6.9 1998/05/06 14:20:09 lewisg
346
* get rid of NULL structure bugs
348
* Revision 6.8 1998/04/28 22:47:21 lewisg
349
* master/slave color in sync
351
* Revision 6.7 1998/04/28 19:40:01 lewisg
354
* Revision 6.6 1998/04/28 19:38:39 lewisg
357
* Revision 6.5 1998/04/28 18:53:25 ywang
358
* take NcbiMimeAsn1_alignseq to view alignment only
360
* Revision 6.4 1998/04/28 15:20:37 kans
361
* cast needed on FileGets for CodeWarrior
363
* Revision 6.3 1998/04/28 15:14:29 lewisg
364
* moved OpenMimeFileWithDeletion to cn3dopen
366
* Revision 6.2 1998/04/27 23:23:06 lewisg
367
* added ability to open mime files
369
* Revision 6.1 1998/04/16 00:32:25 lewisg
370
* corrected neighbor mode bugs
372
* Revision 6.0 1997/08/25 18:13:38 madden
373
* Revision changed to 6.0
375
* Revision 5.0 1996/05/28 14:05:44 ostell
376
* Set to revision 5.0
378
* Revision 1.5 1996/04/18 17:01:10 hogue
379
* Fixed calls to FetchBS for later integration into Entrez, added feature to turn off redundant backbone model for faster spinning...
381
* Revision 1.4 1996/03/30 23:41:01 hogue
382
* Redraw now saves camera
384
* Revision 1.3 1996/03/29 20:01:24 hogue
385
* Added call to reset active structure upon opening.
387
* Revision 1.2 1996/02/02 19:40:19 hogue
391
* ==========================================================================
398
#include <objalign.h>
403
#include <lsqfetch.h>
404
#include <cn3dopen.h>
405
#include <cn3dmain.h>
406
#include <algorend.h>
408
#include <salmedia.h>
409
#include <cn3dshim.h>
410
#include <cn3dmodl.h>
411
#include <cn3dstyl.h>
412
#include <alignmgr.h>
413
#include <sqnutils.h>
414
#include <cn3dsave.h>
417
#include <udviewer.h>
419
#include <accutils.h>
422
static Boolean Cn3D_Open_InUse = FALSE;
423
static WindoW Cn3D_wNetOpen;
424
static TexT Cn3D_tOpen;
425
static GrouP Cn3D_gAccType;
426
static ButtoN Cn3D_bOpenAccept;
427
static GrouP Cn3D_gMdlLvl;
428
static GrouP Cn3D_gMdlNo;
430
static WindoW Cn3D_wOpen;
431
static ButtoN Cn3D_bOpenBrowse;
433
Boolean Mime_ReadIn = FALSE;
438
/*****************************************************************************
440
Function: Cn3D_UseNetwork()
442
Purpose: Sets Cn3D_ColorData.UseEntrez, if Cn3D should use the network
446
*****************************************************************************/
448
NLM_EXTERN Boolean Cn3D_CheckNetworkUse()
451
Boolean useNetwork = FALSE;
454
("CN3D", "SETTINGS", "NETWORKAVAILABLE", NULL, str, sizeof(str))) {
455
if (StringICmp(str, "TRUE") == 0) useNetwork = TRUE;
457
Cn3D_ColorData.UseEntrez = useNetwork;
458
Cn3D_ColorData.EntrezOn = FALSE;
462
/*------------------------------------------------------*/
463
Boolean Cn3D_UsingEntrez(void)
465
return Cn3D_ColorData.UseEntrez;
468
/*------------------------------------------------------*/
469
Boolean Cn3D_EntrezOn(void)
471
return Cn3D_ColorData.EntrezOn;
474
/*------------------------------------------------------*/
475
SeqEntryPtr Cn3DFetchSeqEntry(PMSD pmsdThis)
477
PDNMM pdnmmHead = NULL;
478
PMMD pmmdThis = NULL;
482
if (pmsdThis == NULL)
485
pdnmmHead = pmsdThis->pdnmmHead;
487
pmmdThis = pdnmmHead->data.ptrvalue;
488
if (pmmdThis == NULL)
490
if (pmmdThis->bWhat != (Byte) AM_PROT
491
&& pmmdThis->bWhat != (Byte) AM_RNA
492
&& pmmdThis->bWhat != (Byte) AM_DNA)
494
if (pmmdThis->iGi != 0) {
495
si.choice = SEQID_GI;
496
si.data.intvalue = pmmdThis->iGi;
497
bsp = BioseqLockById(&si);
501
return SeqEntryFind(&si);
505
pdnmmHead = pdnmmHead->next;
511
static SeqAnnot * Cn3D_ShredCBlast(SeqAnnot *sap)
514
SeqAnnot *sapout, *saptmp;
516
if (sap == NULL) return NULL;
520
if (saptmp->type == 2) {
524
saptmp = saptmp->next;
528
if(am_guess_numrows(salp) > 2) return sap;
530
AlnMgrIndexSeqAlign(salp);
531
AlnMgrMakeMultipleByScore(salp);
532
AlnMgrDeleteHidden(salp, FALSE);
533
sapout = SeqAnnotNew();
534
sapout->data = DDV_ShredAln(salp);
535
if(sapout->data == NULL) return sap;
543
sets alignment bits in master structure given pairwise seqaligns
545
static void Cn3D_MarkStrucSeqs(PDNMS pdnmsThis, SeqAnnot *sap)
547
PMSD pmsdThis = NULL;
548
PMMD pmmdThis = NULL;
549
PMGD pmgdThis = NULL;
551
SeqAlignPtr salp = NULL;
552
DenseSegPtr dssp = NULL;
553
DenseDiagPtr ddp = NULL;
556
if (sap == NULL || pdnmsThis == NULL) return;
557
pmsdThis = pdnmsThis->data.ptrvalue;
558
if (pmsdThis == NULL) return;
561
if (sap->type == 2) {
569
if(salp->segtype == SAS_DENDIAG) {
573
else if(salp->segtype == SAS_DENSEG) {
578
pmmdThis = GetMMFromMSDBySeqId(pmsdThis, sip);
579
/* assume the first sip is for the sequence with known structure */
582
if (pmmdThis == NULL) return;
585
pmsdThis->bAligned++;
586
if(salp->segtype == SAS_DENSEG) {
588
if(dssp->dim != 2) continue;
590
for (numseg = 0; numseg < dssp->numseg; numseg++) {
591
if (dssp->starts[numseg*2] == -1
592
|| dssp->starts[numseg*2+1] == -1 ) continue;
593
for (nres = dssp->starts[numseg*2];
594
nres < dssp->starts[numseg*2] + dssp->lens[numseg];
596
pmgdThis = GetMGFromMM(pmmdThis, nres + 1);
597
if (pmgdThis) pmgdThis->bReserved++;
601
else /* densediag */ {
603
if(ddp->dim != 2) continue;
604
if (ddp->starts[0] != -1 && ddp->starts[1] != -1) {
605
for (nres = ddp->starts[0]; nres < ddp->starts[0] + ddp->len;
607
pmgdThis = GetMGFromMM(pmmdThis, nres + 1);
608
if (pmgdThis) pmgdThis->bReserved++;
618
fnMarkAlignedResidue()
619
Given a master and model, mark all of the residues in the slave and master that are aligned.
622
ValNodePtr fnMarkAlignedResidues(PDNMS pdnmsMaster, PDNMS pdnmsSlave,
623
BiostrucFeaturePtr pbsfThis)
626
ValNodePtr pvnAlignment;
627
ValNodePtr pvnThis = NULL;
628
ChemGraphPntrsPtr pcgpThis;
629
ValNodePtr pvnListMaster = NULL, pvnListSlave = NULL,
630
pvnListMasterHead, pvnListSlaveHead;
631
PFB pfbMaster = NULL, pfbSlave = NULL;
632
ChemGraphAlignmentPtr pcgaSlave;
635
/* find the corresponding alignment */
637
ValNodeFindNext(pbsfThis->Location_location, NULL,
638
Location_location_alignment);
639
if (pvnAlignment == NULL)
643
pcgaSlave = pvnAlignment->data.ptrvalue;
644
pvnThis = pcgaSlave->alignment;
646
pcgpThis = (ChemGraphPntrsPtr) pvnThis;
647
pvnListMasterHead = pvnListMaster =
648
MakeChemGraphNodeList(pdnmsMaster, pcgpThis);
649
pcgpThis = (ChemGraphPntrsPtr) pvnThis->next;
650
pvnListSlaveHead = pvnListSlave =
651
MakeChemGraphNodeList(pdnmsSlave, pcgpThis);
652
if (!pvnListMaster || !pvnListSlave)
654
while (pvnListMaster && pvnListSlave) {
655
pfbMaster = (PFB) pvnListMaster->data.ptrvalue;
656
pfbMaster->bReserved++;
657
pfbSlave = (PFB) pvnListSlave->data.ptrvalue;
658
pfbSlave->bReserved++;
659
((PMGD) pfbSlave)->pbMasterReserved = &(pfbMaster->bReserved); /* use unused feature pointer to point slave back at master */
660
pvnListSlave = pvnListSlave->next;
661
pvnListMaster = pvnListMaster->next;
662
} /* while pvnListMaster */
663
ValNodeFree(pvnListMasterHead);
664
ValNodeFree(pvnListSlaveHead);
665
} /* while pvnThis */
670
fnClearMarkedResidues
671
callback function used to clear all of the alignment pointers and counters used for protein conservation calculations
674
void LIBCALLBACK fnClearMarkedResidues(PFB pfbThis, Int4 iModel,
675
Int4 iIndex, Pointer ptr)
679
pfbThis->bReserved = 0;
680
pmgdThis = (PMGD) pfbThis;
681
pmgdThis->pbMasterReserved = NULL;
684
/******************************************************************************
686
* Traverses the given MSD and sets it up for displaying one model or animation
687
* Turns off backbone model if all atoms is loaded in?
689
******************************************************************************/
691
NLM_EXTERN void MMDB_OpenTraverse(PMSD pmsd)
693
PDNML pdnmlThis = NULL;
694
PMLD pmldThis = NULL;
698
pdnmlThis = pmsd->pdnmlModels;
699
/* set up for doing one model or animation */
701
pmldThis = (PMLD) pdnmlThis->data.ptrvalue;
702
if (pmldThis->iType == Model_type_ncbi_backbone)
704
if (pmldThis->iType == Model_type_ncbi_all_atom)
706
pdnmlThis = pdnmlThis->next;
709
if (pmldOne && pmldAll)
710
pmldOne->bSelected &= (Byte) 0xFE;
713
/******************************************************************************
715
* Sets up Cn3D for reading in a new structure and any potential alignments
718
******************************************************************************/
720
NLM_EXTERN void Cn3D_OpenStart()
725
Cn3D_SaveActiveCam();
736
NLM_EXTERN Boolean Cn3D_StartNet(Boolean UseNetwork)
738
if (Cn3D_ColorData.EntrezOn) return TRUE;
739
if (Cn3D_ColorData.UseEntrez) {
740
if(EntrezInit("Cn3D", TRUE, NULL)) {
741
if(EntrezBioseqFetchEnable("Cn3D", FALSE)) {
742
Cn3D_ColorData.EntrezOn = TRUE;
750
/******************************************************************************
752
* Finishes setting up Cn3D. Called after reading in a new structure and any
753
* alignments and bioseqs. If necessary, will load in a sequence via
754
* netentrez if a network connection is open.
756
******************************************************************************/
758
/* call back to replace gi's with full seqid's */
759
static void LIBCALLBACK fnRewireSips(PFB pfbThis, Int4 iModel,
760
Int4 iIndex, Pointer ptr)
766
pmmdThis = (PMMD) pfbThis;
767
if(pmmdThis->pSeqId == NULL) return;
768
bsp = BioseqLockById(pmmdThis->pSeqId);
769
if(bsp == NULL) return;
770
sip = SeqIdDupList(bsp->id);
775
SeqIdFree(pmmdThis->pSeqId);
776
pmmdThis->pSeqId = sip;
781
NLM_EXTERN void Cn3D_OpenEnd()
783
PMSD pmsdMaster = NULL;
784
PDNMS pdnmsMaster = NULL, pdnmsSlave = NULL;
785
SeqEntryPtr sep = NULL;
787
BiostrucFeaturePtr bsfp;
791
Cn3DIndexUserDefinedFeature();
794
OGL_Reset(Cn3D_ColorData.OGL_Data);
799
pdnmsMaster = GetSelectedModelstruc();
800
if(pdnmsMaster == NULL) return;
801
pmsdMaster = pdnmsMaster->data.ptrvalue;
802
if(pmsdMaster == NULL) return;
804
Cn3D_GetRenderSettingsFromBiostruc(pdnmsMaster);
806
if (!Mime_ReadIn || pmsdMaster->iMimeType == NcbiMimeAsn1_entrez) {
808
if (Cn3D_ColorData.EntrezOn) {
809
sep = Cn3DFetchSeqEntry(pmsdMaster);
811
pmsdMaster->iMimeType = NcbiMimeAsn1_strucseq;
812
Cn3D_RegisterSeqEntry(sep);
814
else pmsdMaster->iMimeType = NcbiMimeAsn1_entrez;
816
else pmsdMaster->iMimeType = NcbiMimeAsn1_entrez;
819
Cn3D_ColorData.IsUserData = TRUE;
820
if(Cn3D_ColorData.pDDVColorGlobal == NULL) {
821
Cn3D_ColorData.pDDVColorGlobal = DDV_CreateColorGlobal(FALSE,
823
DDV_LoadSSColor(Cn3D_ColorData.pDDVColorGlobal, "CN3D");
824
Cn3D_ColorData.IsUserData = FALSE;
825
Cn3D_RegisterColor();
828
if (pmsdMaster->iMimeType != NcbiMimeAsn1_entrez) {
829
TraverseMolecules(pdnmsMaster, 0, 0, NULL,
830
(pNodeFunc) fnRewireSips);
831
for(pdnmsSlave = pmsdMaster->pdnmsSlaves; pdnmsSlave != NULL;
832
pdnmsSlave = pdnmsSlave->next)
833
TraverseMolecules(pdnmsSlave, 0, 0, NULL,
834
(pNodeFunc) fnRewireSips);
837
Cn3D_ResetActiveStrucProc();
838
Cn3D_RedrawEx(TRUE); /* always a new structure */
841
bsfp = Cn3D_FindFeature(pmsdMaster->pbsBS->features,
842
Feature_type_camera, 1);
845
camera = (Camera *)bsfp->Property_property->data.ptrvalue;
846
if(camera->scale != 0) {
847
Cn3D_Asn2Matrix(Cn3D_ColorData.OGL_Data->ModelMatrix, camera->modelview);
848
Cn3D_ColorData.OGL_Data->CameraDistance = ((FloatLo)camera->distance)
850
Cn3D_ColorData.OGL_Data->CameraAngle = ((FloatLo)camera->angle)
852
Cn3D_ColorData.OGL_Data->CameraDirection[0] = ((FloatLo)camera->x)
854
Cn3D_ColorData.OGL_Data->CameraDirection[1] = ((FloatLo)camera->y)
856
Cn3D_ColorData.OGL_Data->NeedCameraSetup = TRUE;
859
OGL_AllLayerOnProc(Cn3D_ColorData.OGL_Data);
862
Cn3D_RedrawNUpdate(FALSE);
863
if (pmsdMaster->iMimeType != NcbiMimeAsn1_entrez) LaunchSequenceWindow();
867
static void Cn3D_StoreAlignRowNumsInMMDs(SeqAnnot * sanp)
869
PDNMS pdnmsMaster, pdnmsSlave;
872
SeqAlignPtr salp = NULL;
875
for (; sanp != NULL; sanp = sanp->next) {
876
if (sanp->data == NULL) continue;
882
pdnmsMaster = GetSelectedModelstruc();
883
if (pdnmsMaster == NULL) return;
885
/* assume master is row #1 */
886
sip = AlnMgrGetNthSeqIdPtr(salp, row);
887
pmmdThis = GetMMFromMSDBySeqId((PMSD) pdnmsMaster->data.ptrvalue, sip);
889
Message(MSG_ERROR, "error matching master MMD to target row 0");
892
pmmdThis->iTargetRow = row;
895
/* assume slaves are rows 2..N in order */
896
for(pdnmsSlave = ((PMSD) pdnmsMaster->data.ptrvalue)->pdnmsSlaves;
898
pdnmsSlave = pdnmsSlave->next, row++) {
900
sip = AlnMgrGetNthSeqIdPtr(salp, row);
901
pmmdThis = GetMMFromMSDBySeqId((PMSD) pdnmsSlave->data.ptrvalue, sip);
903
Message(MSG_ERROR, "error matching slave MMD to target row %i", row);
906
pmmdThis->iTargetRow = row;
911
/******************************************************************************
913
* Opens the file with filename and tries to read in NcbiMimeAsn1. Doesn't
914
* care if it binary or text encoded. If removeIt is set, deletes the file
915
* afterwards. The NcbiMimeAsn1 is read into the object manager and MMDBapi
917
******************************************************************************/
919
Boolean OpenMimeFileWithDeletion(CharPtr filename, Boolean removeIt)
921
Boolean retval = FALSE;
924
NcbiMimeAsn1Ptr mime;
925
FILE *fp = FileOpen(filename, "r");
931
FileRead(buf, 1, StrLen(PRINT_FORM_MIME_NAME), fp);
933
if (StrNCmp(buf, PRINT_FORM_MIME_NAME, StrLen(PRINT_FORM_MIME_NAME)) ==
934
0) aip = AsnIoOpen(filename, "r");
936
aip = AsnIoOpen(filename, "rb");
939
mime = NcbiMimeAsn1AsnRead(aip, NULL);
943
Cn3DMime = mime->choice;
947
retval = MMDB_ReadMime(mime);
951
FileRemove(filename);
959
* callback to initialize MG's PARS list with default PARS (passed as ptr)
961
void LIBCALLBACK fnSetGlobalPARSinMG(PFB pfbThis, Int4 iModel,
962
Int4 iIndex, Pointer ptr)
964
ValNodeAddPointer(&(((PMGD) pfbThis)->pvnPARSList), 0, (VoidPtr) ptr);
967
NLM_EXTERN void Cn3D_SetPars(PARS parsThis, PDNMS pdnms)
971
if(parsThis == NULL || pdnms == NULL) return;
972
pmsdThis = pdnms->data.ptrvalue;
973
pmsdThis->pGlobalPARS = parsThis;
974
TraverseGraphs(pdnms, 0, 0, (Pointer) parsThis, (pNodeFunc) fnSetGlobalPARSinMG);
977
/******************************************************************************
979
* Meant to be an ncbiobj and mmdb dependent function to process mime input
980
* into objects and MSD's. Still has a few dependencies to be eliminated
982
******************************************************************************/
983
Boolean MMDB_ReadMime(NcbiMimeAsn1Ptr mime)
985
Boolean retval = FALSE;
986
BiostrucFeaturePtr pbsfThis;
987
PMSD pmsdSlave = NULL, pmsdMaster = NULL;
988
PDNMS pdnmsMaster = NULL, pdnmsSlave = NULL;
989
BiostrucAlignSeqPtr pbsasThis = NULL;
990
SeqAnnotPtr sap = NULL;
994
EntrezGeneralPtr egp;
995
BiostrucAlignPtr pbsaThis;
997
BiostrucSeqsPtr bsssp;
999
PMSD pmsdThis = NULL;
1000
PDNML pdnmlThis = NULL;
1001
ValNodePtr pvnAlignment;
1002
PDNTRN pdnTransform = NULL;
1004
BiostrucPtr pbsThis;
1006
switch (mime->choice) {
1008
case NcbiMimeAsn1_entrez:
1009
egp = (EntrezGeneralPtr) mime->data.ptrvalue;
1010
if (!egp || !egp->Data_data)
1014
switch (egp->Data_data->choice) {
1015
case Data_data_structure:
1017
MakeAModelstruc((BiostrucPtr) egp->Data_data->data.ptrvalue);
1020
pmsdThis = (PMSD) pdnms->data.ptrvalue;
1021
pmsdThis->iMimeType = NcbiMimeAsn1_entrez;
1022
MMDB_OpenTraverse(pmsdThis);
1023
Cn3D_SetPars(NewStructureRenderSet(), pdnms);
1027
case Data_data_prot:
1029
case Data_data_genome:
1035
case NcbiMimeAsn1_strucseq:
1036
bssp = (BiostrucSeqPtr) mime->data.ptrvalue;
1037
pdnms = MakeAModelstruc((BiostrucPtr) bssp->structure);
1040
pmsdThis = (PMSD) pdnms->data.ptrvalue;
1041
Cn3D_SetPars(NewStructureRenderSet(), pdnms);
1042
pmsdThis->iMimeType = NcbiMimeAsn1_strucseq;
1044
MMDB_OpenTraverse(pmsdThis);
1045
Cn3D_RegisterSeqEntry(bssp->sequences);
1048
case NcbiMimeAsn1_strucseqs:
1049
bsssp = (BiostrucSeqsPtr) mime->data.ptrvalue;
1050
pdnms = MakeAModelstruc((BiostrucPtr) bsssp->structure);
1053
pmsdThis = (PMSD) pdnms->data.ptrvalue;
1054
pmsdThis->iMimeType = NcbiMimeAsn1_strucseqs;
1055
MMDB_OpenTraverse(pmsdThis);
1056
Cn3D_MarkStrucSeqs(pdnms, bsssp->seqalign);
1058
sap = Cn3D_ShredCBlast(bsssp->seqalign);
1059
Cn3D_RegisterSeqAnnot(sap, TRUE, TRUE);
1060
Cn3D_RegisterSeqEntry(bsssp->sequences);
1061
parsThis = NewStructureRenderSet();
1062
parsThis->PBBColor = C_BYSEQCONS;
1063
parsThis->ConsColAlg = CSC_SHOWIDENTITY;
1064
Cn3D_SetPars(parsThis, pdnms);
1065
/* after indexing/IBM, store "original" row numbers in corresponding MMD */
1066
Cn3D_StoreAlignRowNumsInMMDs(sap);
1069
case NcbiMimeAsn1_alignseq:
1071
pbsasThis = (BiostrucAlignSeqPtr) mime->data.ptrvalue;
1072
sap = Cn3D_ShredCBlast(pbsasThis->seqalign);
1073
Cn3D_RegisterSeqAnnot(sap, TRUE, TRUE);
1074
Cn3D_RegisterSeqEntry(pbsasThis->sequences);
1076
Message(MSG_ERROR, "Cn3D: Sorry, can't view alignments without structures (yet).");
1080
case NcbiMimeAsn1_alignstruc: /* this is the code that received alignments */
1081
pbsaThis = (BiostrucAlignPtr) mime->data.ptrvalue;
1082
if (!pbsaThis) break; /* THROW */
1084
/* load in the master */
1085
pdnmsMaster = MakeAModelstruc((BiostrucPtr) pbsaThis->master); /* grab the master struc */
1086
if (!pdnmsMaster) break;
1088
pmsdMaster = (PMSD) pdnmsMaster->data.ptrvalue;
1090
pmsdMaster->iMimeType = NcbiMimeAsn1_alignstruc;
1092
parsThis = NewAlignRenderSet();
1093
Cn3D_SetPars(parsThis, pdnmsMaster);
1095
pmsdMaster->bVisible = TRUE;
1096
MMDB_OpenTraverse(pmsdMaster);
1098
/* add the alignment seq annot ptr, etc. */
1099
pmsdMaster->psaStrucAlignment = pbsaThis->alignments;
1100
Cn3D_RegisterSeqAnnot(pbsaThis->seqalign, TRUE, TRUE);
1101
Cn3D_RegisterSeqEntry(pbsaThis->sequences);
1103
SetNeighborOn(); /* turn on neighbor mode */
1105
SetMasterModelstruc(pdnmsMaster);
1108
pbsThis = (BiostrucPtr) pbsaThis->slaves;
1109
pbsfThis = (BiostrucFeaturePtr)
1110
pbsaThis->alignments->features->features;
1111
pvnAlignment = NULL;
1112
TraverseGraphs(pdnmsMaster, 0, 0, NULL,
1113
(pNodeFunc) fnClearMarkedResidues);
1116
pdnmsSlave = MakeAModelstruc(pbsThis);
1119
TraverseGraphs(pdnmsSlave, 0, 0, NULL,
1120
(pNodeFunc) fnClearMarkedResidues);
1121
pmsdSlave = (PMSD) pdnmsSlave->data.ptrvalue;
1122
pmsdSlave->bMaster = FALSE; /* this is not a master struct */
1123
pmsdMaster->bAligned++;
1124
pmsdSlave->pbAligned = &(pmsdMaster->bAligned);
1126
MMDB_OpenTraverse(pmsdSlave);
1127
Cn3D_SetPars(parsThis, pdnmsSlave);
1129
pmsdSlave->bVisible = TRUE; /* turn them all on by default */
1132
fnMarkAlignedResidues(pdnmsMaster, pdnmsSlave, pbsfThis);
1133
if (!pvnAlignment) break;
1135
/* create the spatial transformation */
1136
pdnTransform = NULL;
1137
TransformToDNTRN(&pdnTransform,
1138
((ChemGraphAlignmentPtr) pvnAlignment->data.ptrvalue)->transform);
1139
/* reverse transforms order to pass to Vibrant/shim3d/OpenGL as ValNode */
1141
while (pdnTransform->next) pdnTransform = pdnTransform->next;
1142
while (pdnTransform) {
1143
ValNodeAddPointer(&(pmsdSlave->pdnSlaveToMasterTransforms),
1144
pdnTransform->choice, pdnTransform->data.ptrvalue);
1145
pdnTransform = pdnTransform->last;
1150
/* loop over the slave's models with the transformation */
1152
if (pdnTransform == NULL) break;
1153
pdnmlThis = pmsdSlave->pdnmlModels;
1156
TraverseAtoms(pdnmsSlave, pdnmlThis->choice, 0,
1157
pdnTransform, DoApplyTransform);
1158
TraverseSolids(pdnmsSlave, pdnmlThis->choice, 0,
1159
pdnTransform, DoApplyTransform);
1160
pdnmlThis = pdnmlThis->next;
1164
FreeDNTRN(pdnTransform);
1166
pbsThis = pbsThis->next;
1167
pbsfThis = pbsfThis->next;
1168
} /*while pbsThis */
1170
/* after indexing/IBM, store "original" row numbers in corresponding MMD */
1171
Cn3D_StoreAlignRowNumsInMMDs(pbsaThis->seqalign);
1179
} while (0); /* End-of-TRY-block */
1185
static void Cn3D_OpenEnableProc(TexT t)
1188
GetTitle(Cn3D_tOpen, str, sizeof(str));
1189
if (StringLen(str) == 0) {
1190
Disable(Cn3D_bOpenAccept);
1192
Enable(Cn3D_bOpenAccept);
1197
static void Cn3D_NetOpenAcceptProc(ButtoN b)
1200
BiostrucPtr pbsBiostruc = NULL;
1201
PDNMS pdnmsModelstruc = NULL;
1202
PMSD pmsdThis = NULL;
1208
GetTitle(Cn3D_tOpen, str, sizeof(str));
1210
switch (GetValue(Cn3D_gMdlLvl)) {
1212
MdlLvl = ONECOORDATOM;
1215
MdlLvl = ONECOORDRES;
1224
MdlLvl = ALLSIMPLEMDL;
1227
MdlLvl = BSEVERYTHING;
1230
MdlLvl = ONECOORDATOM; /* set from config-file default */
1232
switch (GetValue(Cn3D_gMdlNo)) {
1256
MdlNo = 1; /* set from config-file default */
1258
if (GetValue(Cn3D_gMdlLvl) == 6)
1259
MdlNo = MAX_MDLNO; /* get all */
1260
if (GetValue(Cn3D_gAccType) == 1) { /* PDB */
1261
pbsBiostruc = FetchBiostrucPDB(str, MdlLvl, MdlNo);
1265
FetchBS(str, INP_GI, MdlLvl, MdlNo, GetMMDBAPIbExtent());
1268
if (pbsBiostruc != NULL) {
1270
pdnmsModelstruc = MakeAModelstruc(pbsBiostruc);
1273
if (pdnmsModelstruc == NULL) {
1274
/* return a not found error here */
1275
Remove(Cn3D_wNetOpen);
1276
Cn3D_EnableFileOps();
1277
Cn3D_Open_InUse = FALSE;
1280
if (GetValue(Cn3D_gMdlLvl) == 5) { /* turn off backbone model if "All" models present */
1281
pmsdThis = (PMSD) pdnmsModelstruc->data.ptrvalue;
1282
MMDB_OpenTraverse(pmsdThis);
1284
Cn3D_SetPars(NewStructureRenderSet(), pdnmsModelstruc);
1286
Remove(Cn3D_wNetOpen);
1287
Cn3D_EnableFileOps();
1289
/*CALL TO initialize the view */
1291
Cn3D_Open_InUse = FALSE;
1299
static void Cn3D_NetOpenCancelProc(GraphiC g)
1301
Remove(Cn3D_wNetOpen);
1302
Cn3D_EnableFileOps();
1303
Cn3D_Open_InUse = FALSE;
1307
NLM_EXTERN void Cn3D_NetOpenBiostruc(IteM i)
1312
if (Cn3D_Open_InUse)
1315
Cn3D_Open_InUse = TRUE;
1317
Cn3D_StartNet(TRUE);
1318
if (!Cn3D_ColorData.EntrezOn) return;
1321
MovableModalWindow(-30, -20, -10, -10, " Internet retrieve from MMDB ",
1323
hg = HiddenGroup(Cn3D_wNetOpen, 3, 0, NULL);
1324
SetGroupSpacing(hg, 30, 30);
1325
g = NormalGroup(hg, 1, 0, " Enter accession code:", systemFont, NULL);
1326
SetGroupMargins(g, 10, 15);
1327
Cn3D_tOpen = DialogText(g, "", 10, (TxtActnProc) Cn3D_OpenEnableProc);
1329
NormalGroup(hg, 1, 2, " accession type", systemFont, NULL);
1330
SetGroupMargins(Cn3D_gAccType, 10, 10);
1331
RadioButton(Cn3D_gAccType, "PDB Code");
1332
RadioButton(Cn3D_gAccType, "MMDB ID");
1334
g = HiddenGroup(hg, 1, 2, NULL);
1335
SetGroupSpacing(g, 15, 15);
1337
DefaultButton(g, "OK", (BtnActnProc) Cn3D_NetOpenAcceptProc);
1338
b = PushButton(g, "Cancel", (BtnActnProc) Cn3D_NetOpenCancelProc);
1341
NormalGroup(Cn3D_wNetOpen, 2, 3, " model complexity", systemFont,
1343
SetGroupMargins(Cn3D_gMdlLvl, 10, 10);
1344
SetGroupSpacing(Cn3D_gMdlLvl, 10, 5);
1345
RadioButton(Cn3D_gMdlLvl, "a) NCBI one XYZ per atom model");
1346
RadioButton(Cn3D_gMdlLvl, "c) NCBI backbone model");
1347
RadioButton(Cn3D_gMdlLvl, "b) original PDB models 1-n");
1348
RadioButton(Cn3D_gMdlLvl, "d) NCBI vector model");
1349
RadioButton(Cn3D_gMdlLvl, "Viewing Subset (a, c and d)");
1350
RadioButton(Cn3D_gMdlLvl, "Everything");
1353
NormalGroup(Cn3D_wNetOpen, 7, 0, " n = ", systemFont, NULL);
1354
RadioButton(Cn3D_gMdlNo, "1");
1355
RadioButton(Cn3D_gMdlNo, "2");
1356
RadioButton(Cn3D_gMdlNo, "5");
1357
RadioButton(Cn3D_gMdlNo, "10");
1358
RadioButton(Cn3D_gMdlNo, "15");
1359
RadioButton(Cn3D_gMdlNo, "20");
1360
RadioButton(Cn3D_gMdlNo, "maximum");
1363
SetValue(Cn3D_gMdlNo, 7);
1364
SetValue(Cn3D_gAccType, 1);
1365
SetValue(Cn3D_gMdlLvl, 5);
1366
Disable(Cn3D_bOpenAccept);
1367
Cn3D_DisableFileOps();
1369
Show(Cn3D_wNetOpen);
1373
/*********************************************/
1374
/* below this are the file i/o open-er procs */
1375
/*********************************************/
1377
NLM_EXTERN void Cn3D_OpenBiostruc(IteM i)
1380
unsigned char szBegin[10];
1381
BiostrucPtr pbsBiostruc;
1382
PDNMS pdnmsModelstruc;
1383
PMSD pmsdThis = NULL;
1384
Int4 MdlNo = MAX_MDLNO;
1389
GetInputFileName(str, sizeof(str), NULL, NULL);
1390
if(StrCmp(str,"") == 0) return;
1392
hFile = FileOpen(str, "rb");
1393
if(hFile == NULL) return;
1394
FileGets((CharPtr) szBegin, 2, hFile);
1395
if (hFile == NULL) szBegin[0] = (Char) 0;
1397
if(szBegin[0] == 31 && szBegin[1] == 139) {
1399
"This file may require a newer version of Cn3D. Go to http://www.ncbi.nlm.nih.gov/Structure/CN3D for more information");
1402
/* to make cn3d to take strucseq for which szBegin[0] is 78 */
1403
/* for single biostruc szBegin[0] is 48 */
1404
if (szBegin[0] > 70) { /* mime */
1405
if (!OpenMimeFileWithDeletion(str, FALSE)) {
1408
} else { /* not mime */
1411
hFile = FileOpen(str, "r");
1413
FileRead(buf, 1, StrLen(PRINT_FORM_BIOSTRUC), hFile);
1415
if (StrNCmp(buf, PRINT_FORM_BIOSTRUC, StrLen(PRINT_FORM_BIOSTRUC)) ==
1417
/* these get everything in the file , ignoring modellevel */
1419
FetchBS(str, INP_ASCII_FILE, BSEVERYTHING, MdlNo,
1421
} else { /* Binary */
1423
FetchBS(str, INP_BINARY_FILE, BSEVERYTHING, MdlNo,
1427
if (pbsBiostruc != NULL) {
1429
pdnmsModelstruc = MakeAModelstruc(pbsBiostruc);
1430
pmsdThis = (PMSD) pdnmsModelstruc->data.ptrvalue;
1431
MMDB_OpenTraverse(pmsdThis);
1432
Cn3D_SetPars(NewStructureRenderSet(), pdnmsModelstruc);
1438
} /* switch between mime and non-mime */
1441
/* generic set up for new alignment */
1442
static void Cn3D_ImportSAEnd(SeqAlign *salp, Boolean Neat)
1450
if (salp == NULL) return;
1451
pdnmsThis = GetSelectedModelstruc();
1452
if (!pdnmsThis) return;
1454
/* close the sequence window */
1456
ObjMgrGetEntityIDForPointer((void *) Cn3D_ColorData.pvnsep);
1457
ObjMgrSendMsg(OM_MSG_FLUSH, entityID, 0, 0);
1459
/* fetch the active structure */
1460
pars = (PARS) ((PMSD) pdnmsThis->data.ptrvalue)->pGlobalPARS;
1462
pars->ConsColAlg = (Nlm_Int2) 0;
1463
pars->PBBColor = C_BYSEQCONS;
1464
pars->PResColor = C_BYSEQCONS;
1465
pars->ObjectOn = FALSE;
1468
annot = SeqAnnotNew();
1469
if(annot == NULL) return;
1473
/* change mime type for saving */
1475
pmsdThis = pdnmsThis->data.ptrvalue;
1476
if(pmsdThis) pmsdThis->iMimeType = NcbiMimeAsn1_strucseqs;
1477
Cn3D_MarkStrucSeqs(pdnmsThis, annot);
1480
Cn3D_ColorData.pDDVColorGlobal = NULL; /* force creation of new color object */
1481
Cn3D_RegisterSeqAnnot(annot, Neat, Neat); /* register annot? */
1482
Cn3D_StoreAlignRowNumsInMMDs(annot);
1483
Cn3D_LaunchSeqAnnot(annot);
1484
ViewMgr_Update(salp);
1485
Disable(Cn3D_ColorData.BlastMany);
1491
static void Cn3D_ImportSAEndCB(UDV_BlastDlgData *bddp)
1493
if(bddp) Cn3D_ImportSAEnd(bddp->salp, bddp->IBM);
1497
/*******************************************************************************
1499
Function : Cn3D_BlastDlg()
1501
Purpose : Blast alignment dialog for multiple alignment
1503
Parameters : i; menu
1505
*******************************************************************************/
1506
NLM_EXTERN void Cn3D_BlastDlg(IteM i)
1508
UDV_BlastDlgData *bddp;
1510
if(Cn3D_ColorData.sap) return;
1511
Cn3D_StartNet(TRUE);
1512
if (!Cn3D_ColorData.EntrezOn) {
1513
Message(MSG_ERROR, "Blast requires network access");
1517
bddp = (UDV_BlastDlgData *)MemNew(sizeof(UDV_BlastDlgData));
1518
if (bddp == NULL) return;
1519
bddp->pvnSips = SAM_ExtractSips(Cn3D_ColorData.pvnsep);
1520
bddp->callback = Cn3D_ImportSAEndCB;
1528
static void Cn3D_ImportSeqEntry(DDV_ImportDialog *idp)
1531
Uint2 entityID, entityIDsalp;
1534
entityID = ObjMgrGetEntityIDForPointer((void *) idp->bsp);
1536
if(Cn3D_ColorData.sap && (idp->mode == DDVIMPNET2SA
1537
|| idp->mode == DDVIMPSE2SA)) {
1538
MemSet(&dum, 0, sizeof(DDVUpdateMSG));
1539
dum.data = &entityID;
1540
dum.type = UPDATE_TYPE_NEWSEQ;
1541
entityIDsalp = ObjMgrGetEntityIDForPointer((void *) Cn3D_ColorData.sap->data);
1542
ObjMgrSendProcMsg(OM_MSG_UPDATE, entityIDsalp, 0, OBJ_SEQALIGN,
1543
0, 0, (Pointer)&dum);
1546
if(idp->mode & DDVIMPNET)
1548
idp->sep = GetBestTopParentForData(entityID, idp->bsp);
1549
for(pvn = Cn3D_ColorData.pvnsep; pvn != NULL; pvn = pvn->next)
1550
if(pvn == idp->sep) return;
1552
ValNodeLink(&Cn3D_ColorData.pvnsep, idp->sep);
1553
idp->sep->next = NULL;
1554
SAM_MakeViewerFree((void *) idp->sep);
1555
if(IS_Bioseq(idp->sep)) GatherSpecificProcLaunch(0, "Seq-Struc Communication",
1556
OMPROC_VIEW, FALSE, entityID, 0, OBJ_BIOSEQ);
1557
else GatherSpecificProcLaunch(0, "Seq-Struc Communication", OMPROC_VIEW,
1558
FALSE, entityID, 0, OBJ_BIOSEQSET);
1561
/*******************************************************************************
1563
Function : Cn3D_ImportCBSE()
1565
Purpose : callback for importing single sequence into a seqalign
1567
*******************************************************************************/
1568
static void Cn3D_ImportCBSE(DDV_ImportDialog *idp, SeqAlign *salpdest,
1571
if (salpdest == NULL || salp == NULL) return;
1572
SeqAlignSetFree(salp->next);
1574
ViewMgr_Add(salpdest, salp);
1575
Cn3D_ImportSeqEntry(idp);
1578
/*******************************************************************************
1580
Function : Cn3D_ImportCB()
1582
Purpose : callback for importing single sequence and creating a new pairwise
1585
*******************************************************************************/
1586
static void Cn3D_ImportCB(DDV_ImportDialog *idp, SeqAlign *salpdest,
1589
if (salp == NULL) return;
1590
SeqAlignSetFree(salp->next);
1592
Cn3D_ImportSAEnd(salp, TRUE);
1593
Cn3D_ImportSeqEntry(idp);
1596
/*******************************************************************************
1598
Function : Cn3D_ImportBioseq()
1600
Purpose : Import a single bioseq via the net
1602
*******************************************************************************/
1603
static void Cn3D_sImportBioseq(Boolean Gap)
1605
DDV_ImportDialog *idp;
1607
idp = MemNew(sizeof(DDV_ImportDialog));
1608
if(idp == NULL) return;
1610
idp->AccessionCB = Cn3D_Accession2Gi;
1612
Cn3D_StartNet(TRUE);
1613
if (!Cn3D_ColorData.EntrezOn) {
1614
Message(MSG_ERROR, "Blast requires network access");
1618
if(Cn3D_ColorData.sap == NULL) {
1620
idp->callback = Cn3D_ImportCB;
1621
idp->pvnSips = SAM_ExtractSips(Cn3D_ColorData.pvnsep);
1622
idp->mode = DDVIMPNET2SE;
1625
idp->sap = (SeqAlign *)Cn3D_ColorData.sap->data;
1626
idp->sip = AlnMgrFindMaster(idp->sap);
1627
idp->callback = Cn3D_ImportCBSE;
1628
idp->mode = DDVIMPNET2SA;
1631
DDV_ImportBioseqDlg(idp);
1634
NLM_EXTERN void Cn3D_ImportBioseq(IteM i)
1636
Cn3D_sImportBioseq(FALSE);
1639
NLM_EXTERN void Cn3D_ImportBioseqGap(IteM i)
1641
Cn3D_sImportBioseq(TRUE);
1645
/*******************************************************************************
1647
Function : Cn3D_ImportBioseqFile()
1649
Purpose : Import a single bioseq from a fasta file
1651
*******************************************************************************/
1652
static void Cn3D_sImportBioseqFile(Boolean Gap)
1654
DDV_ImportDialog *idp;
1655
SeqEntry *sep; /* need to deallocate! */
1661
GetInputFileName(str, sizeof(str), NULL, NULL);
1662
if(StrCmp(str,"") == 0) return;
1664
fp = FileOpen(str,"r");
1666
sep = FastaToSeqEntry(fp, FALSE);
1669
Message(MSG_ERROR, "Sequence Import Error");
1673
if (IS_Bioseq(sep)) {
1674
bsp = (BioseqPtr) sep->data.ptrvalue;
1675
if (bsp != NULL) ObjMgrRegister (OBJ_BIOSEQ, (Pointer) bsp);
1678
Message(MSG_ERROR, "Sequence Import Error: must be a single sequence");
1682
idp = MemNew(sizeof(DDV_ImportDialog));
1683
if(idp == NULL) return;
1686
idp->sipslave = SAM_ExtractSips(sep);
1687
idp->AccessionCB = Cn3D_Accession2Gi;
1689
if(Cn3D_ColorData.sap == NULL) {
1691
idp->callback = Cn3D_ImportCB;
1692
idp->pvnSips = SAM_ExtractSips(Cn3D_ColorData.pvnsep);
1693
idp->mode = DDVIMPSE2SE;
1694
DDV_ImportBioseqDlg(idp);
1697
idp->sap = (SeqAlign *)Cn3D_ColorData.sap->data;
1698
idp->sip = AlnMgrFindMaster(idp->sap);
1699
idp->callback = Cn3D_ImportCBSE;
1700
idp->mode = DDVIMPSE2SA;
1706
NLM_EXTERN void Cn3D_ImportBioseqFile(IteM i)
1708
Cn3D_sImportBioseqFile(FALSE);
1711
NLM_EXTERN void Cn3D_ImportBioseqFileGap(IteM i)
1713
Cn3D_sImportBioseqFile(TRUE);
1717
NLM_EXTERN Int4 Cn3D_Accession2Gi (CharPtr string, Boolean IsAmino)
1722
DocType AAorNN; /* is this of TYP_AA or TYP_NA */
1724
if (!EntrezIsInited ()) {
1725
Message (MSG_ERROR, "Network connection to Entrez unavailable");
1729
if(IsAmino) AAorNN = TYP_AA;
1730
else AAorNN = TYP_NT;
1732
str = MemNew (StringLen (string) + 10);
1733
sprintf (str, "\"%s\" [ACCN]", string);
1734
lsp = EntrezTLEvalString (str, AAorNN, -1, NULL, NULL);
1736
if (lsp == NULL) return 0;
1737
if (lsp->num <= 0) {