3875
4102
h = HiddenGroup (w, -1, 0, NULL);
3876
4103
SetGroupSpacing (h, 10, 10);
4105
afp->aln_settings = AlnSettingsDlg (h, TRUE);
4107
c = HiddenGroup (h, 4, 0, NULL);
4108
b = DefaultButton (c, "Accept", DoReadAlignment);
4109
SetObjectExtra (b, afp, NULL);
4110
PushButton (c, "Cancel", StdCancelButtonProc);
4112
AlignObjects (ALIGN_CENTER, (HANDLE) afp->aln_settings, (HANDLE) c, NULL);
4118
extern void ReadAlignment (IteM i)
4120
BuildGetAlphabetDialog (i);
4125
typedef struct alnsettingsdlg {
4126
DIALOG_MESSAGE_BLOCK
4133
PopuP sequence_type;
4134
} AlnSettingsDlgData, PNTR AlnSettingsDlgPtr;
4136
static CharPtr aln_settings_help = "\
4137
Beginning Gap: When some of the sequences in an \
4138
alignment are shorter or longer than others, beginning \
4139
gap characters are added to the beginning of the sequence \
4140
to maintain the correct spacing. These will not appear \
4141
in your sequence file.\n\
4142
Middle Gap: These characters are used to maintain the spacing \
4143
inside an alignment. These are not nucleotides and will \
4144
not appear as part of your sequence file.\n\
4145
End Gap: When some of the sequences in an alignment are shorter \
4146
or longer than others, end gap characters are added to the end \
4147
of the sequence to maintain the correct spacing. These will \
4148
not appear in your sequence file.\n\
4149
Ambiguous/Unknown: These characters are used to represent \
4150
indeterminate/ambiguous nucleotides. These will appear in your \
4151
sequence file as 'n'.\n\
4152
Match: These characters are used to indicate positions where \
4153
sequences are identical to the first sequence. These will be \
4154
replaced by the actual characters from the first sequence.";
4156
const char *nucleotide_alphabet = "ABCDGHKMRSTUVWYabcdghkmrstuvwy";
4157
const char *protein_alphabet = "ABCDEFGHIKLMPQRSTUVWXYZabcdefghiklmpqrstuvwxyz";
4159
extern TSequenceInfoPtr GetDefaultSequenceInfo (void)
4161
TSequenceInfoPtr sequence_info = SequenceInfoNew();
4163
sequence_info->missing = MemFree (sequence_info->missing);
4164
sequence_info->missing = StringSave ("?Nn");
4166
sequence_info->beginning_gap = MemFree (sequence_info->beginning_gap);
4167
sequence_info->beginning_gap = StringSave ("-.Nn?");
4169
sequence_info->middle_gap = MemFree (sequence_info->middle_gap);
4170
sequence_info->middle_gap = StringSave ("-.");
4172
sequence_info->end_gap = MemFree (sequence_info->end_gap);
4173
sequence_info->end_gap = StringSave ("-.Nn?");
4175
sequence_info->match = MemFree (sequence_info->match);
4176
sequence_info->match = StringSave (":");
4178
sequence_info->alphabet = nucleotide_alphabet;
4180
return sequence_info;
4183
static Pointer AlnSettingsDlgToData (DialoG d)
4185
AlnSettingsDlgPtr dlg;
4186
TSequenceInfoPtr sequence_info;
4188
dlg = (AlnSettingsDlgPtr) GetObjectExtra (d);
4189
if (dlg == NULL) return NULL;
4191
sequence_info = SequenceInfoNew ();
4192
if (sequence_info == NULL) return NULL;
4194
sequence_info->missing = MemFree (sequence_info->missing);
4195
sequence_info->missing = SaveStringFromText (dlg->missing);
4197
sequence_info->beginning_gap = MemFree (sequence_info->beginning_gap);
4198
sequence_info->beginning_gap = SaveStringFromText (dlg->beginning_gap);
4200
sequence_info->middle_gap = MemFree (sequence_info->middle_gap);
4201
sequence_info->middle_gap = SaveStringFromText (dlg->middle_gap);
4203
sequence_info->end_gap = MemFree (sequence_info->end_gap);
4204
sequence_info->end_gap = SaveStringFromText (dlg->end_gap);
4206
sequence_info->match = MemFree (sequence_info->match);
4207
sequence_info->match = SaveStringFromText (dlg->match);
4209
if (dlg->sequence_type != NULL)
4211
if (GetValue (dlg->sequence_type) == 1) {
4212
sequence_info->alphabet = nucleotide_alphabet;
4214
sequence_info->alphabet = protein_alphabet;
4219
sequence_info->alphabet = nucleotide_alphabet;
4222
return sequence_info;
4226
static void DataToAlnSettingsDlg (DialoG d, Pointer data)
4228
AlnSettingsDlgPtr dlg;
4229
TSequenceInfoPtr sequence_info;
4231
dlg = (AlnSettingsDlgPtr) GetObjectExtra (d);
4232
if (dlg == NULL) return;
4234
sequence_info = (TSequenceInfoPtr) data;
4236
if (sequence_info == NULL)
4238
SetTitle (dlg->missing, "?Nn");
4239
SetTitle (dlg->beginning_gap, "-.Nn?");
4240
SetTitle (dlg->middle_gap, "-.");
4241
SetTitle (dlg->end_gap, "-.Nn?");
4242
SetTitle (dlg->match, ":");
4243
if (dlg->sequence_type != NULL)
4245
SetValue (dlg->sequence_type, 1);
4250
SetTitle (dlg->missing, sequence_info->missing);
4251
SetTitle (dlg->beginning_gap, sequence_info->beginning_gap);
4252
SetTitle (dlg->middle_gap, sequence_info->middle_gap);
4253
SetTitle (dlg->end_gap, sequence_info->end_gap);
4254
SetTitle (dlg->match, sequence_info->match);
4256
if (dlg->sequence_type != NULL)
4258
if (StringCmp (sequence_info->alphabet, protein_alphabet) == 0)
4260
SetValue (dlg->sequence_type, 2);
4264
SetValue (dlg->sequence_type, 1);
4271
static ValNodePtr TestAlnSettingsDlg (DialoG d)
4273
ValNodePtr err_list = NULL;
4274
TSequenceInfoPtr sequence_info;
4276
CharPtr fmt = "Character %c cannot appear in both %s and %s.";
4278
CharPtr missing_name = "Ambiguous/Unknown";
4279
CharPtr middle_gap_name = "Middle Gap";
4280
CharPtr match_name = "Match";
4282
sequence_info = DialogToPointer (d);
4283
if (sequence_info == NULL) return NULL;
4285
/* missing and match cannot appear in middle gap list */
4286
cp = sequence_info->missing;
4287
while (cp != NULL && *cp != 0)
4289
if (StringChr (sequence_info->middle_gap, *cp))
4291
err_str = (CharPtr) MemNew (sizeof (Char) * (StringLen (fmt)
4292
+ StringLen (missing_name)
4293
+ StringLen (middle_gap_name)));
4294
sprintf (err_str, fmt, *cp, missing_name, middle_gap_name);
4295
ValNodeAddPointer (&err_list, 0, err_str);
4300
cp = sequence_info->match;
4301
while (cp != NULL && *cp != 0)
4303
if (StringChr (sequence_info->middle_gap, *cp))
4305
err_str = (CharPtr) MemNew (sizeof (Char) * (StringLen (fmt)
4306
+ StringLen (match_name)
4307
+ StringLen (middle_gap_name)));
4308
sprintf (err_str, fmt, *cp, match_name, middle_gap_name);
4309
ValNodeAddPointer (&err_list, 0, err_str);
4314
/* missing and match cannot share characters */
4315
cp = sequence_info->missing;
4316
while (cp != NULL && *cp != 0)
4318
if (StringChr (sequence_info->match, *cp))
4320
err_str = (CharPtr) MemNew (sizeof (Char) * (StringLen (fmt)
4321
+ StringLen (missing_name)
4322
+ StringLen (match_name)));
4323
sprintf (err_str, fmt, *cp, missing_name, match_name);
4324
ValNodeAddPointer (&err_list, 0, err_str);
4333
extern DialoG AlnSettingsDlg (GrouP h, Boolean allow_sequence_type)
4335
AlnSettingsDlgPtr dlg;
3878
g = HiddenGroup (h, 2, 4, NULL);
4338
dlg = (AlnSettingsDlgPtr) MemNew (sizeof (AlnSettingsDlgData));
4339
p = HiddenGroup (h, -1, 0, NULL);
4340
SetObjectExtra (p, dlg, StdCleanupExtraProc);
4341
SetGroupSpacing (p, 10, 10);
4343
dlg->dialog = (DialoG) p;
4344
dlg->todialog = DataToAlnSettingsDlg;
4345
dlg->fromdialog = AlnSettingsDlgToData;
4346
dlg->testdialog = TestAlnSettingsDlg;
4348
g = HiddenGroup (p, 2, 0, NULL);
3879
4349
StaticPrompt (g, "Ambiguous/Unknown", 0, dialogTextHeight, programFont, 'c');
3880
afp->missing = DialogText (g, "?Nn", 5, NULL);
4350
dlg->missing = DialogText (g, "?Nn", 5, NULL);
3881
4351
StaticPrompt (g, "Match", 0, dialogTextHeight, programFont, 'c');
3882
afp->match = DialogText (g, ".", 5, NULL);
4352
dlg->match = DialogText (g, ".", 5, NULL);
3883
4353
StaticPrompt (g, "Beginning Gap", 0, dialogTextHeight, programFont, 'c');
3884
afp->beginning_gap = DialogText (g, "-.?nN", 5, NULL);
4354
dlg->beginning_gap = DialogText (g, "-.?nN", 5, NULL);
3885
4355
StaticPrompt (g, "Middle Gap", 0, dialogTextHeight, programFont, 'c');
3886
afp->middle_gap = DialogText (g, "-", 5, NULL);
4356
dlg->middle_gap = DialogText (g, "-", 5, NULL);
3887
4357
StaticPrompt (g, "End Gap", 0, dialogTextHeight, programFont, 'c');
3888
afp->end_gap = DialogText (g, "-.?nN", 5, NULL);
3889
StaticPrompt (g, "Sequence Type", 0, dialogTextHeight, programFont, 'c');
3890
afp->sequence_type = PopupList (g, TRUE, NULL);
3891
PopupItem (afp->sequence_type, "Nucleotide");
3892
PopupItem (afp->sequence_type, "Protein");
3893
SetValue (afp->sequence_type, 1);
3895
c = HiddenGroup (h, 4, 0, NULL);
3896
b = DefaultButton (c, "Accept", DoReadAlignment);
3897
SetObjectExtra (b, afp, NULL);
3898
PushButton (c, "Cancel", StdCancelButtonProc);
3900
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
3906
extern void ReadAlignment (IteM i)
3908
BuildGetAlphabetDialog (i);
4358
dlg->end_gap = DialogText (g, "-.?nN", 5, NULL);
4359
if (allow_sequence_type) {
4360
StaticPrompt (g, "Sequence Type", 0, dialogTextHeight, programFont, 'c');
4361
dlg->sequence_type = PopupList (g, TRUE, NULL);
4362
PopupItem (dlg->sequence_type, "Nucleotide");
4363
PopupItem (dlg->sequence_type, "Protein");
4364
SetValue (dlg->sequence_type, 1);
4367
p_msg = MultiLinePrompt (p, aln_settings_help, 750, systemFont);
4369
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) p_msg, NULL);
4627
5091
static Boolean debug_fix_pub_equiv = FALSE;
4628
5092
static Boolean debug_fix_pub_set = FALSE;
5094
static Boolean log_mla_asn = FALSE;
5095
static Boolean log_mla_set = FALSE;
5097
static ValNodePtr LookupAnArticleFuncNew (ValNodePtr oldpep, BoolPtr success)
5100
CitArtPtr cap = NULL;
5105
ValNodePtr pub = NULL;
5111
if (success != NULL) {
5114
if (oldpep == NULL) return NULL;
5117
if (! log_mla_set) {
5118
str = (CharPtr) getenv ("LOG_MLA_ASN");
5119
if (StringDoesHaveText (str)) {
5120
if (StringICmp (str, "TRUE") == 0) {
5128
for (vnp = oldpep; vnp != NULL; vnp = vnp->next) {
5129
if (vnp->choice == PUB_Article) {
5130
cap = (CitArtPtr) vnp->data.ptrvalue;
5131
} else if (vnp->choice == PUB_PMid) {
5132
pmid = (Int4) vnp->data.intvalue;
5137
mrp = Mla2CreateCitArtMatchRequest (cap);
5140
LaunchAsnTextViewer ((Pointer) mrp, (AsnWriteFunc) MlaRequestAsnWrite, "citart match request");
5142
mbp = Mla2SynchronousQuery (mrp);
5143
mrp = MlaRequestFree (mrp);
5146
LaunchAsnTextViewer ((Pointer) mbp, (AsnWriteFunc) MlaBackAsnWrite, "citart match result");
5148
pmid = Mla2ExtractCitMatchReply (mbp);
5149
mbp = MlaBackFree (mbp);
5155
mrp = Mla2CreatePubFetchRequest (pmid);
5158
LaunchAsnTextViewer ((Pointer) mrp, (AsnWriteFunc) MlaRequestAsnWrite, "get pub request");
5160
mbp = Mla2SynchronousQuery (mrp);
5161
mrp = MlaRequestFree (mrp);
5164
LaunchAsnTextViewer ((Pointer) mbp, (AsnWriteFunc) MlaBackAsnWrite, "get pub result");
5166
cap = Mla2ExtractPubFetchReply (mbp);
5169
LaunchAsnTextViewer ((Pointer) cap, (AsnWriteFunc) CitArtAsnWrite, "before");
5171
ChangeCitArtMLAuthorsToSTD (cap);
5173
LaunchAsnTextViewer ((Pointer) cap, (AsnWriteFunc) CitArtAsnWrite, "after");
5175
for (ids = cap->ids; ids != NULL; ids = ids->next) {
5176
if (ids->choice != ARTICLEID_PUBMED) continue;
5177
if (ids->data.intvalue != pmid) {
5178
Message (MSG_POSTERR, "CitArt ID %ld does not match PMID %ld",
5179
(long) ids->data.intvalue, (long) pmid);
5182
pub = ValNodeAddPointer (NULL, PUB_Article, (Pointer) cap);
5183
ValNodeAddInt (&pub, PUB_PMid, pmid);
5184
if (success != NULL) {
5188
mbp = MlaBackFree (mbp);
4630
5196
static ValNodePtr LookupAnArticleFunc (ValNodePtr oldpep, BoolPtr success)
6290
static void TermListFormMenus (WindoW w)
6297
bfp = (BaseFormPtr) GetObjectExtra (w);
6299
m = PulldownMenu (w, "File");
6300
AddAboutAndHelpMenuItems (m);
6301
FormCommandItem (m, "Close", bfp, VIB_MSG_CLOSE);
6303
if (loadSaveUidListOK) {
6304
FormCommandItem (m, "Import Uid List...", bfp, VIB_MSG_IMPORT);
6305
FormCommandItem (m, "Export Uid List...", bfp, VIB_MSG_EXPORT);
6308
FormCommandItem (m, "Quit/Q", bfp, VIB_MSG_QUIT);
6310
m = PulldownMenu (w, "Edit");
6311
FormCommandItem (m, CUT_MENU_ITEM, bfp, VIB_MSG_CUT);
6312
FormCommandItem (m, COPY_MENU_ITEM, bfp, VIB_MSG_COPY);
6313
FormCommandItem (m, PASTE_MENU_ITEM, bfp, VIB_MSG_PASTE);
6314
FormCommandItem (m, CLEAR_MENU_ITEM, bfp, VIB_MSG_DELETE);
6316
m = PulldownMenu (w, "Options");
6317
CommandItem (m, "Preferences...", PreferencesProc);
6319
sub = SubMenu (m, "Query Style");
6320
CreateQueryTypeChoice (sub, bfp);
6321
CreateClearUnusedItem (m, bfp);
6323
m = PulldownMenu (w, "Misc");
6324
CommandItem (m, "Style Manager...", StyleManagerProc);
6327
if (BiostrucAvail ()) {
6329
CommandItem (m, "Cn3D Window...", Cn3DWinShowProc);
6334
VSMAddToMenu (m, VSM_DESKTOP);
6338
static void DocSumFormMenus (WindoW w)
6347
bfp = (BaseFormPtr) GetObjectExtra (w);
6349
m = PulldownMenu (w, "File");
6350
FormCommandItem (m, "Close", bfp, VIB_MSG_CLOSE);
6352
FormCommandItem (m, "Import FASTA or Uid List...", bfp, VIB_MSG_IMPORT);
6353
FormCommandItem (m, "Export...", bfp, VIB_MSG_EXPORT);
6356
FormCommandItem (m, "Save", bfp, VIB_MSG_SAVE);
6357
FormCommandItem (m, "Save As...", bfp, VIB_MSG_SAVE_AS);
6360
FormCommandItem (m, "Print...", bfp, VIB_MSG_PRINT);
6362
m = PulldownMenu (w, "Edit");
6363
FormCommandItem (m, COPY_MENU_ITEM, bfp, VIB_MSG_COPY);
6365
m = PulldownMenu (w, "Options");
6366
CommandItem (m, "Preferences...", PreferencesProc);
6368
sub = SubMenu (m, "Font Selection");
6369
i = CommandItem (sub, "DocSum Font...", DocSumFontChangeProc);
6370
SetObjectExtra (i, bfp, NULL);
6372
i = CommandItem (sub, "Display Font...", DisplayFontChangeProc);
6373
SetObjectExtra (i, bfp, NULL);
6376
sub = SubMenu (m, "Neighbor Policy");
6377
c = CreateNeighborDelayChoice (sub, bfp);
6378
SetValue (c, 2); /* UseDelayedNeighbor */
6380
LoadDocsumOptionsMenu (m);
6381
seqviewprocs.alignWithChecked = entrezglobals.alignWithChecked;
6382
seqviewprocs.alignDefault = entrezglobals.alignDefault;
6384
CreateAnalysisMenu (w, bfp, FALSE, TRUE);
6389
6902
static void GetRidCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 indent)
6429
6942
SeqEntryExplore (sep, NULL, GetRidCallback);
6432
typedef struct findgenedata {
6437
} FindGeneData, PNTR FindGenePtr;
6439
typedef struct tripletdata {
6446
} TripletData, PNTR TripletDataPtr;
6448
static Boolean FindOverlappingGeneFunc (GatherContextPtr gcp)
6456
if (gcp == NULL) return TRUE;
6458
fgp = (FindGenePtr) gcp->userdata;
6459
if (fgp == NULL) return TRUE;
6460
if (gcp->thistype == OBJ_SEQFEAT) {
6461
sfp = (SeqFeatPtr) gcp->thisitem;
6462
if (sfp != NULL && sfp->data.choice == SEQFEAT_GENE) {
6463
grp = (GeneRefPtr) sfp->data.value.ptrvalue;
6465
diff = SeqLocAinB (fgp->slp, sfp->location);
6467
if (diff < fgp->min) {
6479
static Boolean FindTripletItem (GatherContextPtr gcp)
6485
tdp = (TripletDataPtr) gcp->userdata;
6486
if (tdp != NULL && gcp->thisitem == tdp->lookfor) {
6487
tdp->entityID = gcp->entityID;
6488
tdp->itemID = gcp->itemID;
6489
tdp->itemtype = gcp->thistype;
6490
omtp = ObjMgrTypeFind (tdp->omp, gcp->thistype, NULL, NULL);
6492
if (omtp->labelfunc != NULL) {
6493
(*(omtp->labelfunc)) (gcp->thisitem, tdp->label, 80, OM_LABEL_CONTENT);
6500
static CharPtr deleteCdsMsg =
6501
"In addition to deleting the CDS feature, you should probably\n\
6502
delete the protein product, which is a separate data element in\n\
6503
the record. You will be asked about this in a subsequent message.\n\
6504
Do you wish to continue deleting the CDS?";
6506
6945
static CharPtr deleteProtMsg =
6507
6946
"The protein product of a CDS (shown in the /translation qualifier)\n\
6508
6947
is actually a separate data element in the record. Unless explicitly\n\
6509
deleted, it will remain hidden in the record after you delete the CDS.\n\
6510
Do you wish to delete the protein product";
6948
deleted, it will remain hidden in the record after you delete the CDS.";
6512
6950
static CharPtr deleteGeneMsg =
6513
6951
"The /gene qualifier is generated from an overlapping gene feature.\n\
6514
If you delete a CDS you may also want to delete this separate gene.\n\
6515
Do you wish to delete the overlapping gene";
6517
static CharPtr deleteMrnaMsg =
6518
"In addition to deleting the mRNA feature, you should probably\n\
6519
delete the cDNA and protein products, which are separate data\n\
6520
elements in the record. Do you wish to continue deleting the mRNA?";
6952
If you delete a CDS you may also want to delete this separate gene.";
6522
6954
static CharPtr deleteCdnaMsg =
6523
6955
"The cDNA product of an mRNA is actually a separate data element\n\
6524
6956
in the record. Unless explicitly deleted, it will remain hidden\n\
6525
in the record after you delete the mRNA. Do you wish to delete\n\
6957
in the record after you delete the mRNA.";
6959
typedef struct deletecdsoptions {
6960
Boolean delete_feature;
6961
Boolean delete_gene;
6962
Boolean delete_cdna;
6963
Boolean delete_protein;
6964
} DeleteCDSOptionsData, PNTR DeleteCDSOptionsPtr;
6966
static void GetDeleteCDSOptions (DeleteCDSOptionsPtr dcop)
6971
ModalAcceptCancelData acd;
6972
ButtoN delete_gene = NULL;
6973
ButtoN delete_cdna = NULL;
6974
ButtoN delete_protein = NULL;
6976
if (dcop == NULL) return;
6977
if (!dcop->delete_gene
6978
&& !dcop->delete_cdna
6979
&& !dcop->delete_protein) {
6983
acd.accepted = FALSE;
6984
acd.cancelled = FALSE;
6986
w = ModalWindow(-20, -13, -10, -10, NULL);
6987
h = HiddenGroup (w, -1, 0, NULL);
6988
SetGroupSpacing (h, 10, 10);
6990
g = HiddenGroup (h, 2, 0, NULL);
6991
SetGroupSpacing (g, 10, 10);
6992
if (dcop->delete_gene) {
6993
delete_gene = CheckBox (g, "Delete overlapping gene", NULL);
6994
MultiLinePrompt (g, deleteGeneMsg, 30 * stdCharWidth, systemFont);
6997
if (dcop->delete_cdna) {
6998
delete_cdna = CheckBox (g, "Delete cDNA", NULL);
6999
SetStatus (delete_cdna, TRUE);
7000
MultiLinePrompt (g, deleteCdnaMsg, 30 * stdCharWidth, systemFont);
7003
if (dcop->delete_protein) {
7004
delete_protein = CheckBox (g, "Delete protein product", NULL);
7005
SetStatus (delete_protein, TRUE);
7006
MultiLinePrompt (g, deleteProtMsg, 30 * stdCharWidth, systemFont);
7009
c = HiddenGroup (h, 3, 0, NULL);
7010
SetGroupSpacing (c, 10, 10);
7011
b = PushButton (c, "Accept", ModalAcceptButton);
7012
SetObjectExtra (b, &acd, NULL);
7013
b = PushButton (c, "Cancel", ModalCancelButton);
7014
SetObjectExtra (b, &acd, NULL);
7015
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);
7019
while (!acd.accepted && ! acd.cancelled)
7021
ProcessExternalEvent ();
7028
dcop->delete_feature = TRUE;
7029
dcop->delete_gene = delete_gene == NULL ? FALSE : GetStatus (delete_gene);
7030
dcop->delete_cdna = delete_cdna == NULL ? FALSE : GetStatus (delete_cdna);
7031
dcop->delete_protein = delete_protein == NULL ? FALSE : GetStatus (delete_protein);
7035
dcop->delete_feature = FALSE;
7036
dcop->delete_gene = FALSE;
7037
dcop->delete_cdna = FALSE;
7038
dcop->delete_protein = FALSE;
6528
7042
static Boolean DeleteSelectedFeatureOrDescriptor (GatherContextPtr gcp)
6533
7046
BioseqPtr cdna;
6535
7047
Uint2 entityID;
6536
7048
SeqFeatPtr gene;
6539
7050
Uint2 itemtype;
6541
7051
BioseqSetPtr nps;
6544
7052
BioseqSetPtr parent;
6546
7053
SeqFeatPtr sfp;
6549
SeqFeatXrefPtr xref;
7055
DeleteCDSOptionsData dcod;
7056
SeqMgrFeatContext fcontext;
6550
7059
#ifdef USE_SMARTNET
6552
7060
UserObjectPtr uop;
7063
if (gcp->thistype != OBJ_SEQDESC && gcp->thistype != OBJ_SEQFEAT) {
7064
/* This function should only handle descriptors and features */
7066
} else if (gcp->thisitem == NULL) {
6556
7070
#ifdef USE_SMARTNET
6557
7071
/* This code will prevent from deletion SMART User Object */
7086
/* delete the descriptor */
7087
if (gcp->thistype == OBJ_SEQDESC) {
7088
sdp = (SeqDescrPtr) gcp->thisitem;
7089
if (sdp != NULL && sdp->extended != 0) {
7090
ovn = (ObjValNodePtr) sdp;
7091
ovn->idx.deleteme = TRUE;
7098
/* because it wasn't a descriptor, this must be a feature */
7099
sfp = (SeqFeatPtr) gcp->thisitem;
6578
7104
entityID = gcp->entityID;
6579
7105
itemID = gcp->itemID;
6580
7106
itemtype = gcp->thistype;
6582
scope = GetBestTopParentForItemID (entityID, itemID, itemtype);
6583
if (gcp->thistype == OBJ_SEQFEAT) {
6584
sfp = (SeqFeatPtr) gcp->thisitem;
6585
if (sfp != NULL && sfp->idx.subtype == FEATDEF_mRNA && sfp->product != NULL) {
6587
sip = SeqLocId (mrna->product);
6589
cdna = BioseqFind (sip);
6591
if (cdna->idx.parenttype == OBJ_BIOSEQSET) {
6592
parent = (BioseqSetPtr) cdna->idx.parentptr;
6593
while (parent != NULL) {
6594
if (parent->_class == BioseqseqSet_class_nuc_prot) {
6597
if (parent->idx.parenttype == OBJ_BIOSEQSET) {
6598
parent = (BioseqSetPtr) parent->idx.parentptr;
7108
/* When deleting some features, there are other objects that the user may wish to
7109
* remove at the same time.
7110
* When removing a coding region, the user may wish to also do the following:
7111
* 1) Remove the overlapping gene
7112
* 2) Remove the product protein
7113
* When removing an mRNA, the user may wish to also do the following:
7114
* 1) Remove the cDNA product
7115
* 2) Remove the nucprotset parent
7117
if (sfp->idx.subtype == FEATDEF_mRNA && sfp->product != NULL) {
7118
sip = SeqLocId (sfp->product);
7120
cdna = BioseqFind (sip);
7122
if (cdna->idx.parenttype == OBJ_BIOSEQSET) {
7123
parent = (BioseqSetPtr) cdna->idx.parentptr;
7124
while (parent != NULL) {
7125
if (parent->_class == BioseqseqSet_class_nuc_prot) {
7128
if (parent->idx.parenttype == OBJ_BIOSEQSET) {
7129
parent = (BioseqSetPtr) parent->idx.parentptr;
6607
if (sfp != NULL && sfp->data.choice != SEQFEAT_CDREGION) {
7137
} else if (sfp->idx.subtype == FEATDEF_CDS) {
6612
7138
if (sfp->product != NULL) {
6613
7139
sip = SeqLocId (sfp->product);
6614
7140
if (sip != NULL) {
6615
7141
bsp = BioseqFind (sip);
6619
while (xref != NULL && xref->data.choice != SEQFEAT_GENE) {
6623
MemSet ((Pointer) (&gs), 0, sizeof (GatherScope));
6625
gs.get_feats_location = TRUE;
6626
MemSet ((Pointer)(gs.ignore), (int)(TRUE), (size_t)(OBJ_MAX * sizeof(Boolean)));
6627
gs.ignore[OBJ_BIOSEQ] = FALSE;
6628
gs.ignore[OBJ_BIOSEQ_SEG] = FALSE;
6629
gs.ignore[OBJ_SEQFEAT] = FALSE;
6630
gs.ignore[OBJ_SEQANNOT] = FALSE;
6635
fgd.slp = sfp->location;
6636
GatherEntity (entityID, (Pointer) &fgd, FindOverlappingGeneFunc, &gs);
6637
if (fgd.sfp != NULL) {
7144
if (SeqMgrGetGeneXref(sfp) == NULL) {
7145
gene = SeqMgrGetOverlappingGene (sfp->location, &fcontext);
7149
MemSet (&dcod, 0, sizeof (dcod));
6642
7150
if (sfp != NULL) {
6643
ans = Message (MSG_OKC, "%s", deleteCdsMsg);
6644
if (ans == ANS_CANCEL) {
6648
if (nps != NULL || cdna != NULL) {
6649
ans = Message (MSG_OKC, "%s", deleteMrnaMsg);
6650
if (ans == ANS_CANCEL) {
6654
MemSet ((Pointer) (&ompc), 0, sizeof (OMProcControl));
6655
ompc.do_not_reload_from_cache = TRUE;
6656
ompc.input_entityID = entityID;
6657
ompc.input_itemID = itemID;
6658
ompc.input_itemtype = itemtype;
6659
if (! DetachDataForProc (&ompc, FALSE)) {
6660
Message (MSG_ERROR, "DetachDataForProc failed");
6662
if (nps != NULL || cdna != NULL) {
6663
ans = Message (MSG_YN, "%s", deleteCdnaMsg, td.label);
6664
if (ans == ANS_YES) {
6666
nps->idx.deleteme = TRUE;
6667
} else if (cdna != NULL) {
6668
cdna->idx.deleteme = TRUE;
7151
dcod.delete_feature = TRUE;
7153
if (nps != NULL || cdna != NULL) {
7154
dcod.delete_cdna = TRUE;
6672
7156
if (bsp != NULL) {
6677
td.lookfor = (Pointer) bsp;
6678
td.label [0] = '\0';
6679
MemSet ((Pointer) (&gs), 0, sizeof (GatherScope));
6681
gs.get_feats_location = TRUE;
6682
MemSet ((Pointer)(gs.ignore), (int)(TRUE), (size_t)(OBJ_MAX * sizeof(Boolean)));
6683
gs.ignore[OBJ_BIOSEQ] = FALSE;
6684
gs.ignore[OBJ_BIOSEQ_SEG] = FALSE;
6685
gs.ignore[OBJ_SEQFEAT] = FALSE;
6686
gs.ignore[OBJ_SEQANNOT] = FALSE;
6688
GatherEntity (entityID, (Pointer) (&td), FindTripletItem, &gs);
6689
if (td.entityID > 0 && td.itemID > 0 && td.itemtype > 0) {
6690
ans = Message (MSG_YN, "%s (%s)?", deleteProtMsg, td.label);
6691
if (ans == ANS_YES) {
6692
MemSet ((Pointer) (&ompc), 0, sizeof (OMProcControl));
6693
ompc.do_not_reload_from_cache = TRUE;
6694
ompc.input_entityID = td.entityID;
6695
ompc.input_itemID = td.itemID;
6696
ompc.input_itemtype = td.itemtype;
6697
if (! DetachDataForProc (&ompc, FALSE)) {
6698
Message (MSG_ERROR, "DetachDataForProc failed");
7157
dcod.delete_protein = TRUE;
6703
7160
if (gene != NULL) {
6708
td.lookfor = (Pointer) gene;
6709
td.label [0] = '\0';
6710
MemSet ((Pointer) (&gs), 0, sizeof (GatherScope));
6712
gs.get_feats_location = TRUE;
6713
MemSet ((Pointer)(gs.ignore), (int)(TRUE), (size_t)(OBJ_MAX * sizeof(Boolean)));
6714
gs.ignore[OBJ_BIOSEQ] = FALSE;
6715
gs.ignore[OBJ_BIOSEQ_SEG] = FALSE;
6716
gs.ignore[OBJ_SEQFEAT] = FALSE;
6717
gs.ignore[OBJ_SEQANNOT] = FALSE;
6719
GatherEntity (entityID, (Pointer) (&td), FindTripletItem, &gs);
6720
if (td.entityID > 0 && td.itemID > 0 && td.itemtype > 0) {
6721
ans = Message (MSG_YN, "%s (%s)?", deleteGeneMsg, td.label);
6722
if (ans == ANS_YES) {
6723
MemSet ((Pointer) (&ompc), 0, sizeof (OMProcControl));
6724
ompc.do_not_reload_from_cache = TRUE;
6725
ompc.input_entityID = td.entityID;
6726
ompc.input_itemID = td.itemID;
6727
ompc.input_itemtype = td.itemtype;
6728
if (! DetachDataForProc (&ompc, FALSE)) {
6729
Message (MSG_ERROR, "DetachDataForProc failed");
7161
dcod.delete_gene = TRUE;
7164
GetDeleteCDSOptions (&dcod);
7165
if (!dcod.delete_feature) {
7170
/* delete the feature */
7171
sfp->idx.deleteme = TRUE;
7173
/* delete cdna product */
7174
if (dcod.delete_cdna) {
7176
nps->idx.deleteme = TRUE;
7177
} else if (cdna != NULL) {
7178
cdna->idx.deleteme = TRUE;
7182
/* delete protein product */
7183
if (bsp != NULL && dcod.delete_protein) {
7184
bsp->idx.deleteme = TRUE;
7187
/* delete overlapping gene */
7188
if (gene != NULL && dcod.delete_gene) {
7189
gene->idx.deleteme = TRUE;
7192
/* Note - delete marked objects is called by the calling function */
8095
8574
AsnSetXMLmodulePrefix (StringSave (str));
8098
if (GetSequinAppParam ("PREFERENCES", "COL1R", NULL, str, sizeof (str)))
8100
if (StrToInt (str, &val) && val > 0) {
8101
val = MIN (val, 255);
8102
seqedprocs.col1r = val;
8105
if (GetSequinAppParam ("PREFERENCES", "COL1G", NULL, str, sizeof (str)))
8107
if (StrToInt (str, &val) && val > 0) {
8108
val = MIN (val, 255);
8109
seqedprocs.col1g = val;
8112
if (GetSequinAppParam ("PREFERENCES", "COL1B", NULL, str, sizeof (str)))
8114
if (StrToInt (str, &val) && val > 0) {
8115
val = MIN (val, 255);
8116
seqedprocs.col1b = val;
8119
if (GetSequinAppParam ("PREFERENCES", "COL2R", NULL, str, sizeof (str)))
8121
if (StrToInt (str, &val) && val > 0) {
8122
val = MIN (val, 255);
8123
seqedprocs.col2r = val;
8126
if (GetSequinAppParam ("PREFERENCES", "COL2G", NULL, str, sizeof (str)))
8128
if (StrToInt (str, &val) && val > 0) {
8129
val = MIN (val, 255);
8130
seqedprocs.col2g = val;
8133
if (GetSequinAppParam ("PREFERENCES", "COL2B", NULL, str, sizeof (str)))
8135
if (StrToInt (str, &val) && val > 0) {
8136
val = MIN (val, 255);
8137
seqedprocs.col2b = val;
8140
if (GetSequinAppParam ("PREFERENCES", "COL3R", NULL, str, sizeof (str)))
8142
if (StrToInt (str, &val) && val > 0) {
8143
val = MIN (val, 255);
8144
seqedprocs.col3r = val;
8147
if (GetSequinAppParam ("PREFERENCES", "COL3G", NULL, str, sizeof (str)))
8149
if (StrToInt (str, &val) && val > 0) {
8150
val = MIN (val, 255);
8151
seqedprocs.col3g = val;
8154
if (GetSequinAppParam ("PREFERENCES", "COL3B", NULL, str, sizeof (str)))
8156
if (StrToInt (str, &val) && val > 0) {
8157
val = MIN (val, 255);
8158
seqedprocs.col3b = val;
8161
if (GetSequinAppParam ("PREFERENCES", "COL4R", NULL, str, sizeof (str)))
8163
if (StrToInt (str, &val) && val > 0) {
8164
val = MIN (val, 255);
8165
seqedprocs.col4r = val;
8168
if (GetSequinAppParam ("PREFERENCES", "COL4G", NULL, str, sizeof (str)))
8170
if (StrToInt (str, &val) && val > 0) {
8171
val = MIN (val, 255);
8172
seqedprocs.col4g = val;
8175
if (GetSequinAppParam ("PREFERENCES", "COL4B", NULL, str, sizeof (str)))
8177
if (StrToInt (str, &val) && val > 0) {
8178
val = MIN (val, 255);
8179
seqedprocs.col4b = val;
8182
if (GetSequinAppParam ("PREFERENCES", "COL5R", NULL, str, sizeof (str)))
8184
if (StrToInt (str, &val) && val > 0) {
8185
val = MIN (val, 255);
8186
seqedprocs.col5r = val;
8189
if (GetSequinAppParam ("PREFERENCES", "COL5G", NULL, str, sizeof (str)))
8191
if (StrToInt (str, &val) && val > 0) {
8192
val = MIN (val, 255);
8193
seqedprocs.col5g = val;
8196
if (GetSequinAppParam ("PREFERENCES", "COL5B", NULL, str, sizeof (str)))
8198
if (StrToInt (str, &val) && val > 0) {
8199
val = MIN (val, 255);
8200
seqedprocs.col5b = val;
8203
if (GetSequinAppParam ("PREFERENCES", "COL6R", NULL, str, sizeof (str)))
8205
if (StrToInt (str, &val) && val > 0) {
8206
val = MIN (val, 255);
8207
seqedprocs.col6r = val;
8210
if (GetSequinAppParam ("PREFERENCES", "COL6G", NULL, str, sizeof (str)))
8212
if (StrToInt (str, &val) && val > 0) {
8213
val = MIN (val, 255);
8214
seqedprocs.col6g = val;
8217
if (GetSequinAppParam ("PREFERENCES", "COL6B", NULL, str, sizeof (str)))
8219
if (StrToInt (str, &val) && val > 0) {
8220
val = MIN (val, 255);
8221
seqedprocs.col6b = val;
8225
if (GetSequinAppParam ("PREFERENCES", "COL7R", NULL, str, sizeof (str)))
8227
if (StrToInt (str, &val) && val > 0) {
8228
val = MIN (val, 255);
8229
seqedprocs.col7r = val;
8232
if (GetSequinAppParam ("PREFERENCES", "COL7G", NULL, str, sizeof (str)))
8234
if (StrToInt (str, &val) && val > 0) {
8235
val = MIN (val, 255);
8236
seqedprocs.col7g = val;
8239
if (GetSequinAppParam ("PREFERENCES", "COL7B", NULL, str, sizeof (str)))
8241
if (StrToInt (str, &val) && val > 0) {
8242
val = MIN (val, 255);
8243
seqedprocs.col7b = val;
8247
8577
validateExons = TRUE;
8248
8578
if (GetSequinAppParam ("PREFERENCES", "VALIDATEEXONS", NULL, str, sizeof (str))) {
8249
8579
if (StringICmp (str, "FALSE") == 0) {
10467
static CharPtr hupfetchproc = "HUPBioseqFetch";
10469
static CharPtr hupfetchcmd = NULL;
10471
extern Pointer ReadFromHUP (CharPtr accn, Uint2Ptr datatype, Uint2Ptr entityID);
10472
extern Pointer ReadFromHUP (CharPtr accn, Uint2Ptr datatype, Uint2Ptr entityID)
10478
Char path [PATH_MAX];
10480
if (datatype != NULL) {
10483
if (entityID != NULL) {
10486
if (! dirsubMode) return NULL;
10487
if (StringHasNoText (accn)) return NULL;
10489
if (hupfetchcmd == NULL) {
10490
if (GetAppParam ("SEQUIN", "HUP", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) {
10491
hupfetchcmd = StringSaveNoNull (cmmd);
10494
if (hupfetchcmd == NULL) return NULL;
10499
sprintf (cmmd, "csh %s %s > %s", hupfetchcmd, accn, path);
10503
sprintf (cmmd, "%s %s -o %s", hupfetchcmd, accn, path);
10507
fp = FileOpen (path, "r");
10512
dataptr = ReadAsnFastaOrFlatFile (fp, datatype, entityID, FALSE, FALSE, TRUE, FALSE);
10519
static Int2 LIBCALLBACK HUPBioseqFetchFunc (Pointer data)
10528
OMProcControlPtr ompcp;
10529
ObjMgrProcPtr ompp;
10530
Char path [PATH_MAX];
10531
SeqEntryPtr sep = NULL;
10534
OMUserDataPtr omudp;
10536
ompcp = (OMProcControlPtr) data;
10537
if (ompcp == NULL) return OM_MSG_RET_ERROR;
10538
ompp = ompcp->proc;
10539
if (ompp == NULL) return OM_MSG_RET_ERROR;
10540
sip = (SeqIdPtr) ompcp->input_data;
10541
if (sip == NULL) return OM_MSG_RET_ERROR;
10543
if (sip->choice != SEQID_GENBANK) return OM_MSG_RET_ERROR;
10544
tsip = (TextSeqIdPtr) sip->data.ptrvalue;
10545
if (tsip == NULL || StringHasNoText (tsip->accession)) return OM_MSG_RET_ERROR;
10547
if (hupfetchcmd == NULL) {
10548
if (GetAppParam ("SEQUIN", "HUP", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) {
10549
hupfetchcmd = StringSaveNoNull (cmmd);
10552
if (hupfetchcmd == NULL) return OM_MSG_RET_ERROR;
10557
sprintf (cmmd, "csh %s %s > %s", hupfetchcmd, tsip->accession, path);
10561
sprintf (cmmd, "%s %s -o %s", hupfetchcmd, tsip->accession, path);
10565
fp = FileOpen (path, "r");
10568
return OM_MSG_RET_ERROR;
10570
dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, &entityID, FALSE, FALSE, TRUE, FALSE);
10574
if (dataptr == NULL) return OM_MSG_RET_OK;
10576
sep = GetTopSeqEntryForEntityID (entityID);
10577
if (sep == NULL) return OM_MSG_RET_ERROR;
10578
bsp = BioseqFindInSeqEntry (sip, sep);
10579
ompcp->output_data = (Pointer) bsp;
10580
ompcp->output_entityID = ObjMgrGetEntityIDForChoice (sep);
10582
omudp = ObjMgrAddUserData(ompcp->output_entityID, ompp->procid, OMPROC_FETCH, 0);
10585
return OM_MSG_RET_DONE;
10588
static Boolean HUPFetchEnable (void)
10591
ObjMgrProcLoad (OMPROC_FETCH, hupfetchproc, hupfetchproc,
10592
OBJ_SEQID, 0, OBJ_BIOSEQ, 0, NULL,
10593
HUPBioseqFetchFunc, PROC_PRIORITY_DEFAULT);
10067
10597
static CharPtr tpasmartfetchproc = "TPASmartBioseqFetch";
10069
10599
static CharPtr tpasmartfetchcmd = NULL;
11995
extern void MakeBadSpecificHostValueTable (IteM i)
11999
ValNodePtr bad_biop_list;
12003
bfp = currentFormDataPtr;
12005
bfp = GetObjectExtra (i);
12007
if (bfp == NULL) return;
12008
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
12009
if (sep == NULL) return;
12011
bad_biop_list = Taxon3CheckSpecificHostInSeqEntry (sep, TRUE, FALSE);
12013
if (bad_biop_list == NULL)
12015
Message (MSG_OK, "No bad specific-host values found!");
12018
lip = OpenLog ("Bad Specific-Host Values");
12020
lip->data_in_log = WriteBadSpecificHostTable (bad_biop_list, lip->fp);
12022
bad_biop_list = ValNodeFree (bad_biop_list);
12024
lip = FreeLog (lip);
12028
typedef struct updatefeaturesform {
12030
DialoG new_features;
12031
ValNodePtr feat_list;
12033
} UpdateFeaturesFormData, PNTR UpdateFeaturesFormPtr;
12036
static void CleanupUpdateFeaturesForm (GraphiC g, VoidPtr data)
12038
UpdateFeaturesFormPtr f;
12040
f = (UpdateFeaturesFormPtr) data;
12042
f->feat_list = FreeClickableList (f->feat_list);
12043
f->sap = SeqAnnotFree (f->sap);
12045
StdCleanupFormProc (g, data);
12050
static CharPtr GetNewItemDescription (SeqFeatPtr sfp)
12052
CharPtr location, label, row_text;
12055
location = SeqLocPrintUseBestID (sfp->location);
12056
label = (CharPtr) FeatDefTypeLabel(sfp);
12058
FeatDefLabel (sfp, buf, sizeof (buf) - 1, OM_LABEL_CONTENT);
12060
row_text = (CharPtr) MemNew (sizeof (Char) *
12063
+ StringLen (location)
12065
sprintf (row_text, "%s:%s:%s\n", label, buf, location);
12066
location = MemFree (location);
12071
static ClickableItemPtr PutFeaturesInOldItem (ValNodePtr item_list)
12073
ClickableItemPtr cip_olditems, cip;
12076
cip_olditems = (ClickableItemPtr) MemNew (sizeof (ClickableItemData));
12077
if (item_list == NULL) {
12078
cip_olditems->description = StringSave ("No old features found");
12079
cip_olditems->chosen = FALSE;
12081
for (vnp = item_list; vnp != NULL; vnp = vnp->next) {
12082
cip = (ClickableItemPtr) MemNew (sizeof (ClickableItemData));
12083
cip->description = GetNewItemDescription (vnp->data.ptrvalue);
12084
cip->chosen = TRUE;
12085
ValNodeAddPointer (&(cip->item_list), OBJ_SEQFEAT, vnp->data.ptrvalue);
12086
ValNodeAddPointer (&(cip_olditems->subcategories), 0, cip);
12088
cip_olditems->description = StringSave ("Old Features (check to delete)");
12089
cip_olditems->chosen = TRUE;
12091
return cip_olditems;
12095
static void MarkChosenFeatures (ValNodePtr item_list, Boolean delete_marked)
12097
ClickableItemPtr cip;
12101
while (item_list != NULL) {
12102
cip = (ClickableItemPtr) item_list->data.ptrvalue;
12104
for (vnp = cip->item_list; vnp != NULL; vnp = vnp->next) {
12105
if (vnp->choice == OBJ_SEQFEAT) {
12106
sfp = (SeqFeatPtr) vnp->data.ptrvalue;
12107
if ((cip->chosen && delete_marked) || (!cip->chosen && !delete_marked)) {
12108
sfp->idx.deleteme = TRUE;
12113
item_list = item_list->next;
12118
static void MarkChosenFeaturesForBioseqs (ValNodePtr feat_list)
12120
ClickableItemPtr cip, cip_new, cip_old;
12122
if (feat_list == NULL) return;
12123
cip = (ClickableItemPtr) feat_list->data.ptrvalue;
12124
if (cip->item_list != NULL && cip->item_list->choice == OBJ_BIOSEQ) {
12125
if (cip->subcategories != NULL) {
12126
cip_new = (ClickableItemPtr) cip->subcategories->data.ptrvalue;
12127
MarkChosenFeatures (cip_new->subcategories, FALSE);
12128
if (cip->subcategories->next != NULL) {
12129
cip_old = (ClickableItemPtr) cip->subcategories->next->data.ptrvalue;
12130
MarkChosenFeatures (cip_old->subcategories, TRUE);
12133
MarkChosenFeaturesForBioseqs (feat_list->next);
12134
} else if (feat_list->next != NULL && feat_list->next->next == NULL && cip->item_list == NULL) {
12135
cip_new = (ClickableItemPtr) feat_list->data.ptrvalue;
12136
cip_old = (ClickableItemPtr) feat_list->next->data.ptrvalue;
12137
MarkChosenFeatures (cip_new->subcategories, FALSE);
12138
MarkChosenFeatures (cip_old->subcategories, TRUE);
12143
static void DoUpdateFeatures (ButtoN b)
12145
UpdateFeaturesFormPtr f;
12147
f = (UpdateFeaturesFormPtr) GetObjectExtra (b);
12148
if (f == NULL) return;
12150
MarkChosenFeaturesForBioseqs (f->feat_list);
12152
SmartAttachSeqAnnotToSeqEntry (f->input_entityID, f->sap, NULL);
12155
DeleteMarkedObjects (f->input_entityID, 0, NULL);
12156
ObjMgrSetDirtyFlag (f->input_entityID, TRUE);
12157
ObjMgrSendMsg (OM_MSG_UPDATE, f->input_entityID, 0, 0);
12163
extern void UpdateFeatures (IteM i)
12170
Char path [PATH_MAX];
12173
ValNodePtr new_feat_list = NULL, no_bsp_list = NULL, old_item_list;
12174
Int4 leftmost = -1, rightmost = -1, new_left, new_right, tmp;
12175
BioseqPtr bsp, last_bsp = NULL;
12176
ClickableItemPtr cip = NULL, cip_newitems = NULL, cip_olditems, cip_newfeat;
12181
UpdateFeaturesFormPtr f;
12185
bfp = currentFormDataPtr;
12187
bfp = GetObjectExtra (i);
12189
if (bfp == NULL) return;
12190
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
12191
if (sep == NULL) return;
12194
if (!GetInputFileName (path, sizeof (path), "", "TEXT")) {
12198
fp = FileOpen (path, "r");
12200
Message (MSG_ERROR, "Unable to open file!");
12203
dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, NULL, FALSE, FALSE,
12206
if (dataptr == NULL || datatype != OBJ_SEQANNOT) {
12207
Message (MSG_ERROR, "File does not contain feature table!");
12211
sap = (SeqAnnotPtr) dataptr;
12212
if (sap->type != 1) {
12213
Message (MSG_ERROR, "File does not contain feature table!");
12214
sap = SeqAnnotFree (sap);
12218
// list features for each bioseq
12219
for (sfp = sap->data; sfp != NULL; sfp = sfp->next) {
12220
bsp = BioseqFindFromSeqLoc (sfp->location);
12222
ValNodeAddPointer (&no_bsp_list, OBJ_SEQFEAT, sfp);
12224
if (bsp != last_bsp) {
12225
if (last_bsp != NULL) {
12226
slp = SeqLocIntNew (leftmost, rightmost, Seq_strand_plus, SeqIdDup (SeqIdFindWorst (bsp->id)));
12227
old_item_list = ListFeaturesOverlappingLocation (last_bsp, slp, 0, 0);
12228
slp = SeqLocFree (slp);
12229
cip_olditems = PutFeaturesInOldItem (old_item_list);
12230
old_item_list = ValNodeFree (old_item_list);
12231
ValNodeAddPointer (&(cip->subcategories), 0, cip_olditems);
12233
cip = (ClickableItemPtr) MemNew (sizeof (ClickableItemData));
12234
ValNodeAddPointer (&(cip->item_list), OBJ_BIOSEQ, bsp);
12236
SeqIdWrite (SeqIdFindBest (bsp->id, SEQID_GENBANK), id, PRINTID_FASTA_LONG, sizeof (id) - 1);
12237
cip->description = StringSave (id);
12238
cip_newitems = (ClickableItemPtr) MemNew (sizeof (ClickableItemData));
12239
cip_newitems->description = StringSave ("New Features (check to import)");
12240
cip_newitems->chosen = TRUE;
12241
ValNodeAddPointer (&(cip->subcategories), 0, cip_newitems);
12243
ValNodeAddPointer (&new_feat_list, 0, cip);
12247
cip_newfeat = (ClickableItemPtr) MemNew (sizeof (ClickableItemData));
12248
cip_newfeat->description = GetNewItemDescription (sfp);
12249
cip_newfeat->chosen = TRUE;
12250
ValNodeAddPointer (&(cip_newfeat->item_list), OBJ_SEQFEAT, sfp);
12251
ValNodeAddPointer (&(cip_newitems->subcategories), 0, cip_newfeat);
12252
new_left = SeqLocStart (sfp->location);
12253
new_right = SeqLocStop (sfp->location);
12254
if (new_left > new_right) {
12256
new_left = new_right;
12259
if (leftmost == -1 || new_left < leftmost) {
12260
leftmost = new_left;
12262
if (rightmost == -1 || new_right > rightmost) {
12263
rightmost = new_right;
12267
if (last_bsp != NULL) {
12268
slp = SeqLocIntNew (leftmost, rightmost, Seq_strand_plus, SeqIdDup (SeqIdFindWorst (bsp->id)));
12269
old_item_list = ListFeaturesOverlappingLocation (last_bsp, slp, 0, 0);
12270
slp = SeqLocFree (slp);
12271
cip_olditems = PutFeaturesInOldItem (old_item_list);
12272
old_item_list = ValNodeFree (old_item_list);
12273
ValNodeAddPointer (&(cip->subcategories), 0, cip_olditems);
12276
if (no_bsp_list != NULL) {
12277
Message (MSG_ERROR, "%d features in table are not found on a Bioseq in this record!", ValNodeLen (no_bsp_list));
12278
no_bsp_list = ValNodeFree (no_bsp_list);
12281
if (new_feat_list == NULL) {
12282
Message (MSG_ERROR, "No features found!");
12283
sap = SeqAnnotFree (sap);
12286
if (new_feat_list->next == NULL) {
12287
no_bsp_list = new_feat_list;
12288
cip = (ClickableItemPtr) new_feat_list->data.ptrvalue;
12289
new_feat_list = cip->subcategories;
12290
cip->subcategories = NULL;
12291
no_bsp_list = FreeClickableList (no_bsp_list);
12295
/* Now create dialog to allow user to select new features to import and existing features to delete */
12296
f = (UpdateFeaturesFormPtr) MemNew (sizeof (UpdateFeaturesFormData));
12297
w = FixedWindow (-50, -33, -10, -10, "Update Features", StdCloseWindowProc);
12298
SetObjectExtra (w, f, CleanupUpdateFeaturesForm);
12299
f->form = (ForM) w;
12300
f->input_entityID = bfp->input_entityID;
12301
f->feat_list = new_feat_list;
12303
h = HiddenGroup (w, -1, 0, NULL);
12304
SetGroupSpacing (h, 10, 10);
12305
g = HiddenGroup (h, 2, 0, NULL);
12306
f->new_features = CreateClickableListDialog (g, "New Features (check to import)", "label1", NULL, NULL, NULL, GetDiscrepancyItemText);
12307
PointerToDialog (f->new_features, new_feat_list);
12308
/* f->old_features = CreateClickableListDialog (g, "Old Features", "label1",
12309
ScrollToDiscrepancyItem, EditDiscrepancyItem, bfp,
12310
GetDiscrepancyItemText); */
12311
c = HiddenGroup (h, 4, 0, NULL);
12312
b = PushButton (c, "Accept", DoUpdateFeatures);
12313
SetObjectExtra (b, f, NULL);
12314
PushButton (c, "Cancel", StdCancelButtonProc);
12316
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, NULL);