summaryrefslogtreecommitdiff
path: root/sequin
diff options
context:
space:
mode:
authorAaron M. Ucko <ucko@debian.org>2005-06-17 02:24:46 +0000
committerAaron M. Ucko <ucko@debian.org>2005-06-17 02:24:46 +0000
commitd76c50353c9e74f6915ca6352afb29ae53d45777 (patch)
tree9045ebb0b61573bfa4ff3d8778899c5a2cb76d6c /sequin
parent402b112099aa816a02fd502b7f0261a99fe7126a (diff)
Load /tmp/.../ncbi-tools6-6.1.20050605 into
branches/upstream/current.
Diffstat (limited to 'sequin')
-rw-r--r--sequin/sequin.h106
-rw-r--r--sequin/sequin1.c55
-rw-r--r--sequin/sequin10.c433
-rw-r--r--sequin/sequin2.c2889
-rw-r--r--sequin/sequin3.c1197
-rw-r--r--sequin/sequin4.c313
-rw-r--r--sequin/sequin5.c1215
-rw-r--r--sequin/sequin6.c617
-rw-r--r--sequin/sequin7.c50
-rw-r--r--sequin/sequin8.c3
-rw-r--r--sequin/sequin9.c1741
11 files changed, 4657 insertions, 3962 deletions
diff --git a/sequin/sequin.h b/sequin/sequin.h
index 09ebe58f..d5aa01ff 100644
--- a/sequin/sequin.h
+++ b/sequin/sequin.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.289 $
+* $Revision: 6.300 $
*
* File Description:
*
@@ -181,6 +181,7 @@ extern ForM CreateStartupForm (Int2 left, Int2 top, CharPtr title,
BtnActnProc readExisting,
BtnActnProc fetchFromNet,
BtnActnProc showHelp,
+ BtnActnProc createSubmissionTemplate,
BtnActnProc quitProgram,
WndActnProc activateForm);
@@ -348,12 +349,6 @@ extern Int2 LIBCALLBACK BioseqSetEditFunc (Pointer data);
extern void LaunchOrfViewer (BioseqPtr bsp, Uint2 entityID, Uint2 itemID, Boolean standAlone);
-#define ADD_TITLE 1
-#define ADD_RRNA 2
-#define ADD_CDS 3
-#define ADD_IMP 4
-#define ADD_GENE 5
-
extern Int2 ApplyAnnotationToAll (Int2 type, SeqEntryPtr sep,
ButtoN partialLft, ButtoN partialRgt,
TexT geneName, TexT protName,
@@ -415,6 +410,7 @@ extern void ExportAlignmentInterleave (IteM i);
extern void ExportAlignmentContiguous (IteM i);
extern void FixFeatureIntervals (IteM i);
extern void ConvertInnerCDSsToProteinFeatures (IteM i);
+extern void CombineMultipleCDS (IteM i);
extern void NewDescriptorMenuFunc (ObjMgrProcPtr ompp, BaseFormPtr bfp, Uint2 descsubtype);
extern Boolean PropagateFromGenBankBioseqSet (SeqEntryPtr sep, Boolean ask);
@@ -440,6 +436,8 @@ extern void ApplyTitle (IteM i);
extern void ApplyCDS (IteM i);
extern void ApplyRRNA (IteM i);
extern void ApplyImpFeat (IteM i);
+extern void AdjustCDSLocationsForGapsCallback (SeqFeatPtr sfp, Pointer userdata);
+extern void AdjustCDSLocationsForGaps (IteM i);
extern void LoadTPAAccessionNumbersFromFile (IteM i);
extern void LoadSecondaryAccessionNumbersFromFile (IteM i);
extern void LoadHistoryAccessionNumbersFromFile (IteM i);
@@ -677,7 +675,8 @@ typedef struct sequencesform {
ButtoN specify_mgcode_btn;
ButtoN clear_mods_btn;
DoC org_doc;
- DoC summary_doc;
+ ButtoN ident_org_btn;
+ DialoG summary_dlg;
/* These allow the user to specify topology and molecule */
ButtoN topology_btn;
@@ -685,15 +684,8 @@ typedef struct sequencesform {
} SequencesForm, PNTR SequencesFormPtr;
-typedef int (LIBCALLBACK *CompareFunc) (Nlm_VoidPtr, Nlm_VoidPtr);
-
-extern int LIBCALLBACK CompareImpFeatEnumFieldAssoc (VoidPtr ptr1, VoidPtr ptr2);
-extern int LIBCALLBACK CompareFeatureValNodeStrings (VoidPtr ptr1, VoidPtr ptr2);
-
extern ValNodePtr InsertMostUsedFeatureValNodes (ValNodePtr old_list);
-extern void SortEnumFieldAssocPtrArray (EnumFieldAssocPtr alist, CompareFunc compar);
-
extern ValNodePtr FindExactStringInStrings ( ValNodePtr strings, CharPtr value);
extern EnumFieldAssocPtr InsertMostUsedFeatureEnumFieldAssoc (
@@ -923,6 +915,8 @@ typedef struct stringconstraint
Boolean not_present;
} StringConstraintData, PNTR StringConstraintPtr;
+extern StringConstraintPtr StringConstraintFree (StringConstraintPtr scp);
+
#define CHOICE_CONSTRAINT_ANY 1
#define CHOICE_CONSTRAINT_QUAL_PRESENT 3
#define CHOICE_CONSTRAINT_STRING 5
@@ -944,6 +938,9 @@ typedef struct filterset
ChoiceConstraintPtr cgp;
} FilterSetData, PNTR FilterSetPtr;
+extern void FilterSetClearText (FilterSetPtr fsp);
+extern FilterSetPtr FilterSetFree (FilterSetPtr fsp);
+
extern Boolean DoesStringMatchConstraint (CharPtr pchSource, StringConstraintPtr scp);
typedef CharPtr (*GetFeatureFieldString) PROTO ((SeqFeatPtr, ValNodePtr, FilterSetPtr));
@@ -955,6 +952,17 @@ typedef void (*RemoveDescriptorFieldString) PROTO ((SeqDescrPtr, Pointer, Filter
typedef void (*FeatureActionProc) PROTO ((SeqFeatPtr, Pointer, FilterSetPtr));
typedef void (*DescriptorActionProc) PROTO ((SeqDescrPtr, Pointer, FilterSetPtr));
+extern void
+OperateOnSeqEntryConstrainedObjects
+(SeqEntryPtr sep,
+ FilterSetPtr fsp,
+ FeatureActionProc feature_action,
+ DescriptorActionProc descriptor_action,
+ Uint1 seqFeatChoice,
+ Uint1 featDefChoice,
+ Uint1 descriptorChoice,
+ Pointer userdata);
+
extern CharPtr HandleApplyValue (CharPtr orig_text, ApplyValuePtr avp);
extern ValNodePtr
ApplyValueToValNodeStringList
@@ -1031,28 +1039,25 @@ typedef struct pubconstraint
extern PubConstraintPtr PubConstraintFree (PubConstraintPtr pcp);
extern DialoG PubConstraintDialog (GrouP h);
+extern DialoG AcceptCancelDialog
+(GrouP parent,
+ Nlm_AcceptActnProc accept_actn,
+ Nlm_CancelActnProc cancel_actn,
+ Nlm_ClearActnProc clear_actn,
+ Nlm_ClearTextActnProc clear_text_actn,
+ Pointer userdata,
+ WindoW w);
+extern void EnableAcceptCancelDialogAccept (DialoG d);
+extern void DisableAcceptCancelDialogAccept (DialoG d);
-extern DialoG SelectionDialog
-(GrouP h,
- Nlm_ChangeNotifyProc change_notify,
- Pointer change_userdata,
- Boolean allow_multi,
- CharPtr err_msg,
- ValNodePtr choice_list,
- Int2 list_height);
+extern ValNodePtr BuildFeatureDialogList (Boolean list_most_used_first);
-extern DialoG ValNodeSelectionDialog
-(GrouP h,
- ValNodePtr choice_list,
- Int2 list_height,
- NameFromValNodeProc name_proc,
- FreeValNodeProc free_vn_proc,
- CopyValNodeDataProc copy_vn_proc,
- MatchValNodeProc match_vn_proc,
- CharPtr err_name,
+extern DialoG
+FeatureSelectionDialog
+(GrouP h,
+ Boolean allow_multi,
Nlm_ChangeNotifyProc change_notify,
- Pointer change_userdata,
- Boolean allow_multi);
+ Pointer change_userdata);
extern DialoG SourceQualTypeSelectionDialog
(GrouP h,
@@ -1060,15 +1065,6 @@ extern DialoG SourceQualTypeSelectionDialog
Nlm_ChangeNotifyProc change_notify,
Pointer change_userdata);
-extern DialoG SequenceSelectionDialog
-(GrouP h,
- Nlm_ChangeNotifyProc change_notify,
- Pointer change_userdata,
- Boolean allow_multi,
- Boolean show_nucs,
- Boolean show_prots,
- Uint2 entityID);
-
extern DialoG
FeatureFieldSelectionDialog
(GrouP h,
@@ -1115,21 +1111,21 @@ extern CharPtr GetCDSGeneProtField (SeqFeatPtr sfp, ValNodePtr vnp, FilterSetPtr
extern DialoG
RNAAddFieldSelectionDialog
(GrouP h,
- Boolean allow_none,
+ Boolean allow_multi,
Nlm_ChangeNotifyProc change_notify,
Pointer change_userdata);
extern DialoG
RNARemoveFieldSelectionDialog
(GrouP h,
- Boolean allow_none,
+ Boolean allow_multi,
Nlm_ChangeNotifyProc change_notify,
Pointer change_userdata);
extern DialoG
RNAFieldSelectionDialog
(GrouP h,
- Boolean allow_none,
+ Boolean allow_multi,
Nlm_ChangeNotifyProc change_notify,
Pointer change_userdata);
@@ -1221,6 +1217,24 @@ extern void StringToLower (CharPtr str);
extern Boolean ExportSubmitterBlockTemplate (SeqEntryPtr sep, SeqDescrPtr sdp);
extern DialoG OrganismSelectionDialog (GrouP parent, CharPtr org_name);
+typedef struct getsample
+{
+ GetFeatureFieldString fieldstring_func;
+ GetDescriptorFieldString descrstring_func;
+ ValNodePtr requested_field;
+ FreeValNodeProc free_vn_proc;
+ CopyValNodeDataProc copy_vn_proc;
+
+ CharPtr sample_text;
+ Int4 num_found;
+ Boolean all_same;
+} GetSampleData, PNTR GetSamplePtr;
+
+extern GetSamplePtr GetSampleNew (void);
+extern GetSamplePtr GetSampleFree (GetSamplePtr gsp);
+
+extern ExistingTextPtr GetExistingTextHandlerInfo (GetSamplePtr gsp, Boolean non_text);
+
#ifdef __cplusplus
}
diff --git a/sequin/sequin1.c b/sequin/sequin1.c
index 2375c9e3..6d5a0a43 100644
--- a/sequin/sequin1.c
+++ b/sequin/sequin1.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.505 $
+* $Revision: 6.510 $
*
* File Description:
*
@@ -72,6 +72,7 @@ static char *time_of_compilation = "now";
#include <salsap.h>
#include <salutil.h>
#include <salpedit.h>
+#include <salpanel.h>
#include <salptool.h>
#include <pobutil.h>
#include <accutils.h>
@@ -4177,18 +4178,6 @@ static void StdValidatorFormActivated (WindoW w)
NULL);
}
-extern void UpdateSequenceFormActivated (WindoW w);
-extern void UpdateSequenceFormActivated (WindoW w)
-
-{
- currentFormDataPtr = (VoidPtr) GetObjectExtra (w);
- initialFormsActive = FALSE;
- RepeatProcOnHandles (Enable,
- (HANDLE) openItem,
- (HANDLE) closeItem,
- NULL);
-}
-
static void TextViewProcFormActivated (WindoW w)
{
@@ -8555,7 +8544,12 @@ static void SetupMacMenus (void)
m = PulldownMenu (NULL, "File");
openItem = CommandItem (m, "Open.../O", MacReadNewAsnProc);
+ SetAppProperty (SEQFORM_OPEN_ITEM, openItem);
closeItem = FormCommandItem (m, "Close", NULL, VIB_MSG_CLOSE);
+ SetAppProperty (SEQFORM_CLOSE_ITEM, closeItem);
+
+ SetAppProperty (SEQFORM_INIT_ACTIVE, &initialFormsActive);
+
SeparatorItem (m);
importItem = FormCommandItem (m, "Import.../I", NULL, VIB_MSG_IMPORT);
exportItem = FormCommandItem (m, "Export.../E", NULL, VIB_MSG_EXPORT);
@@ -9192,6 +9186,27 @@ static void StartNew (ButtoN b)
Update ();
}
+static void CloseSubmissionTemplateEditor (Pointer userdata, WindoW w)
+{
+ Remove (w);
+ Show (startupForm);
+ Update ();
+}
+
+static void CreateSubmissionTemplate (ButtoN b)
+
+{
+ WindoW w;
+
+ Hide (startupForm);
+ Update ();
+
+ w = (WindoW) CreateSubmitTemplateEditorForm (-50, -33, "Submission Template Editor",
+ CloseSubmissionTemplateEditor, NULL);
+
+ Show (w);
+}
+
static void FinishGenome (ButtoN b)
{
@@ -10943,11 +10958,11 @@ Int2 Main (void)
startupForm = CreateStartupForm (-5, -67, "Welcome to Sequin",
StartFa2htgs, StartPhrap, BuildContig,
StartNew, ReadOld, fetchProc,
- ShowHelp, DoQuit, StartupActivateProc);
+ ShowHelp, CreateSubmissionTemplate, DoQuit, StartupActivateProc);
} else {
startupForm = CreateStartupForm (-5, -67, "Welcome to Sequin",
NULL, NULL, NULL, StartNew, ReadOld, fetchProc,
- ShowHelp, DoQuit, StartupActivateProc);
+ ShowHelp, NULL, DoQuit, StartupActivateProc);
}
globalFormatBlock.seqPackage = SEQ_PKG_SINGLE;
globalFormatBlock.seqFormat = SEQ_FMT_FASTA;
@@ -11087,10 +11102,12 @@ extern Boolean ExportSubmitterBlockTemplate (SeqEntryPtr sep, SeqDescrPtr sdp)
AsnIoFlush(aip);
AsnIoReset(aip);
- SeqDescAsnWrite (sdp, aip, NULL);
-
- AsnIoFlush(aip);
- AsnIoReset(aip);
+ if (sdp != NULL)
+ {
+ SeqDescAsnWrite (sdp, aip, NULL);
+ AsnIoFlush(aip);
+ AsnIoReset(aip);
+ }
AsnIoClose (aip);
ssp = SeqSubmitFree (ssp);
diff --git a/sequin/sequin10.c b/sequin/sequin10.c
index 4aac80f6..2c54a609 100644
--- a/sequin/sequin10.c
+++ b/sequin/sequin10.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 9/3/2003
*
-* $Revision: 1.265 $
+* $Revision: 1.269 $
*
* File Description:
*
@@ -4146,7 +4146,9 @@ static void GroupSegmentedCDSs (
vnp->choice = DEFLINE_FEATLIST;
vnp->data.ptrvalue = search_sfp;
search_fcp->delete_me = TRUE;
- new_slp = SeqLocIntersection (fcp->slp, search_fcp->slp, bsp);
+ new_slp = SeqLocMerge (bsp, fcp->slp, search_fcp->slp,
+ FALSE, TRUE, FALSE);
+
SeqLocFree (fcp->slp);
fcp->slp = new_slp;
}
@@ -5082,7 +5084,7 @@ static CharPtr GetGenericInterval
{
StringCat (interval, "complete ");
}
- if (IsCDS (sfp))
+ if (IsCDS (sfp) && ! IsPseudo (sfp))
{
StringCat (interval, "cds");
if (fcp->is_alt_spliced)
@@ -8642,8 +8644,11 @@ static CharPtr BuildFeatureClauses (
GroupAltSplicedExons (feature_list, bsp, TRUE);
- /* group CDSs that have the same name and are under the same gene together */
- GroupSegmentedCDSs (feature_list, bsp, TRUE, feature_requests->suppress_locus_tags);
+ if (!isSegment)
+ {
+ /* group CDSs that have the same name and are under the same gene together */
+ GroupSegmentedCDSs (feature_list, bsp, TRUE, feature_requests->suppress_locus_tags);
+ }
/* now group clauses */
GroupAllClauses ( feature_list, bsp );
@@ -9928,6 +9933,10 @@ typedef struct orgmodloadformdata {
SeqEntryPtr seq_list;
Boolean done;
Boolean mods_added;
+
+ /* this member is used for detecting existing fields */
+ GetSamplePtr gsp;
+ ExistingTextPtr etp;
} OrgModLoadFormData, PNTR OrgModLoadFormPtr;
static void SetFormModsAcceptButton (Handle a)
@@ -10081,11 +10090,54 @@ static void CleanupOrgModLoadForm (
StdCleanupFormProc (g, data);
}
-static void AddOneQualToOrg (
- BioSourcePtr biop,
+static CharPtr genome_names[] =
+{
+ "",
+ "genomic",
+ "chloroplast",
+ "chromoplast",
+ "kinteoplast",
+ "mitochondrion",
+ "plastid",
+ "macronuclear",
+ "extrachrom",
+ "plasmid",
+ "transposon",
+ "insertion_seq",
+ "cyanelle",
+ "proviral",
+ "virion",
+ "nucleomorph",
+ "apicoplast",
+ "leucoplast",
+ "proplastid",
+ "endogenous_virus",
+};
+
+static Uint1 GetGenomeValFromString (CharPtr value_string)
+{
+ Uint1 genome_val;
+
+ if (StringHasNoText (value_string))
+ {
+ return 0;
+ }
+ for (genome_val = 1; genome_val < sizeof (genome_names); genome_val++)
+ {
+ if (StringICmp (value_string, genome_names[genome_val]) == 0)
+ {
+ return genome_val;
+ }
+ }
+ return 0;
+}
+
+
+static void AddOneQualToOrg
+( BioSourcePtr biop,
CharPtr value_string,
- Int4 modifier_index
-)
+ Int4 modifier_index,
+ ExistingTextPtr etp)
{
OrgRefPtr orp;
OrgModPtr mod, last_mod;
@@ -10115,8 +10167,9 @@ static void AddOneQualToOrg (
}
if (mod != NULL)
{
- MemFree (mod->subname);
- mod->subname = StringSave (value_string);
+ mod->subname = HandleExistingText (mod->subname,
+ StringSave (value_string),
+ etp);
}
else
{
@@ -10142,8 +10195,9 @@ static void AddOneQualToOrg (
}
if (ssp != NULL)
{
- MemFree (ssp->name);
- ssp->name = StringSave (value_string);
+ ssp->name = HandleExistingText (ssp->name,
+ StringSave (value_string),
+ etp);
}
else
{
@@ -10162,7 +10216,7 @@ static void AddOneQualToOrg (
}
}
-static void ApplyTaxNameToOrg (BioSourcePtr biop, CharPtr value_string)
+static void ApplyTaxNameToOrg (BioSourcePtr biop, CharPtr value_string, ExistingTextPtr etp)
{
if (biop == NULL) return;
if (biop->org == NULL)
@@ -10170,52 +10224,9 @@ static void ApplyTaxNameToOrg (BioSourcePtr biop, CharPtr value_string)
biop->org = OrgRefNew ();
}
if (biop->org == NULL) return;
- if (biop->org->taxname != NULL)
- {
- biop->org->taxname = MemFree (biop->org->taxname);
- }
- biop->org->taxname = StringSave (value_string);
-}
-
-static Uint1 GetGenomeValFromString (CharPtr value_string)
-{
- static CharPtr genome_names[] =
- {
- "",
- "genomic",
- "chloroplast",
- "chromoplast",
- "kinteoplast",
- "mitochondrion",
- "plastid",
- "macronuclear",
- "extrachrom",
- "plasmid",
- "transposon",
- "insertion_seq",
- "cyanelle",
- "proviral",
- "virion",
- "nucleomorph",
- "apicoplast",
- "leucoplast",
- "proplastid",
- "endogenous_virus",
- };
- Uint1 genome_val;
-
- if (StringHasNoText (value_string))
- {
- return 0;
- }
- for (genome_val = 1; genome_val < sizeof (genome_names); genome_val++)
- {
- if (StringICmp (value_string, genome_names[genome_val]) == 0)
- {
- return genome_val;
- }
- }
- return 0;
+ biop->org->taxname = HandleExistingText (biop->org->taxname,
+ StringSave (value_string),
+ etp);
}
static void ApplyLocationToOrg (BioSourcePtr biop, CharPtr value_string)
@@ -10252,11 +10263,12 @@ static void ApplyQualsToOrg (
if (apply_choice < NumDefLineModifiers + 1)
{
AddOneQualToOrg (biop, part->data.ptrvalue,
- GetValue (form_data->line_forms[column_index].apply_choice) - 1);
+ GetValue (form_data->line_forms[column_index].apply_choice) - 1,
+ form_data->etp);
}
else if (apply_choice == NumDefLineModifiers + 1)
{
- ApplyTaxNameToOrg (biop, part->data.ptrvalue);
+ ApplyTaxNameToOrg (biop, part->data.ptrvalue, form_data->etp);
}
else if (apply_choice == NumDefLineModifiers + 2)
{
@@ -10539,6 +10551,295 @@ static void ApplyTableModsByBankitID (BioseqPtr bsp, Pointer userdata)
}
}
+/* This code is used to detect existing modifiers before a change is made */
+static void FindOneQualOnOrg
+( BioSourcePtr biop,
+ Int4 modifier_index,
+ GetSamplePtr gsp)
+{
+ OrgModPtr mod;
+ SubSourcePtr ssp;
+
+ if (biop == NULL || gsp == NULL) return;
+
+ if (DefLineModifiers[modifier_index].isOrgMod)
+ {
+ if (biop->org == NULL
+ || biop->org->orgname == NULL)
+ {
+ return;
+ }
+
+ mod = biop->org->orgname->mod;
+ while (mod != NULL
+ && mod->subtype != DefLineModifiers[modifier_index].subtype)
+ {
+ mod = mod->next;
+ }
+ if (mod != NULL)
+ {
+ gsp->num_found ++;
+ if (gsp->sample_text == NULL)
+ {
+ gsp->sample_text = StringSave (mod->subname);
+ }
+ else if (StringCmp (gsp->sample_text, mod->subname) != 0)
+ {
+ gsp->all_same = FALSE;
+ }
+ }
+ }
+ else
+ {
+ ssp = biop->subtype;
+ while (ssp != NULL && ssp->subtype != DefLineModifiers[modifier_index].subtype)
+ {
+ ssp = ssp->next;
+ }
+ if (ssp != NULL)
+ {
+ gsp->num_found ++;
+ if (gsp->sample_text == NULL)
+ {
+ gsp->sample_text = StringSave (ssp->name);
+ }
+ else if (StringCmp (gsp->sample_text, ssp->name) != 0)
+ {
+ gsp->all_same = FALSE;
+ }
+ }
+ }
+}
+
+static void FindQualsOnOrg
+( BioSourcePtr biop,
+ ValNodePtr parts,
+ OrgModLoadFormPtr form_data)
+{
+ Int4 column_index;
+ ValNodePtr part;
+ Int4 apply_choice;
+
+ if (biop == NULL || parts == NULL
+ || form_data == NULL || form_data->gsp == NULL) return;
+
+ part = parts;
+ for (column_index = 0;
+ column_index < form_data->num_line_forms && part != NULL;
+ column_index ++)
+ {
+ apply_choice = GetValue (form_data->line_forms[column_index].apply_choice);
+ if (GetValue (form_data->line_forms[column_index].action_choice) == 2
+ && apply_choice > 0)
+ {
+ if (form_data->replace_with_blank || ! StringHasNoText (part->data.ptrvalue))
+ {
+ if (apply_choice < NumDefLineModifiers + 1)
+ {
+ FindOneQualOnOrg (biop,
+ GetValue (form_data->line_forms[column_index].apply_choice) - 1,
+ form_data->gsp);
+ }
+ else if (apply_choice == NumDefLineModifiers + 1)
+ {
+ if (biop->org != NULL && !StringHasNoText (biop->org->taxname))
+ {
+ form_data->gsp->num_found ++;
+ if (form_data->gsp->sample_text == NULL)
+ {
+ form_data->gsp->sample_text = StringSave (biop->org->taxname);
+ }
+ else if (StringCmp (form_data->gsp->sample_text, biop->org->taxname) != 0)
+ {
+ form_data->gsp->all_same = FALSE;
+ }
+ }
+ }
+ else if (apply_choice == NumDefLineModifiers + 2)
+ {
+ if (biop->genome > 0)
+ {
+ form_data->gsp->num_found ++;
+ if (form_data->gsp->sample_text == NULL)
+ {
+ form_data->gsp->sample_text = StringSave (genome_names [biop->genome]);
+ }
+ else if (StringCmp (form_data->gsp->sample_text, genome_names [biop->genome]) != 0)
+ {
+ form_data->gsp->all_same = FALSE;
+ }
+ }
+ }
+ }
+ }
+ part = part->next;
+ }
+}
+
+static void FindTableModsByTaxName (BioSourcePtr biop, Pointer userdata)
+{
+ OrgModLoadFormPtr form_data;
+ Int4 column_index, part_index;
+ ValNodePtr line, part;
+ TableLinePtr tlp;
+ Boolean found_org;
+
+ form_data = (OrgModLoadFormPtr) userdata;
+ if (form_data == NULL || form_data->gsp == NULL) return;
+ if (biop == NULL) return;
+ if (biop->org == NULL) return;
+ if (biop->org->taxname == NULL) return;
+
+ for (column_index = 0;
+ column_index < form_data->num_line_forms;
+ column_index ++)
+ {
+ if (GetValue (form_data->line_forms[column_index].action_choice) == 1
+ && GetValue (form_data->line_forms[column_index].match_choice) == 3)
+ {
+ for (line = form_data->line_list; line != NULL; line = line->next)
+ {
+ tlp = line->data.ptrvalue;
+ if (tlp == NULL) continue;
+ part = tlp->parts;
+ for (part_index = 0;
+ part_index < column_index && part != NULL;
+ part_index ++)
+ {
+ part = part->next;
+ }
+ if (part != NULL
+ && StringCmp (part->data.ptrvalue, biop->org->taxname) == 0)
+ {
+ FindQualsOnOrg (biop, tlp->parts, form_data);
+ found_org = TRUE;
+ }
+ }
+ }
+ }
+}
+
+static void FindTableModsByAccessionNumber (BioseqPtr bsp, Pointer userdata)
+{
+ OrgModLoadFormPtr form_data;
+ SeqDescrPtr sdp;
+ GBBlockPtr gbp;
+ Int4 column_index, part_index;
+ BioSourcePtr biop;
+ ValNodePtr line, part;
+ TableLinePtr tlp;
+ Boolean use_local_id;
+ Boolean look_for_tmsmart;
+ Int4 match_choice;
+
+ form_data = (OrgModLoadFormPtr) userdata;
+ if (form_data == NULL || bsp == NULL) return;
+
+ biop = GetBiopForBsp (bsp);
+ if (biop == NULL) return;
+
+ gbp = NULL;
+ sdp = BioseqGetSeqDescr (bsp, Seq_descr_genbank, NULL);
+ if (sdp != NULL)
+ {
+ gbp = sdp->data.ptrvalue;
+ }
+
+ for (column_index = 0;
+ column_index < form_data->num_line_forms;
+ column_index ++)
+ {
+ match_choice = GetValue (form_data->line_forms[column_index].match_choice);
+ if (GetValue (form_data->line_forms[column_index].action_choice) == 1
+ && (match_choice == 1 || match_choice == 2 || match_choice == 4))
+ {
+ if (match_choice == 1 || match_choice == 4) {
+ use_local_id = FALSE;
+ } else {
+ use_local_id = TRUE;
+ }
+ if (match_choice == 4) {
+ look_for_tmsmart = TRUE;
+ } else {
+ look_for_tmsmart = FALSE;
+ }
+
+ for (line = form_data->line_list; line != NULL; line = line->next)
+ {
+ tlp = line->data.ptrvalue;
+ if (tlp == NULL) continue;
+ part = tlp->parts;
+ for (part_index = 0;
+ part_index < column_index && part != NULL;
+ part_index ++)
+ {
+ part = part->next;
+ }
+ if (part != NULL
+ && ( IDListHasValue ( part->data.ptrvalue,
+ bsp->id, use_local_id, look_for_tmsmart)
+ || (! use_local_id &&
+ HasExtraAccession ( part->data.ptrvalue, gbp))))
+ {
+ FindQualsOnOrg (biop, tlp->parts, form_data);
+ }
+ }
+ }
+ }
+}
+
+static void FindTableModsByBankitID (BioseqPtr bsp, Pointer userdata)
+{
+ OrgModLoadFormPtr form_data;
+ ObjectIdPtr oip;
+ SeqIdPtr sip;
+ DbtagPtr dp;
+ Char match_str [30];
+ Int4 column_index, part_index;
+ BioSourcePtr biop;
+ ValNodePtr line, part;
+ TableLinePtr tlp;
+ Int4 match_choice;
+
+ form_data = (OrgModLoadFormPtr) userdata;
+ if (form_data == NULL || bsp == NULL) return;
+
+ biop = GetBiopForBsp (bsp);
+ if (biop == NULL) return;
+
+ match_str [0] = 0;
+ for(sip = bsp->id; sip != NULL; sip = sip->next) {
+ if(sip->choice == SEQID_GENERAL) {
+ dp = (DbtagPtr) sip->data.ptrvalue;
+ if(StringICmp(dp->db, "BankIt") == 0) {
+ oip = dp->tag;
+ sprintf (match_str, "bankit%d", oip->id);
+ break;
+ }
+ }
+ }
+ if (match_str [0] == 0) return;
+
+ for (column_index = 0;
+ column_index < form_data->num_line_forms;
+ column_index ++)
+ {
+ match_choice = GetValue (form_data->line_forms[column_index].match_choice);
+ if (GetValue (form_data->line_forms[column_index].action_choice) == 1 && match_choice == 5) {
+ for (line = form_data->line_list; line != NULL; line = line->next) {
+ tlp = line->data.ptrvalue;
+ if (tlp == NULL) continue;
+ part = tlp->parts;
+ for (part_index = 0; part_index < column_index && part != NULL; part_index ++) {
+ part = part->next;
+ }
+ if (part != NULL && StringCmp (part->data.ptrvalue, match_str) == 0) {
+ FindQualsOnOrg (biop, tlp->parts, form_data);
+ }
+ }
+ }
+ }
+}
static void DoAcceptFormMods (ButtoN b)
{
@@ -10553,9 +10854,17 @@ static void DoAcceptFormMods (ButtoN b)
sep = GetTopSeqEntryForEntityID (form_data->entityID);
if (sep == NULL) return;
+ form_data->gsp = GetSampleNew ();
+ VisitBioSourcesInSep (sep, form_data, FindTableModsByTaxName);
+ VisitBioseqsInSep (sep, form_data, FindTableModsByAccessionNumber);
+ VisitBioseqsInSep (sep, form_data, FindTableModsByBankitID);
+ form_data->etp = GetExistingTextHandlerInfo (form_data->gsp, FALSE);
+ form_data->gsp = GetSampleFree (form_data->gsp);
+
VisitBioSourcesInSep (sep, form_data, ApplyTableModsByTaxName);
VisitBioseqsInSep (sep, form_data, ApplyTableModsByAccessionNumber);
VisitBioseqsInSep (sep, form_data, ApplyTableModsByBankitID);
+ form_data->etp = MemFree (form_data->etp);
Update ();
ObjMgrSetDirtyFlag (form_data->entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, form_data->entityID, 0, 0);
diff --git a/sequin/sequin2.c b/sequin/sequin2.c
index a1ff4f10..3850cc57 100644
--- a/sequin/sequin2.c
+++ b/sequin/sequin2.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.377 $
+* $Revision: 6.402 $
*
* File Description:
*
@@ -69,6 +69,7 @@
#include <netscape.h>
#endif
#include <actutils.h>
+#include <salpanel.h>
extern EnumFieldAssoc orgmod_subtype_alist [];
extern EnumFieldAssoc subsource_subtype_alist [];
@@ -117,18 +118,6 @@ static Boolean PackageTypeIsSingle (Int2 seqPackage)
}
}
-static Boolean PackageTypeDefaultMolTypeIsDNA (Int2 seqPackage)
-{
- if (PackageTypeIsSet (seqPackage) || seqPackage == SEQ_PKG_GENOMICCDNA)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
-}
-
/* These functions are used to find titles in SeqEntries */
static void FindFirstTitle (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 indent)
@@ -500,7 +489,7 @@ static CharPtr GetModValueFromSeqEntry (SeqEntryPtr sep, CharPtr mod_name)
if (!LookForSearchString (ttl, lookfor, value, value_len - 1))
{
- if (StringICmp (mod_name, "organism"))
+ if (StringICmp (mod_name, "organism") == 0)
{
MakeSearchStringFromAlist (lookfor, "org");
if (!LookForSearchString (ttl, lookfor, value, value_len - 1))
@@ -508,7 +497,7 @@ static CharPtr GetModValueFromSeqEntry (SeqEntryPtr sep, CharPtr mod_name)
value = MemFree (value);
}
}
- else if (StringICmp (mod_name, "org"))
+ else if (StringICmp (mod_name, "org") == 0)
{
MakeSearchStringFromAlist (lookfor, "organism");
if (!LookForSearchString (ttl, lookfor, value, value_len - 1))
@@ -536,6 +525,37 @@ return to the Sequence Format form and choose the proper submission type.\n\n";
#define FastaFormatBufLen 1000
+static Int4 CountSegSetSegments (SeqEntryPtr sep)
+{
+ BioseqSetPtr bssp;
+
+ if (sep == NULL || sep->data.ptrvalue == NULL || ! IS_Bioseq_set (sep))
+ {
+ return 0;
+ }
+
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp->_class != BioseqseqSet_class_segset)
+ {
+ return 0;
+ }
+ sep = bssp->seq_set;
+
+ while (sep != NULL)
+ {
+ if (IS_Bioseq_set (sep) && sep->data.ptrvalue != NULL)
+ {
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp->_class == BioseqseqSet_class_parts)
+ {
+ return ValNodeLen (bssp->seq_set);
+ }
+ }
+ sep = sep->next;
+ }
+ return 0;
+}
+
static void FormatFastaDoc (FastaPagePtr fpp)
{
@@ -557,6 +577,7 @@ static void FormatFastaDoc (FastaPagePtr fpp)
CharPtr ttl;
CharPtr tmp;
ValNodePtr vnp;
+ Int4 num_seg;
if (fpp != NULL) {
str = MemNew (sizeof (char) * FastaFormatBufLen);
@@ -595,7 +616,7 @@ static void FormatFastaDoc (FastaPagePtr fpp)
label = "Message";
measure = "nucleotides";
} else if (fpp->is_na) {
- label = "Segment";
+ label = "Sequence";
measure = "nucleotides";
} else {
label = "Sequence";
@@ -605,7 +626,7 @@ static void FormatFastaDoc (FastaPagePtr fpp)
sprintf (str, "%d transcript sequence%s, total length %ld %s\n",
(int) num, plural, (long) len, measure);
} else if (fpp->is_na) {
- sprintf (str, "%d nucleotide segment%s, total length %ld %s\n",
+ sprintf (str, "%d nucleotide sequence%s, total length %ld %s\n",
(int) num, plural, (long) len, measure);
} else {
sprintf (str, "%d protein sequence%s, total length %ld %s\n",
@@ -619,6 +640,7 @@ static void FormatFastaDoc (FastaPagePtr fpp)
for (sep = fpp->list; sep != NULL; sep = sep->next) {
num++;
len = 0;
+ num_seg = CountSegSetSegments (sep);
sip = NULL;
tmp [0] = '\0';
if (IS_Bioseq (sep)) {
@@ -628,6 +650,7 @@ static void FormatFastaDoc (FastaPagePtr fpp)
sip = SeqIdFindWorst (bsp->id);
SeqIdWrite (sip, tmp, PRINTID_REPORT, FastaFormatBufLen);
}
+ nsep = sep;
} else if (IS_Bioseq_set (sep)) {
nsep = FindNucSeqEntry (sep);
if (nsep != NULL && IS_Bioseq (nsep)) {
@@ -639,10 +662,20 @@ static void FormatFastaDoc (FastaPagePtr fpp)
}
}
}
- sprintf (str, "\n%s %d\nLength: %ld %s\nSequence ID: %s\n", label,
- (int) num, (long) len, measure, tmp);
+
+ /* if segmented set, show number of segments */
+ if (num_seg > 0)
+ {
+ sprintf (str, "\nSegset %d\nLength: %ld %s (%d segments)\nSequence ID: %s\n",
+ (int) num, (long) len, measure, num_seg, tmp);
+ }
+ else
+ {
+ sprintf (str, "\n%s %d\nLength: %ld %s\nSequence ID: %s\n", label,
+ (int) num, (long) len, measure, tmp);
+ }
ttl = NULL;
- SeqEntryExplore (sep, (Pointer) (&ttl), FindFirstTitle);
+ SeqEntryExplore (nsep, (Pointer) (&ttl), FindFirstTitle);
title = StringSaveNoNull (ttl);
if (title != NULL && (! fpp->is_na)) {
if (LookForSearchString (title, "[gene=", tmp, FastaFormatBufLen - 1)) {
@@ -732,7 +765,7 @@ static void FormatFastaDoc (FastaPagePtr fpp)
}
MemFree (title);
ttl = NULL;
- SeqEntryExplore (sep, (Pointer) (&ttl), FindFirstTitle);
+ SeqEntryExplore (nsep, (Pointer) (&ttl), FindFirstTitle);
title = StringSaveNoNull (ttl);
if (title != NULL) {
if (! fpp->is_na) {
@@ -962,7 +995,7 @@ static SeqEntryPtr ReadOneSegSet (FILE *fp, Boolean parse_id, ValNodePtr PNTR er
ValNodeAddPointer (err_msg_list, 0, errormsg);
errormsg = NULL;
}
- nextsep = SequinFastaToSeqEntryEx (fp, FALSE, &errormsg, FALSE, &lastchar);
+ nextsep = SequinFastaToSeqEntryEx (fp, TRUE, &errormsg, FALSE, &lastchar);
}
nextsep = SegsetFromSeqEntryList (seg_list);
return nextsep;
@@ -978,14 +1011,7 @@ static void AddDefaultMoleculeTypeAndLocation (SeqEntryPtr seq_list, Int2 seqPac
old_value = GetModValueFromSeqEntry (sep, "moltype");
if (StringHasNoText (old_value))
{
- if (PackageTypeIsSet (seqPackage) || seqPackage == SEQ_PKG_GENOMICCDNA)
- {
- ApplyOneModToSeqEntry (sep, "moltype", "dna");
- }
- else
- {
- ApplyOneModToSeqEntry (sep, "moltype", "rna");
- }
+ ApplyOneModToSeqEntry (sep, "moltype", "dna");
}
old_value = MemFree (old_value);
old_value = GetModValueFromSeqEntry (sep, "location");
@@ -994,6 +1020,13 @@ static void AddDefaultMoleculeTypeAndLocation (SeqEntryPtr seq_list, Int2 seqPac
ApplyOneModToSeqEntry (sep, "location", "genomic");
}
old_value = MemFree (old_value);
+
+ old_value = GetModValueFromSeqEntry (sep, "topology");
+ if (StringHasNoText (old_value))
+ {
+ ApplyOneModToSeqEntry (sep, "topology", "Linear");
+ }
+ old_value = MemFree (old_value);
}
}
@@ -1116,6 +1149,7 @@ ImportSequencesFromFile
last->next = new_sep_list;
}
+
return sep_list;
}
@@ -1388,10 +1422,77 @@ static Boolean RejectExtraSequences (SeqEntryPtr new_list, FastaPagePtr fpp)
}
}
+static void ShowImportHelp (ButtoN b)
+{
+ CharPtr help_msg;
+
+ help_msg = (CharPtr) GetObjectExtra (b);
+ if (help_msg == NULL)
+ {
+ return;
+ }
+
+ Message (MSG_OK, help_msg);
+}
+
+static Boolean OkToImport (CharPtr msg, CharPtr help_msg)
+{
+ WindoW w;
+ GrouP h, c;
+ PrompT p;
+ ButtoN b;
+ ModalAcceptCancelData acd;
+
+ if (msg == NULL)
+ {
+ return TRUE;
+ }
+ acd.accepted = FALSE;
+ acd.cancelled = FALSE;
+
+ w = ModalWindow(-20, -13, -10, -10, NULL);
+ h = HiddenGroup (w, -1, 0, NULL);
+
+ p = StaticPrompt (h, msg, 0, 0, programFont, 'l');
+ c = HiddenGroup (h, 3, 0, NULL);
+ b = PushButton (c, "Yes", ModalAcceptButton);
+ SetObjectExtra (b, &acd, NULL);
+ b = PushButton (c, "No", ModalCancelButton);
+ SetObjectExtra (b, &acd, NULL);
+ if (help_msg != NULL)
+ {
+ b = PushButton (c, "Help", ShowImportHelp);
+ SetObjectExtra (b, help_msg, NULL);
+ }
+ AlignObjects (ALIGN_CENTER, (HANDLE) p, (HANDLE) c, NULL);
+
+ Show(w);
+ Select (w);
+ while (!acd.accepted && ! acd.cancelled)
+ {
+ ProcessExternalEvent ();
+ Update ();
+ }
+ ProcessAnEvent ();
+ Remove (w);
+ if (acd.accepted)
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+static CharPtr segset_import_help_str = "Segmented sequence: a collection of non-overlapping, non-contiguous sequences that cover a specified genetic region. A standard example is a set of genomic DNA sequences that encode exons from a gene along with fragments of their flanking introns.";
+static CharPtr gapped_import_help_str = "Gapped sequence: a sequence with one or more gaps of known or unknown length.";
+
+
static Boolean ImportedSequenceTypeOk (SeqEntryPtr list, Int2 seqPackage)
{
BioseqPtr bsp;
- MsgAnswer ans = ANS_YES;
+ Boolean rval = TRUE;
if (list == NULL || seqPackage != SEQ_PKG_SINGLE)
{
@@ -1402,21 +1503,18 @@ static Boolean ImportedSequenceTypeOk (SeqEntryPtr list, Int2 seqPackage)
bsp = (BioseqPtr) list->data.ptrvalue;
if (bsp != NULL && bsp->repr == Seq_repr_delta)
{
- ans = Message (MSG_YN, "You have imported a gapped (delta) sequence. Did you mean to do that?");
+ SendHelpScrollMessage (helpForm, "Sequence Format Form", NULL);
+ rval = OkToImport ("You have imported a gapped sequence. Did you mean to do that?",
+ gapped_import_help_str);
}
}
else if (list->choice == 2)
{
- ans = Message (MSG_YN, "You have imported a segmented sequence. Did you mean to do that?");
- }
- if (ans == ANS_YES)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
+ SendHelpScrollMessage (helpForm, "Sequence Format Form", NULL);
+ rval = OkToImport ("You have imported a segmented sequence. Did you mean to do that?",
+ segset_import_help_str);
}
+ return rval;
}
static Boolean ImportFastaDialog (DialoG d, CharPtr filename)
@@ -1783,6 +1881,7 @@ static void FormatPhylipDoc (PhylipPagePtr ppp)
if (bssp != NULL && (bssp->_class == 7 ||
(IsPopPhyEtcSet (bssp->_class)))) {
for (sep = bssp->seq_set; sep != NULL; sep = sep->next) {
+ nsep = NULL;
num++;
len = 0;
sip = NULL;
@@ -1808,7 +1907,7 @@ static void FormatPhylipDoc (PhylipPagePtr ppp)
sprintf (str, "\n%s %d\nLength: %ld %s\nSequence ID: %s\n", label,
(int) num, (long) len, measure, tmp);
ttl = NULL;
- SeqEntryExplore (sep, (Pointer) (&ttl), FindFirstTitle);
+ SeqEntryExplore (nsep, (Pointer) (&ttl), FindFirstTitle);
title = StringSaveNoNull (ttl);
if (title != NULL) {
if (LookForSearchString (title, "[org=", tmp, PhylipFormatBufLen - 1)) {
@@ -1850,7 +1949,7 @@ static void FormatPhylipDoc (PhylipPagePtr ppp)
}
MemFree (title);
ttl = NULL;
- SeqEntryExplore (sep, (Pointer) (&ttl), FindFirstTitle);
+ SeqEntryExplore (nsep, (Pointer) (&ttl), FindFirstTitle);
title = StringSaveNoNull (ttl);
if (title != NULL) {
ExciseString (title, "[org=", "]");
@@ -5198,6 +5297,7 @@ static Pointer FastaSequencesFormToSeqEntryPtr (ForM f)
ObjectIdPtr oip;
UserFieldPtr ufp;
UserObjectPtr uop;
+ SeqEntryPtr oldscope;
sep = NULL;
sqfp = (SequencesFormPtr) GetObjectExtra (f);
@@ -5429,6 +5529,7 @@ static Pointer FastaSequencesFormToSeqEntryPtr (ForM f)
sqfp->seqPackage != SEQ_PKG_GENOMICCDNA) {
annotType = GetValue (sqfp->annotType);
if (annotType > 0) {
+ oldscope = SeqEntrySetScope (sep);
switch (annotType) {
case 1 :
ApplyAnnotationToAll (ADD_IMP, sep, sqfp->partialLft, sqfp->partialRgt,
@@ -5457,6 +5558,7 @@ static Pointer FastaSequencesFormToSeqEntryPtr (ForM f)
default :
break;
}
+ SeqEntrySetScope (oldscope);
}
}
ArrowCursor ();
@@ -5823,10 +5925,35 @@ static void ReplaceMolNamesWithMolBracketsInDefinitionLines (SeqEntryPtr sep);
static Boolean CheckSequencesForOrganisms (SequencesFormPtr sqfp);
static void SequencesFormDeleteProc (Pointer formDataPtr);
+static void SetDefaultMolTypesAndTopologies (SeqEntryPtr seq_list)
+{
+ SeqEntryPtr sep, nsep;
+ CharPtr ttl = NULL;
+ Char tmp[128];
+
+ for (sep = seq_list; sep != NULL; sep = sep->next)
+ {
+ nsep = FindNucSeqEntry (sep);
+ ttl = NULL;
+ SeqEntryExplore (nsep, (Pointer) (&ttl), FindFirstTitle);
+
+ if (!LookForSearchString (ttl, "[moltype=", tmp, sizeof (tmp) - 1))
+ {
+ ApplyOneModToSeqEntry (nsep, "moltype", "Genomic DNA");
+ }
+ ttl = NULL;
+ SeqEntryExplore (nsep, (Pointer) (&ttl), FindFirstTitle);
+ if (!LookForSearchString (ttl, "[topology=", tmp, sizeof (tmp) - 1))
+ {
+ ApplyOneModToSeqEntry (nsep, "topology", "Linear");
+ }
+ }
+}
+
static void NucleotideImportFinish (SequencesFormPtr sqfp)
{
- FastaPagePtr fpp;
- PhylipPagePtr ppp;
+ FastaPagePtr fpp = NULL;
+ PhylipPagePtr ppp = NULL;
SeqEntryPtr sep = NULL;
ValNodePtr fixes = NULL;
Boolean cancelled = FALSE;
@@ -5859,6 +5986,15 @@ static void NucleotideImportFinish (SequencesFormPtr sqfp)
FixDefinitionLines (sep, &cancelled, &fixes);
fixes = FreeStringPairList (fixes);
+
+ SetDefaultMolTypesAndTopologies (sep);
+
+ if (fpp != NULL)
+ {
+ Reset (fpp->doc);
+ FormatFastaDoc (fpp);
+ }
+
if (cancelled)
{
SequencesFormDeleteProc (sqfp);
@@ -7822,69 +7958,6 @@ static SeqEntryPtr GetSeqEntryFromSequencesForm (SequencesFormPtr sqfp)
return list;
}
-static Boolean HasNoMoreThanOneOrganismName (SeqEntryPtr seq_list, CharPtr PNTR org_name)
-{
- SeqEntryPtr sep;
- CharPtr ttl;
- CharPtr title;
- Char text [128];
- Char last_org [128];
- Char lookfor [128];
- Char lookfor2 [128];
- Boolean found_org;
- Boolean found_diff_org = FALSE;
-
- MakeSearchStringFromAlist (lookfor, "Org");
- MakeSearchStringFromAlist (lookfor2, "Organism");
- last_org [0] = 0;
-
- for (sep = seq_list; sep != NULL && !found_diff_org; sep = sep->next)
- {
- ttl = NULL;
- found_org = TRUE;
- SeqEntryExplore (sep, (Pointer) (&ttl), FindFirstTitle);
- title = StringSaveNoNull (ttl);
- text [0] = '\0';
- if (! LookForSearchString (title, lookfor, text, sizeof (text) - 1))
- {
- if (! LookForSearchString (title, lookfor2, text, sizeof (text) - 1))
- {
- found_org = FALSE;
- }
- }
- if (found_org)
- {
- if (last_org [0] == 0)
- {
- StringCpy (last_org, text);
- }
- else if (StringCmp (last_org, text) != 0)
- {
- found_diff_org = TRUE;
- }
- }
- }
- if (found_diff_org)
- {
- return FALSE;
- }
- else
- {
- if (org_name != NULL)
- {
- if (last_org [0] == 0)
- {
- *org_name = 0;
- }
- else
- {
- *org_name = StringSave (last_org);
- }
- }
- return TRUE;
- }
-}
-
extern Boolean IsNonTextModifier (CharPtr mod_name)
{
@@ -7918,126 +7991,167 @@ static Int4 GetValForEnumName (EnumFieldAssocPtr eap, CharPtr mod_value)
return 0;
}
-static void AddSeqIDAndValueToTagList
-(CharPtr id,
- CharPtr title,
- CharPtr lookfor,
- CharPtr mod_name,
- Int2 seqPackage,
- ValNodePtr PNTR head,
- ValNodePtr PNTR found_modifiers)
+static CharPtr
+TagListStringFromDefLineValue
+(CharPtr defline_val,
+ Boolean is_nontext,
+ Int2 mod_type)
{
+ CharPtr taglist_str = NULL;
Char text [128];
- CharPtr str;
- Int4 len;
- Int4 mod_type;
- Boolean is_nontext;
-
- if (head == NULL)
- {
- return;
- }
-
- if (found_modifiers != NULL)
- {
- *found_modifiers = BuildModifierTypeList (*found_modifiers, title);
- }
- is_nontext = IsNonTextModifier (mod_name);
- mod_type = GetModifierType (mod_name);
-
- text [0] = '\0';
if (is_nontext)
{
- if (LookForSearchString (title, lookfor, text, sizeof (text) - 1))
+ if (StringHasNoText (defline_val))
{
- StringCpy (text, "1");
+ taglist_str = StringSave ("0");
}
else
{
- StringCpy (text, "0");
+ taglist_str = StringSave ("1");
}
}
else if (mod_type == eModifierType_Organism)
{
- if (! LookForSearchString (title, (CharPtr) short_org, text, sizeof (text) - 1))
- {
- if (! LookForSearchString (title, (CharPtr) long_org, text, sizeof (text) - 1))
- {
- StringCpy (text, " ");
- }
- }
+ taglist_str = StringSave (defline_val);
}
else if (mod_type == eModifierType_Location)
{
- if (LookForSearchString (title, lookfor, text, sizeof (text) - 1))
+ if (StringHasNoText (defline_val))
{
- sprintf (text, "%d", GetValForEnumName (biosource_genome_simple_alist, text));
+ taglist_str = StringSave ("1");
}
else
{
- StringCpy (text, "1");
+ sprintf (text, "%d", GetValForEnumName (biosource_genome_simple_alist,
+ defline_val));
+ taglist_str = StringSave (text);
}
}
else if (mod_type == eModifierType_NucGeneticCode
|| mod_type == eModifierType_MitoGeneticCode)
{
- if (LookForSearchString (title, lookfor, text, sizeof (text) - 1))
+ if (StringHasNoText (defline_val))
{
- sprintf (text, "%d", GeneticCodeFromString (text));
+ taglist_str = StringSave ("0");
}
else
{
- StringCpy (text, "0");
+ sprintf (text, "%d", GeneticCodeFromString (defline_val));
+ taglist_str = StringSave (text);
}
}
else if (mod_type == eModifierType_MolType)
{
- if (LookForSearchString (title, lookfor, text, sizeof (text) - 1))
+ if (StringHasNoText (defline_val))
{
- sprintf (text, "%d", MolTypeFromString (text));
+ taglist_str = StringSave ("253");
}
else
{
- if (PackageTypeIsSet (seqPackage) || seqPackage == SEQ_PKG_GENOMICCDNA)
- {
- sprintf (text, "%d", 253);
- }
- else
- {
- sprintf (text, "%d", 254);
- }
+ sprintf (text, "%d", MolTypeFromString (defline_val));
+ taglist_str = StringSave (text);
}
}
else if (mod_type == eModifierType_Topology)
{
- if (LookForSearchString (title, lookfor, text, sizeof (text) - 1))
+ if (StringHasNoText (defline_val))
{
- sprintf (text, "%d", TopologyFromString (text));
+ sprintf (text, "%d", TopologyFromString (""));
}
else
{
- sprintf (text, "%d", TopologyFromString (""));
+ sprintf (text, "%d", TopologyFromString (defline_val));
}
+ taglist_str = StringSave (text);
}
else
{
- if (! LookForSearchString (title, lookfor, text, sizeof (text) - 1)) {
+ if (StringHasNoText (defline_val))
+ {
+ taglist_str = StringSave (" ");
+ }
+ else
+ {
+ taglist_str = StringSave (defline_val);
+ }
+ }
+ return taglist_str;
+}
+
+static void AddSeqIDAndValueToTagList
+(CharPtr id,
+ CharPtr title,
+ CharPtr lookfor,
+ CharPtr mod_name,
+ Int2 seqPackage,
+ ValNodePtr PNTR head,
+ ValNodePtr PNTR found_modifiers)
+{
+ Char text [128];
+ CharPtr str;
+ Int4 len;
+ Int4 mod_type;
+ Boolean is_nontext;
+ CharPtr taglist_str = NULL;
+
+ if (head == NULL)
+ {
+ return;
+ }
+
+ if (found_modifiers != NULL)
+ {
+ *found_modifiers = BuildModifierTypeList (*found_modifiers, title);
+ }
+
+ is_nontext = IsNonTextModifier (mod_name);
+ mod_type = GetModifierType (mod_name);
+
+ text [0] = '\0';
+
+ if (is_nontext)
+ {
+ if (LookForSearchString (title, lookfor, text, sizeof (text) - 1))
+ {
+ sprintf (text, "2");
+ }
+ else
+ {
+ text [0] = '\0';
+ }
+ }
+ else if (mod_type == eModifierType_Organism)
+ {
+ if (! LookForSearchString (title, (CharPtr) short_org, text, sizeof (text) - 1))
+ {
+ if (! LookForSearchString (title, (CharPtr) long_org, text, sizeof (text) - 1))
+ {
+ StringCpy (text, " ");
+ }
+ }
+ }
+ else
+ {
+ if (!LookForSearchString (title, lookfor, text, sizeof (text) - 1))
+ {
StringCpy (text, " ");
}
}
- len = StringLen (id) + StringLen (text);
+
+ taglist_str = TagListStringFromDefLineValue (text, is_nontext, mod_type);
+ len = StringLen (id) + StringLen (taglist_str);
str = MemNew (len + 4);
if (str != NULL) {
StringCpy (str, id);
StringCat (str, "\t");
- StringCat (str, text);
+ StringCat (str, taglist_str);
StringCat (str, "\n");
}
+ taglist_str = MemFree (taglist_str);
ValNodeAddPointer (head, 0, str);
-
}
static void AddSeqIDAndValueFromSeqEntryToTagList
@@ -8224,6 +8338,92 @@ static Boolean HasAnySourceInformation (ValNodePtr header_list, ValNodePtr colum
return has_any;
}
+static Boolean OrganismMatchesAnotherRow (Int4 row, ValNodePtr row_list, Pointer userdata)
+{
+ ValNodePtr header_vnp, column_list, check_column_list, row_vnp;
+ Int4 row_num;
+
+ if (row_list == NULL || row < 1)
+ {
+ return FALSE;
+ }
+
+ /* we start with the header of the second column, because the first column
+ * is the sequence ID */
+ header_vnp = row_list->data.ptrvalue;
+ if (header_vnp == NULL) return FALSE;
+ header_vnp = header_vnp->next;
+ if (header_vnp == NULL) return FALSE;
+
+ /* find the row we're interested in */
+ for (row_vnp = row_list->next, row_num = 1;
+ row_vnp != NULL && row_num != row;
+ row_vnp = row_vnp->next, row_num++)
+ {
+ }
+ if (row_vnp == NULL)
+ {
+ return FALSE;
+ }
+
+ column_list = (ValNodePtr) row_vnp->data.ptrvalue;
+ if (!HasAnySourceInformation (row_list->data.ptrvalue, column_list))
+ {
+ return FALSE;
+ }
+
+ if (column_list == NULL || column_list->next == NULL)
+ {
+ return FALSE;
+ }
+
+ /* now check it against the other rows */
+ for (row_vnp = row_list->next, row_num = 1;
+ row_vnp != NULL;
+ row_vnp = row_vnp->next, row_num++)
+ {
+ if (row_num == row)
+ {
+ continue;
+ }
+
+ check_column_list = (ValNodePtr) row_vnp->data.ptrvalue;
+ if (check_column_list == NULL || check_column_list->next == NULL)
+ {
+ continue;
+ }
+
+ /* we compare the column lists, starting with the second column
+ * because the first column contains the sequence ID
+ */
+ if (DoColumnlistsHaveIdenticalSourceInformation (column_list->next,
+ check_column_list->next,
+ header_vnp))
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static Boolean AnySequencesHaveIdenticalOrganisms (ValNodePtr row_list)
+{
+ Int4 i, num_rows;
+ Boolean have_match = FALSE;
+
+ if (row_list == NULL || row_list->next == NULL)
+ {
+ return FALSE;
+ }
+ num_rows = ValNodeLen (row_list);
+
+ for (i = 1; i < num_rows && ! have_match; i++)
+ {
+ have_match = OrganismMatchesAnotherRow (i, row_list, NULL);
+ }
+ return have_match;
+}
+
static void ReportIdenticalOrganisms (ValNodePtr row_list, DoC doc)
{
ValNodePtr checked_list = NULL;
@@ -8320,7 +8520,7 @@ static void ReportIdenticalOrganisms (ValNodePtr row_list, DoC doc)
}
}
-static void SummarizeModifiers (ValNodePtr row_list, DoC summary_doc)
+static void SummarizeModifiers (ValNodePtr row_list, DialoG summary_dlg)
{
ValNodePtr header_vnp, row_vnp, column_vnp;
Int4 column_offset, col_pos;
@@ -8330,16 +8530,25 @@ static void SummarizeModifiers (ValNodePtr row_list, DoC summary_doc)
CharPtr first_value_seen;
Boolean all_unique;
ValNodePtr values_seen;
- CharPtr status;
+ CharPtr row_status;
Int4 line_len;
CharPtr modifier_line = NULL;
Int4 num_missing;
+ ValNodePtr summary_row_list = NULL;
+ ValNodePtr summary_col_list = NULL, summary_header_list = NULL;
- if (row_list == NULL || row_list->next == NULL || summary_doc == NULL)
+ if (row_list == NULL || row_list->next == NULL || summary_dlg == NULL)
{
return;
}
+ summary_col_list = NULL;
+ ValNodeAddPointer (&summary_col_list, 8, StringSave ("Modifier"));
+ ValNodeAddPointer (&summary_col_list, 6, StringSave ("Status"));
+ ValNodeAddPointer (&summary_col_list, 11, StringSave ("First Value"));
+ ValNodeAddPointer (&summary_row_list, 0, summary_col_list);
+ summary_header_list = summary_col_list;
+
header_vnp = row_list->data.ptrvalue;
/* skip over sequence ID column */
header_vnp = header_vnp->next;
@@ -8404,57 +8613,85 @@ static void SummarizeModifiers (ValNodePtr row_list, DoC summary_doc)
/* add summary line for this modifier */
if (! any_present)
{
- status = "%s: All missing (%d sequences). ";
+ row_status = "All missing (%d sequences)";
}
else if (all_present && all_unique)
{
- status = "%s: All present, all unique values. ";
+ row_status = "All present, all unique values";
}
else if (all_present && is_unique)
{
- status = "%s: All present, one unique value. ";
+ row_status = "All present, one unique value";
}
else if (all_present && ! is_unique)
{
- status = "%s: All present, mixed values. ";
+ row_status = "All present, mixed values";
}
else if (! all_present && all_unique)
{
- status = "%s: %d missing, all unique values. ";
+ row_status = "%d missing, all unique values";
}
else if (! all_present && is_unique)
{
- status = "%s: %d missing, one unique value present. ";
+ row_status = "%d missing, one unique value present";
}
else if (! all_present && ! is_unique)
{
- status = "%s: %d missing, mixed values. ";
+ row_status = "%d missing, mixed values";
}
- line_len = StringLen (header_vnp->data.ptrvalue)
- + StringLen (status)
- + StringLen (first_value_seen)
- + 30;
+ line_len = StringLen (row_status) + 30;
modifier_line = (CharPtr) MemNew (line_len * sizeof (Char));
if (modifier_line != NULL)
{
+
+ /* add summary row for this modifier */
+ summary_col_list = NULL;
+ /* add modifier name */
+ ValNodeAddPointer (&summary_col_list,
+ 0,
+ StringSave (header_vnp->data.ptrvalue));
+ /* show up to the first fifteen characters of the modifier name */
+ summary_header_list->choice = MAX (summary_header_list->choice,
+ StringLen (header_vnp->data.ptrvalue));
+ summary_header_list->choice = MIN (summary_header_list->choice,
+ 15);
+
+ /* add status */
if (all_present)
{
- sprintf (modifier_line, status, header_vnp->data.ptrvalue);
+ ValNodeAddPointer (&summary_col_list,
+ 0,
+ StringSave (row_status));
+ summary_header_list->next->choice = MAX (summary_header_list->next->choice,
+ StringLen (row_status));
}
else
{
- sprintf (modifier_line, status, header_vnp->data.ptrvalue, num_missing);
+ sprintf (modifier_line, row_status, num_missing);
+ ValNodeAddPointer (&summary_col_list,
+ 0,
+ StringSave (modifier_line));
+ summary_header_list->next->choice = MAX (summary_header_list->next->choice,
+ StringLen (modifier_line));
}
- if (!StringHasNoText (first_value_seen))
+ /* add sample value */
+ if (StringHasNoText (first_value_seen))
+ {
+ ValNodeAddPointer (&summary_col_list, 0, StringSave (""));
+ }
+ else
{
- StringCat (modifier_line, "(");
- StringCat (modifier_line, first_value_seen);
- StringCat (modifier_line, ")");
+ ValNodeAddPointer (&summary_col_list,
+ 0,
+ StringSave (first_value_seen));
+ summary_header_list->next->next->choice = MAX (summary_header_list->next->next->choice,
+ StringLen (first_value_seen));
}
- AppendText (summary_doc, modifier_line, NULL, NULL, programFont);
+ ValNodeAddPointer (&summary_row_list, 0, summary_col_list);
+
modifier_line = MemFree (modifier_line);
}
@@ -8465,11 +8702,33 @@ static void SummarizeModifiers (ValNodePtr row_list, DoC summary_doc)
header_vnp = header_vnp->next;
column_offset++;
}
+
+ PointerToDialog (summary_dlg, summary_row_list);
+ summary_row_list = FreeTableDisplayRowList (summary_row_list);
+
+}
+
+static ValNodePtr GetListOfCurrentModifiers (SeqEntryPtr seq_list)
+{
+ ValNodePtr found_modifiers = NULL;
+ SeqEntryPtr sep, nsep;
+ CharPtr ttl;
+
+ /* get list of modifiers */
+ ValNodeAddPointer (&found_modifiers, 0, StringSave ("Organism"));
+ for (sep = seq_list; sep != NULL; sep = sep->next)
+ {
+ ttl = NULL;
+ nsep = FindNucSeqEntry (sep);
+ SeqEntryExplore (nsep, (Pointer) (&ttl), FindFirstTitle);
+ found_modifiers = BuildModifierTypeList (found_modifiers, ttl);
+ }
+ return found_modifiers;
}
static void SeqEntryPtrToOrgDoc (SequencesFormPtr sqfp)
{
- SeqEntryPtr seq_list, sep;
+ SeqEntryPtr seq_list, sep, nsep;
ValNodePtr found_modifiers = NULL, vnp;
CharPtr ttl;
CharPtr mod_name;
@@ -8487,7 +8746,6 @@ static void SeqEntryPtrToOrgDoc (SequencesFormPtr sqfp)
if (sqfp == NULL) return;
Reset (sqfp->org_doc);
- Reset (sqfp->summary_doc);
ObjectRect (sqfp->org_doc, &r);
InsetRect (&r, 4, 4);
faColFmt.pixWidth = r.right - r.left;
@@ -8498,23 +8756,22 @@ static void SeqEntryPtrToOrgDoc (SequencesFormPtr sqfp)
AppendText (sqfp->org_doc,
"You must create sequences before you can add source information.",
&faParFmt, &faColFmt, programFont);
+ Show (sqfp->org_doc);
+ Hide (sqfp->ident_org_btn);
+ Hide (sqfp->summary_dlg);
}
else
{
+ Show (sqfp->summary_dlg);
/* get list of modifiers */
- for (sep = seq_list, seq_num = 0; sep != NULL; sep = sep->next, seq_num++)
- {
- ttl = NULL;
- SeqEntryExplore (sep, (Pointer) (&ttl), FindFirstTitle);
- found_modifiers = BuildModifierTypeList (found_modifiers, ttl);
- }
+ found_modifiers = GetListOfCurrentModifiers (seq_list);
/* create header line for table */
/* store max column width in choice */
column_list = NULL;
ValNodeAddPointer (&column_list, 6, StringSave ("Seq ID"));
ValNodeAddPointer (&column_list, 8, StringSave ("Organism"));
- for (vnp = found_modifiers; vnp != NULL; vnp = vnp->next)
+ for (vnp = found_modifiers->next; vnp != NULL; vnp = vnp->next)
{
ValNodeAddPointer (&column_list, StringLen (vnp->data.ptrvalue), StringSave ((CharPtr) vnp->data.ptrvalue));
}
@@ -8527,6 +8784,8 @@ static void SeqEntryPtrToOrgDoc (SequencesFormPtr sqfp)
{
column_list = NULL;
header_vnp = header_list;
+ nsep = FindNucSeqEntry (sep);
+
/* add Sequence ID */
bsp = FindNucBioseq (sep);
if (bsp != NULL)
@@ -8544,7 +8803,7 @@ static void SeqEntryPtrToOrgDoc (SequencesFormPtr sqfp)
/* get title */
ttl = NULL;
- SeqEntryExplore (sep, (Pointer) (&ttl), FindFirstTitle);
+ SeqEntryExplore (nsep, (Pointer) (&ttl), FindFirstTitle);
/* add organism name */
header_vnp = header_vnp->next;
@@ -8554,7 +8813,7 @@ static void SeqEntryPtrToOrgDoc (SequencesFormPtr sqfp)
ValNodeAddPointer (&column_list, 0, org_name);
/* get remaining modifiers */
- for (vnp = found_modifiers; vnp != NULL; vnp = vnp->next)
+ for (vnp = found_modifiers->next; vnp != NULL; vnp = vnp->next)
{
header_vnp = header_vnp->next;
mod_name = (CharPtr) vnp->data.ptrvalue;
@@ -8565,9 +8824,19 @@ static void SeqEntryPtrToOrgDoc (SequencesFormPtr sqfp)
}
ValNodeAddPointer (&row_list, 0, column_list);
}
+ if (AnySequencesHaveIdenticalOrganisms (row_list))
+ {
+ Show (sqfp->ident_org_btn);
+ Show (sqfp->org_doc);
+ }
+ else
+ {
+ Hide (sqfp->ident_org_btn);
+ Hide (sqfp->org_doc);
+ }
ReportIdenticalOrganisms (row_list, sqfp->org_doc);
- SummarizeModifiers (row_list, sqfp->summary_doc);
+ SummarizeModifiers (row_list, sqfp->summary_dlg);
/* free table text */
for (row_vnp = row_list; row_vnp != NULL; row_vnp = row_vnp->next)
@@ -8581,7 +8850,6 @@ static void SeqEntryPtrToOrgDoc (SequencesFormPtr sqfp)
}
/* update document */
InvalDocRows (sqfp->org_doc, 0, 0, 0);
- InvalDocRows (sqfp->summary_doc, 0, 0, 0);
}
static void SeqEntryPtrToSourceTab (SequencesFormPtr sqfp)
@@ -10231,6 +10499,7 @@ static DialoG MultiOrganismSelectionDialog (GrouP parent)
RecT r1, r2, r3;
ValNodePtr gencodelist;
ButtoN b;
+ PrompT p1;
dlg = (MultiOrganismSelectionDialogPtr) MemNew (sizeof (MultiOrganismSelectionDialogData));
@@ -10250,7 +10519,8 @@ static DialoG MultiOrganismSelectionDialog (GrouP parent)
dlg->geneticcodelist = GetGeneticCodeValNodeList ();
dlg->org_select_dlg = OrganismSelectionDialog (grp, "");
-
+ p1 = StaticPrompt (grp, "You can use the Copy buttons to populate the organism field from the selector above.",
+ 0, 0, programFont, 'l');
scroll_grp = NormalGroup (grp, 2, 0, "", NULL, NULL);
id_grp = HiddenGroup (scroll_grp, 5, 0, NULL);
@@ -10304,7 +10574,7 @@ static DialoG MultiOrganismSelectionDialog (GrouP parent)
dlg->id_scroll = ScrollBar4 (scroll_grp, 0, 10, MultiOrgScroll);
SetObjectExtra (dlg->id_scroll, dlg, NULL);
- AlignObjects (ALIGN_CENTER, (HANDLE) dlg->org_select_dlg, (HANDLE) scroll_grp, NULL);
+ AlignObjects (ALIGN_CENTER, (HANDLE) dlg->org_select_dlg, (HANDLE) p1, (HANDLE) scroll_grp, NULL);
ObjectRect (dlg->copy_btn [0], &r1);
ObjectRect (dlg->copy_btn [4], &r2);
@@ -10443,6 +10713,54 @@ GetTagListValue (TagListPtr tlp, Int4 seq_num)
return GetTagListValueEx (tlp, seq_num, 1);
}
+static void SetTagListValue (TagListPtr tlp, Int4 row, Int4 column, CharPtr new_value)
+{
+ ValNodePtr vnp;
+ Int4 row_num;
+ CharPtr new_val;
+
+ if (tlp == NULL)
+ {
+ return;
+ }
+
+ for (vnp = tlp->vnp, row_num = 0;
+ vnp != NULL && row_num != row;
+ vnp = vnp->next, row_num++)
+ {
+ }
+ if (vnp == NULL)
+ {
+ return;
+ }
+
+ new_val = ReplaceTagListColumn (vnp->data.ptrvalue, new_value, column);
+ if (new_val != vnp->data.ptrvalue)
+ {
+ vnp->data.ptrvalue = MemFree (vnp->data.ptrvalue);
+ vnp->data.ptrvalue = new_val;
+ }
+}
+
+static void SetTagListColumnValue (TagListPtr tlp, Int4 column, CharPtr new_value)
+{
+ ValNodePtr vnp;
+ CharPtr new_val;
+
+ for (vnp = tlp->vnp;
+ vnp != NULL;
+ vnp = vnp->next)
+ {
+ new_val = ReplaceTagListColumn (vnp->data.ptrvalue, new_value, column);
+ if (new_val != vnp->data.ptrvalue)
+ {
+ vnp->data.ptrvalue = MemFree (vnp->data.ptrvalue);
+ vnp->data.ptrvalue = new_val;
+ }
+ }
+}
+
+
static void
ReplaceValueInDefLines
(SourceAssistantPtr sap,
@@ -10575,9 +10893,9 @@ static GrouP MakeGeneticCodeCommentInstructionGroup (GrouP parent)
instr_grp = HiddenGroup (parent, 1, 0, NULL);
StaticPrompt (instr_grp, "When a genetic code is determined automatically from the organism name and location,",
0, 0, programFont, 'l');
- StaticPrompt (instr_grp, "you cannot edit the genetic code directly. You may add information about the ",
+ StaticPrompt (instr_grp, "you cannot edit the genetic code directly. You may provide an alternate genetic code",
0, 0, programFont, 'l');
- StaticPrompt (instr_grp, "genetic code here if you wish.",
+ StaticPrompt (instr_grp, "and the evidence to support it here if you wish.",
0, 0, programFont, 'l');
return instr_grp;
@@ -10611,6 +10929,315 @@ static GrouP MakeLocationInstructionGroup (GrouP parent)
return instr_grp;
}
+static GrouP MakeInstructionGroup (GrouP parent, Boolean is_nontext, Int2 mod_type)
+{
+ GrouP instr_grp = NULL;
+
+ if (is_nontext)
+ {
+ instr_grp = MakeNontextInstructionGroup (parent);
+ }
+ else if (mod_type == eModifierType_Location)
+ {
+ instr_grp = MakeLocationInstructionGroup (parent);
+ }
+ else if (mod_type == eModifierType_Organism)
+ {
+ instr_grp = MakeSourceInstructionGroup (parent);
+ }
+ else if (mod_type == eModifierType_NucGeneticCode
+ || mod_type == eModifierType_MitoGeneticCode
+ || mod_type == eModifierType_GeneticCode)
+ {
+ instr_grp = MakeGeneticCodeInstructionGroup (parent);
+ }
+ else if (mod_type == eModifierType_GeneticCodeComment)
+ {
+ instr_grp = MakeGeneticCodeCommentInstructionGroup (parent);
+ }
+ return instr_grp;
+}
+
+
+/* This section of code prepares a dialog for editing one value for
+ * the specified modifier type. It can be used for setting the value
+ * for a single sequence or the values for all sequences.
+ */
+typedef struct singlemodvaldlg
+{
+ DIALOG_MESSAGE_BLOCK
+ Boolean is_nontext;
+ Int2 mod_type;
+ Int2 seqPackage;
+
+ PopuP nontext_popup;
+ DialoG strvalue_dlg;
+ DialoG org_dlg;
+ TexT text_txt;
+} SingleModValDlgData, PNTR SingleModValDlgPtr;
+
+static void SingleModValToDialog (DialoG d, Pointer userdata)
+{
+ SingleModValDlgPtr dlg;
+ CharPtr suggested_value;
+ ValNode vn;
+ ValNodePtr gencodelist;
+
+ dlg = (SingleModValDlgPtr) GetObjectExtra (d);
+
+ if (dlg == NULL)
+ {
+ return;
+ }
+
+ suggested_value = (CharPtr) userdata;
+
+ if (dlg->is_nontext)
+ {
+ if (StringICmp (suggested_value, "TRUE") == 0)
+ {
+ SetValue (dlg->nontext_popup, 2);
+ }
+ else
+ {
+ SetValue (dlg->nontext_popup, 1);
+ }
+ }
+ else if (dlg->mod_type == eModifierType_Location)
+ {
+ if (StringHasNoText (suggested_value))
+ {
+ vn.choice = 1;
+ vn.data.ptrvalue = "genomic";
+ }
+ else
+ {
+ vn.choice = GetValForEnumName (biosource_genome_simple_alist, suggested_value);
+ vn.data.ptrvalue = suggested_value;
+ }
+ vn.next = NULL;
+ PointerToDialog (dlg->strvalue_dlg, &vn);
+ }
+ else if (dlg->mod_type == eModifierType_Organism)
+ {
+ PointerToDialog (dlg->org_dlg, suggested_value);
+ }
+ else if (dlg->mod_type == eModifierType_NucGeneticCode
+ || dlg->mod_type == eModifierType_MitoGeneticCode
+ || dlg->mod_type == eModifierType_GeneticCode)
+ {
+ gencodelist = GetGeneticCodeValNodeList ();
+ if (StringHasNoText (suggested_value))
+ {
+ vn.choice = 0;
+ }
+ else if (isdigit (suggested_value[0]))
+ {
+ vn.choice = atoi (suggested_value);
+ }
+ else
+ {
+ vn.choice = GeneticCodeFromStringAndList (suggested_value, gencodelist);
+ }
+ vn.next = NULL;
+ vn.data.ptrvalue = suggested_value;
+ PointerToDialog (dlg->strvalue_dlg, &vn);
+ gencodelist = ValNodeFreeData (gencodelist);
+ }
+ else if (dlg->mod_type == eModifierType_MolType)
+ {
+ if (StringHasNoText (suggested_value))
+ {
+ vn.choice = 253;
+ }
+ else if (isdigit (suggested_value[0]))
+ {
+ vn.choice = atoi (suggested_value);
+ }
+ else
+ {
+ vn.choice = MolTypeFromString (suggested_value);
+ }
+ vn.next = NULL;
+ vn.data.ptrvalue = suggested_value;
+ PointerToDialog (dlg->strvalue_dlg, &vn);
+ }
+ else if (dlg->mod_type == eModifierType_Topology)
+ {
+ if (StringHasNoText (suggested_value))
+ {
+ vn.choice = 1;
+ }
+ else if (isdigit (suggested_value[0]))
+ {
+ vn.choice = atoi (suggested_value);
+ }
+ else
+ {
+ vn.choice = TopologyFromString (suggested_value);
+ }
+ vn.next = NULL;
+ vn.data.ptrvalue = suggested_value;
+ PointerToDialog (dlg->strvalue_dlg, &vn);
+ }
+ else
+ {
+ if (StringHasNoText (suggested_value))
+ {
+ SetTitle (dlg->text_txt, "");
+ }
+ else
+ {
+ SetTitle (dlg->text_txt, suggested_value);
+ }
+ }
+}
+
+static Pointer DialogToSingleModVal (DialoG d)
+{
+ SingleModValDlgPtr dlg;
+ CharPtr new_value = NULL;
+ ValNodePtr value_vnp;
+
+ dlg = (SingleModValDlgPtr) GetObjectExtra (d);
+
+ if (dlg == NULL)
+ {
+ return;
+ }
+
+ /* prepare value */
+ if (dlg->is_nontext)
+ {
+ if (GetValue (dlg->nontext_popup) == 2)
+ {
+ new_value = StringSave ("2");
+ }
+ }
+ else if (dlg->mod_type == eModifierType_Location
+ || dlg->mod_type == eModifierType_NucGeneticCode
+ || dlg->mod_type == eModifierType_MitoGeneticCode
+ || dlg->mod_type == eModifierType_GeneticCode
+ || dlg->mod_type == eModifierType_MolType
+ || dlg->mod_type == eModifierType_Topology)
+ {
+ value_vnp = DialogToPointer (dlg->strvalue_dlg);
+ new_value = value_vnp->data.ptrvalue;
+ if (dlg->mod_type == eModifierType_Location)
+ {
+ StringToLower (new_value);
+ }
+ value_vnp = ValNodeFree (value_vnp);
+ if (dlg->mod_type == eModifierType_MolType
+ && StringICmp (new_value, "mRNA [cDNA]") == 0)
+ {
+ new_value = MemFree (new_value);
+ new_value = StringSave ("mRNA");
+ }
+ }
+ else if (dlg->mod_type == eModifierType_Organism)
+ {
+ new_value = DialogToPointer (dlg->org_dlg);
+ }
+ else
+ {
+ new_value = SaveStringFromText (dlg->text_txt);
+ }
+ return (Pointer) new_value;
+}
+
+
+static DialoG SingleModValDialog (GrouP parent, Boolean is_nontext, Int2 mod_type, Int2 seqPackage)
+{
+ SingleModValDlgPtr dlg;
+ GrouP grp;
+ ValNodePtr gencodelist;
+
+ dlg = (SingleModValDlgPtr) MemNew (sizeof (SingleModValDlgData));
+ if (dlg == NULL)
+ {
+ return NULL;
+ }
+
+ grp = HiddenGroup (parent, 1, 0, NULL);
+ SetObjectExtra (grp, dlg, StdCleanupExtraProc);
+ SetGroupSpacing (grp, 10, 10);
+
+ dlg->dialog = (DialoG) grp;
+ dlg->todialog = SingleModValToDialog;
+ dlg->fromdialog = DialogToSingleModVal;
+ dlg->dialogmessage = NULL;
+ dlg->testdialog = NULL;
+
+ dlg->is_nontext = is_nontext;
+ dlg->mod_type = mod_type;
+ dlg->nontext_popup = NULL;
+ dlg->strvalue_dlg = NULL;
+ dlg->org_dlg = NULL;
+ dlg->text_txt = NULL;
+
+
+ if (dlg->is_nontext)
+ {
+ dlg->nontext_popup = PopupList (grp, TRUE, NULL);
+ PopupItem (dlg->nontext_popup, "FALSE");
+ PopupItem (dlg->nontext_popup, "TRUE");
+ }
+ else if (dlg->mod_type == eModifierType_Location)
+ {
+ dlg->strvalue_dlg = EnumAssocSelectionDialog (grp, biosource_genome_simple_alist,
+ "location", FALSE, NULL, NULL);
+ }
+ else if (dlg->mod_type == eModifierType_Organism)
+ {
+ dlg->org_dlg = OrganismSelectionDialog (grp, "");
+ }
+ else if (dlg->mod_type == eModifierType_NucGeneticCode
+ || dlg->mod_type == eModifierType_MitoGeneticCode
+ || dlg->mod_type == eModifierType_GeneticCode)
+ {
+ gencodelist = GetGeneticCodeValNodeList ();
+ dlg->strvalue_dlg = ValNodeSelectionDialog (grp, gencodelist, 6,
+ ValNodeStringName,
+ ValNodeSimpleDataFree,
+ ValNodeStringCopy,
+ ValNodeChoiceMatch,
+ "genetic code",
+ NULL, NULL, FALSE);
+ }
+ else if (dlg->mod_type == eModifierType_MolType)
+ {
+ if (seqPackage == SEQ_PKG_GENOMICCDNA)
+ {
+ dlg->strvalue_dlg = EnumAssocSelectionDialog (grp, biomol_nucGen_alist,
+ "moltype", FALSE, NULL, NULL);
+ }
+ else
+ {
+ dlg->strvalue_dlg = EnumAssocSelectionDialog (grp, biomol_nucX_alist,
+ "moltype", FALSE, NULL, NULL);
+ }
+ }
+ else if (dlg->mod_type == eModifierType_Topology)
+ {
+ dlg->strvalue_dlg = EnumAssocSelectionDialog (grp, topology_nuc_alist,
+ "topology", FALSE, NULL, NULL);
+ }
+ else
+ {
+ if (dlg->mod_type == eModifierType_GeneticCodeComment)
+ {
+ dlg->text_txt = DialogText (grp, "", 40, NULL);
+ }
+ else
+ {
+ dlg->text_txt = DialogText (grp, "", 20, NULL);
+ }
+ }
+
+ return (DialoG) grp;
+}
+
static CharPtr
GetValueFromTagList
(TagListPtr tlp,
@@ -10743,7 +11370,7 @@ static void AddSeqIDAndValueFromSeqEntryToRowList
(SeqEntryPtr sep,
ValNodePtr PNTR row_list)
{
- BioseqPtr bsp;
+ BioseqPtr bsp = NULL;
SeqDescrPtr sdp;
Char id_txt [128];
@@ -10801,7 +11428,14 @@ static void EditOrganismColumn (SourceAssistantPtr sap, SeqEntryPtr seq_list)
return;
}
- w = MovableModalWindow (-20, -13, -10, -10, "Organisms", NULL);
+ if ((sap != NULL && sap->num_deflines > 1) || (seq_list != NULL && seq_list->next != NULL))
+ {
+ w = MovableModalWindow (-20, -13, -10, -10, "Organism Editor", NULL);
+ }
+ else
+ {
+ w = MovableModalWindow (-20, -13, -10, -10, "Multiple Organism Editor", NULL);
+ }
h = HiddenGroup(w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
@@ -10944,85 +11578,76 @@ static void EditOrganismColumn (SourceAssistantPtr sap, SeqEntryPtr seq_list)
}
-typedef struct clearcolumnvaluesdata
+typedef struct setcolumnvaluesdata
{
- SourceAssistantPtr sap;
- SeqEntryPtr seq_list;
- TagListPtr tlp;
- CharPtr lookfor;
- CharPtr mod_name;
- Int2 seqPackage;
-} ClearColumnValuesData, PNTR ClearColumnValuesPtr;
+ TagListPtr tlp;
+ DialoG all_val_dlg;
+ Boolean is_nontext;
+ Int2 mod_type;
+} SetColumnValuesData, PNTR SetColumnValuesPtr;
-static void ClearColumnValues (ButtoN b)
-{
- BioseqPtr bsp;
- Char id_txt [128];
- ValNodePtr head, vnp;
- SeqEntryPtr sep, nsep;
- ClearColumnValuesPtr ccvp;
- Int4 j;
+static void SetAllColumnValues (SetColumnValuesPtr scvp, CharPtr new_value)
+{
+ CharPtr taglist_str;
+ Int4 j;
+ ValNodePtr vnp;
- ccvp = (ClearColumnValuesPtr) GetObjectExtra (b);
- if (ccvp == NULL || (ccvp->sap == NULL && ccvp->seq_list == NULL) || ccvp->tlp == NULL)
+ if (scvp == NULL || scvp->tlp == NULL)
{
return;
}
- head = NULL;
- if (ccvp->sap == NULL)
- {
- for (sep = ccvp->seq_list; sep != NULL; sep = sep->next)
- {
- if (IS_Bioseq (sep))
- {
- bsp = (BioseqPtr) sep->data.ptrvalue;
- }
- else if (IS_Bioseq_set (sep))
- {
- nsep = FindNucSeqEntry (sep);
- if (nsep != NULL && IS_Bioseq (nsep))
- {
- bsp = (BioseqPtr) nsep->data.ptrvalue;
- }
- }
-
- if (bsp == NULL)
- {
- continue;
- }
+ taglist_str = TagListStringFromDefLineValue (new_value, scvp->is_nontext, scvp->mod_type);
+ SetTagListColumnValue (scvp->tlp, 1, taglist_str);
+ taglist_str = MemFree (taglist_str);
+
+ SendMessageToDialog (scvp->tlp->dialog, VIB_MSG_REDRAW);
+ for (j = 0, vnp = scvp->tlp->vnp; vnp != NULL; j++, vnp = vnp->next) {
+ }
+ scvp->tlp->max = MAX ((Int2) 0, (Int2) (j - scvp->tlp->rows));
+ CorrectBarMax (scvp->tlp->bar, scvp->tlp->max);
+ CorrectBarPage (scvp->tlp->bar, scvp->tlp->rows - 1, scvp->tlp->rows - 1);
+ if (scvp->tlp->max > 0) {
+ SafeShow (scvp->tlp->bar);
+ } else {
+ SafeHide (scvp->tlp->bar);
+ }
+ SendMessageToDialog (scvp->tlp->dialog, VIB_MSG_ENTER);
+}
+
+static void ClearColumnValues (ButtoN b)
+{
+ SetColumnValuesPtr scvp;
- SeqIdWrite (SeqIdFindWorst (bsp->id), id_txt, PRINTID_REPORT, sizeof (id_txt));
+ scvp = (SetColumnValuesPtr) GetObjectExtra (b);
- AddSeqIDAndValueToTagList (id_txt, NULL,
- ccvp->lookfor, ccvp->mod_name, ccvp->seqPackage,
- &head, NULL);
- }
- }
- else
+ if (ANS_NO == Message (MSG_YN, "Are you sure you want to clear all the values?"))
{
- for (j = 0; j < ccvp->sap->num_deflines; j++)
- {
- AddSeqIDAndValueToTagList (ccvp->sap->id_list[j], NULL,
- ccvp->lookfor, ccvp->mod_name, ccvp->seqPackage,
- &head, NULL);
- }
+ return;
}
- SendMessageToDialog (ccvp->tlp->dialog, VIB_MSG_RESET);
- ccvp->tlp->vnp = head;
- SendMessageToDialog (ccvp->tlp->dialog, VIB_MSG_REDRAW);
- for (j = 0, vnp = ccvp->tlp->vnp; vnp != NULL; j++, vnp = vnp->next) {
+ SetAllColumnValues (scvp, NULL);
+}
+
+static void EditOrgModApplyAll (ButtoN b)
+{
+ SetColumnValuesPtr scvp;
+ CharPtr new_value;
+
+ scvp = (SetColumnValuesPtr) GetObjectExtra (b);
+ if (scvp == NULL || scvp->all_val_dlg == NULL || scvp->tlp == NULL)
+ {
+ return;
}
- ccvp->tlp->max = MAX ((Int2) 0, (Int2) (j - ccvp->tlp->rows));
- CorrectBarMax (ccvp->tlp->bar, ccvp->tlp->max);
- CorrectBarPage (ccvp->tlp->bar, ccvp->tlp->rows - 1, ccvp->tlp->rows - 1);
- if (ccvp->tlp->max > 0) {
- SafeShow (ccvp->tlp->bar);
- } else {
- SafeHide (ccvp->tlp->bar);
+
+ if (ANS_NO == Message (MSG_YN, "Are you sure you want to set all the values?"))
+ {
+ return;
}
- SendMessageToDialog (ccvp->tlp->dialog, VIB_MSG_ENTER);
+
+ new_value = DialogToPointer (scvp->all_val_dlg);
+ SetAllColumnValues (scvp, new_value);
+ new_value = MemFree (new_value);
}
static void
@@ -11050,9 +11675,10 @@ EditOrgModColumn
EnumFieldAssocPtr gencode_alist = NULL;
EnumFieldAssocPtr edit_alists [2];
GrouP instr_grp = NULL;
- ClearColumnValuesData ccvd;
+ SetColumnValuesData scvd;
ButtoN clear_btn;
CharPtr mod_label;
+ ButtoN apply_all_btn;
if (StringHasNoText (mod_name) || (sap == NULL && seq_list == NULL))
{
@@ -11082,6 +11708,15 @@ EditOrgModColumn
w = MovableModalWindow (-20, -13, -10, -10, mod_label, NULL);
h = HiddenGroup(w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
+
+ instr_grp = MakeInstructionGroup (h, is_nontext, mod_type);
+
+ scvd.all_val_dlg = SingleModValDialog (h, is_nontext, mod_type, seqPackage);
+ PointerToDialog (scvd.all_val_dlg, NULL);
+ scvd.is_nontext = is_nontext;
+ scvd.mod_type = mod_type;
+ apply_all_btn = PushButton (h, "Apply above value to all sequences", EditOrgModApplyAll);
+ SetObjectExtra (apply_all_btn, &scvd, NULL);
k = HiddenGroup (h, 1, 0, NULL);
g = HiddenGroup (k, 2, 0, NULL);
@@ -11111,14 +11746,12 @@ EditOrgModColumn
dlg = CreateTagListDialogEx (k, rows_shown, 2, 2,
nontextmodedittypes, modedit_widths,
nontextmodedit_alists, TRUE, TRUE, NULL, NULL);
- instr_grp = MakeNontextInstructionGroup (h);
}
else if (mod_type == eModifierType_Location)
{
dlg = CreateTagListDialogEx (k, rows_shown, 2, 2,
locationmodedittypes, modedit_widths,
locationmodedit_alists, TRUE, TRUE, NULL, NULL);
- instr_grp = MakeLocationInstructionGroup (h);
}
else if (mod_type == eModifierType_NucGeneticCode
|| mod_type == eModifierType_MitoGeneticCode)
@@ -11129,7 +11762,6 @@ EditOrgModColumn
dlg = CreateTagListDialogEx (k, rows_shown, 2, 2,
locationmodedittypes, modedit_widths,
edit_alists, TRUE, TRUE, NULL, NULL);
- instr_grp = MakeGeneticCodeInstructionGroup (h);
}
else if (mod_type == eModifierType_MolType)
{
@@ -11162,7 +11794,6 @@ EditOrgModColumn
dlg = CreateTagListDialogEx (k, rows_shown, 2, 2,
modedit_types, modedit_widths,
NULL, TRUE, TRUE, NULL, NULL);
- instr_grp = MakeSourceInstructionGroup (h);
}
else
{
@@ -11212,15 +11843,21 @@ EditOrgModColumn
}
SendMessageToDialog (tlp->dialog, VIB_MSG_ENTER);
- ccvd.sap = sap;
- ccvd.seq_list = seq_list;
- ccvd.tlp = tlp;
- ccvd.lookfor = lookfor;
- ccvd.mod_name = mod_name;
- ccvd.seqPackage = seqPackage;
+ scvd.tlp = tlp;
- clear_btn = PushButton (h, "Clear All Values", ClearColumnValues);
- SetObjectExtra (clear_btn, &ccvd, NULL);
+ if (mod_type == eModifierType_MolType)
+ {
+ clear_btn = PushButton (h, "Reset All to Genomic DNA", ClearColumnValues);
+ }
+ else if (mod_type == eModifierType_Topology)
+ {
+ clear_btn = PushButton (h, "Reset All to Linear", ClearColumnValues);
+ }
+ else
+ {
+ clear_btn = PushButton (h, "Clear All Values", ClearColumnValues);
+ }
+ SetObjectExtra (clear_btn, &scvd, NULL);
c = HiddenGroup (h, 2, 0, NULL);
b = PushButton (c, "Accept", ModalAcceptButton);
@@ -11228,15 +11865,13 @@ EditOrgModColumn
b = PushButton (c, "Cancel", ModalCancelButton);
SetObjectExtra (b, &acd, NULL);
- if (instr_grp == NULL)
- {
- AlignObjects (ALIGN_CENTER, (HANDLE) k, (HANDLE) clear_btn, (HANDLE) c, (HANDLE) NULL);
- }
- else
- {
- AlignObjects (ALIGN_CENTER, (HANDLE) k, (HANDLE) instr_grp, (HANDLE) clear_btn,
- (HANDLE) c, (HANDLE) NULL);
- }
+ AlignObjects (ALIGN_CENTER, (HANDLE) scvd.all_val_dlg,
+ (HANDLE) apply_all_btn,
+ (HANDLE) k,
+ (HANDLE) clear_btn,
+ (HANDLE) c,
+ (HANDLE) instr_grp,
+ NULL);
Show (w);
Select (w);
@@ -11535,6 +12170,7 @@ ContinueWithAutopopulatedGeneticCodes
return rval;
}
+
static void
ApplyOrgModColumnOrCell
(CharPtr mod_name,
@@ -11547,13 +12183,11 @@ ApplyOrgModColumnOrCell
Int2 seqPackage)
{
WindoW w;
- GrouP h, g, c;
- TexT text_txt;
- PopuP nontext_popup;
+ GrouP h, c;
GrouP instr_grp = NULL;
Boolean found_value = FALSE;
Int4 j;
- ValNodePtr head = NULL, value_vnp;
+ ValNodePtr head = NULL;
ModalAcceptCancelData acd;
ButtoN b;
Boolean is_nontext;
@@ -11561,9 +12195,6 @@ ApplyOrgModColumnOrCell
CharPtr title;
CharPtr all_seq_fmt = "%s (all sequences)";
CharPtr one_seq_fmt = "%s (Seq_ID %s)";
- ValNode vn;
- DialoG org_dlg;
- DialoG strvalue_dlg;
Int4 num_sequences = 0;
SeqEntryPtr sep, nuc_sep;
Char id_txt[128];
@@ -11573,6 +12204,8 @@ ApplyOrgModColumnOrCell
ValNodePtr row_vnp = NULL, col_vnp;
Int4 row_num, col_num;
CharPtr mod_label;
+ Boolean done;
+ DialoG val_dlg;
if (StringHasNoText (mod_name) || row < -1)
{
@@ -11694,138 +12327,10 @@ ApplyOrgModColumnOrCell
h = HiddenGroup(w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
- g = HiddenGroup (h, 1, 0, NULL);
-
- if (is_nontext)
- {
- nontext_popup = PopupList (g, TRUE, NULL);
- PopupItem (nontext_popup, "FALSE");
- PopupItem (nontext_popup, "TRUE");
- if (StringICmp (suggested_value, "TRUE") == 0)
- {
- SetValue (nontext_popup, 2);
- }
- else
- {
- SetValue (nontext_popup, 1);
- }
- instr_grp = MakeNontextInstructionGroup (h);
- }
- else if (mod_type == eModifierType_Location)
- {
- if (StringHasNoText (suggested_value))
- {
- vn.choice = 1;
- vn.data.ptrvalue = "genomic";
- }
- else
- {
- vn.choice = GetValForEnumName (biosource_genome_simple_alist, suggested_value);
- vn.data.ptrvalue = suggested_value;
- }
- vn.next = NULL;
- strvalue_dlg = EnumAssocSelectionDialog (g, biosource_genome_simple_alist,
- "location", FALSE, NULL, NULL);
- PointerToDialog (strvalue_dlg, &vn);
- instr_grp = MakeLocationInstructionGroup (h);
- }
- else if (mod_type == eModifierType_Organism)
- {
- org_dlg = OrganismSelectionDialog (g, suggested_value);
- instr_grp = MakeSourceInstructionGroup (h);
- }
- else if (mod_type == eModifierType_NucGeneticCode
- || mod_type == eModifierType_MitoGeneticCode
- || mod_type == eModifierType_GeneticCode)
- {
- gencodelist = GetGeneticCodeValNodeList ();
- if (StringHasNoText (suggested_value))
- {
- vn.choice = 0;
- }
- else if (isdigit (suggested_value[0]))
- {
- vn.choice = atoi (suggested_value);
- }
- else
- {
- vn.choice = GeneticCodeFromStringAndList (suggested_value, gencodelist);
- }
- vn.next = NULL;
- vn.data.ptrvalue = suggested_value;
- strvalue_dlg = ValNodeSelectionDialog (g, gencodelist, 6,
- ValNodeStringName,
- ValNodeSimpleDataFree,
- ValNodeStringCopy,
- ValNodeChoiceMatch,
- "genetic code",
- NULL, NULL, FALSE);
- PointerToDialog (strvalue_dlg, &vn);
- instr_grp = MakeGeneticCodeInstructionGroup (h);
- }
- else if (mod_type == eModifierType_MolType)
- {
- if (StringHasNoText (suggested_value))
- {
- if (PackageTypeIsSet (seqPackage) || seqPackage == SEQ_PKG_GENOMICCDNA)
- {
- vn.choice = 253;
- }
- else
- {
- vn.choice = 254;
- }
- }
- else if (isdigit (suggested_value[0]))
- {
- vn.choice = atoi (suggested_value);
- }
- else
- {
- vn.choice = MolTypeFromString (suggested_value);
- }
- vn.next = NULL;
- vn.data.ptrvalue = suggested_value;
- if (seqPackage == SEQ_PKG_GENOMICCDNA)
- {
- strvalue_dlg = EnumAssocSelectionDialog (g, biomol_nucGen_alist,
- "moltype", FALSE, NULL, NULL);
- }
- else
- {
- strvalue_dlg = EnumAssocSelectionDialog (g, biomol_nucX_alist,
- "moltype", FALSE, NULL, NULL);
- }
- PointerToDialog (strvalue_dlg, &vn);
- }
- else if (mod_type == eModifierType_Topology)
- {
- if (StringHasNoText (suggested_value))
- {
- vn.choice = 1;
- }
- else if (isdigit (suggested_value[0]))
- {
- vn.choice = atoi (suggested_value);
- }
- else
- {
- vn.choice = TopologyFromString (suggested_value);
- }
- vn.next = NULL;
- vn.data.ptrvalue = suggested_value;
- strvalue_dlg = EnumAssocSelectionDialog (g, topology_nuc_alist,
- "topology", FALSE, NULL, NULL);
- PointerToDialog (strvalue_dlg, &vn);
- }
- else
- {
- text_txt = DialogText (g, suggested_value, 20, NULL);
- if (mod_type == eModifierType_GeneticCodeComment)
- {
- instr_grp = MakeGeneticCodeCommentInstructionGroup (h);
- }
- }
+ instr_grp = MakeInstructionGroup (h, is_nontext, mod_type);
+
+ val_dlg = SingleModValDialog (h, is_nontext, mod_type, seqPackage);
+ PointerToDialog (val_dlg, suggested_value);
c = HiddenGroup (h, 2, 0, NULL);
b = PushButton (c, "Accept", ModalAcceptButton);
@@ -11835,127 +12340,103 @@ ApplyOrgModColumnOrCell
if (instr_grp == NULL)
{
- AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) c, (HANDLE) NULL);
+ AlignObjects (ALIGN_CENTER, (HANDLE) val_dlg, (HANDLE) c, (HANDLE) NULL);
}
else
{
- AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) instr_grp, (HANDLE) c, (HANDLE) NULL);
+ AlignObjects (ALIGN_CENTER, (HANDLE) val_dlg, (HANDLE) instr_grp, (HANDLE) c, (HANDLE) NULL);
}
mod_label = MemFree (mod_label);
Show (w);
Select (w);
- acd.accepted = FALSE;
- acd.cancelled = FALSE;
- while (!acd.accepted && ! acd.cancelled)
- {
- ProcessExternalEvent ();
- Update ();
- }
- ProcessAnEvent ();
- if (acd.cancelled)
- {
- Remove (w);
- return;
- }
- else
+
+ done = FALSE;
+ while (!done)
{
- if (is_nontext)
+ acd.accepted = FALSE;
+ acd.cancelled = FALSE;
+ while (!acd.accepted && ! acd.cancelled)
{
- if (GetValue (nontext_popup) == 2)
- {
- new_value = StringSave ("2");
- }
+ ProcessExternalEvent ();
+ Update ();
}
- else if (mod_type == eModifierType_Location
- || mod_type == eModifierType_NucGeneticCode
- || mod_type == eModifierType_MitoGeneticCode
- || mod_type == eModifierType_GeneticCode
- || mod_type == eModifierType_MolType
- || mod_type == eModifierType_Topology)
+ ProcessAnEvent ();
+ if (acd.cancelled)
{
- value_vnp = DialogToPointer (strvalue_dlg);
- new_value = value_vnp->data.ptrvalue;
- if (mod_type == eModifierType_Location)
- {
- StringToLower (new_value);
- }
- value_vnp = ValNodeFree (value_vnp);
- if (mod_type == eModifierType_MolType
- && StringICmp (new_value, "mRNA [cDNA]") == 0)
- {
- new_value = MemFree (new_value);
- new_value = StringSave ("mRNA");
- }
+ done = TRUE;
}
- else if (mod_type == eModifierType_Organism)
+ else if (row < 0 && ANS_NO == Message (MSG_YN, "Are you sure you want to apply this value to all of your sequences?"))
{
- new_value = DialogToPointer (org_dlg);
+ /* do nothing - they'll be able to cancel from the dialog if they want to */
}
else
{
- new_value = SaveStringFromText (text_txt);
- }
+ /* prepare value */
+ new_value = DialogToPointer (val_dlg);
- if (seq_list != NULL)
- {
- for (sep = seq_list, j = 0;
- sep != NULL;
- sep = sep->next, j++)
+ /* apply value to either seq_list, sap, or row_list */
+ if (seq_list != NULL)
{
- if (j == row || row == -1)
+ for (sep = seq_list, j = 0;
+ sep != NULL;
+ sep = sep->next, j++)
{
- ApplyOneModToSeqEntry (sep, mod_name, new_value);
+ if (j == row || row == -1)
+ {
+ ApplyOneModToSeqEntry (sep, mod_name, new_value);
+ }
}
- }
- if (mod_type == eModifierType_Organism
- || mod_type == eModifierType_Location
- || mod_type == eModifierType_GeneticCode)
- {
- UpdateGeneticCodesForSeqEntryList (seq_list);
- }
- }
- else if (sap != NULL)
- {
- for (j = 0; j < sap->num_deflines; j++)
- {
- if (j == row || row == -1)
+ if (mod_type == eModifierType_Organism
+ || mod_type == eModifierType_Location
+ || mod_type == eModifierType_GeneticCode)
{
- ReplaceValueInDefLines (sap, mod_name, new_value, j);
+ UpdateGeneticCodesForSeqEntryList (seq_list);
}
}
- if (mod_type == eModifierType_Organism
- || mod_type == eModifierType_Location
- || mod_type == eModifierType_GeneticCode)
+ else if (sap != NULL)
{
- UpdateGeneticCodesForSourceAssistant (sap);
- }
- }
- else if (row_list != NULL)
- {
- if (row < 0)
- {
- SetRowListColumn (row_list, row_list_column, new_value);
+ for (j = 0; j < sap->num_deflines; j++)
+ {
+ if (j == row || row == -1)
+ {
+ ReplaceValueInDefLines (sap, mod_name, new_value, j);
+ }
+ }
+ if (mod_type == eModifierType_Organism
+ || mod_type == eModifierType_Location
+ || mod_type == eModifierType_GeneticCode)
+ {
+ UpdateGeneticCodesForSourceAssistant (sap);
+ }
}
- else if (row_vnp != NULL)
+ else if (row_list != NULL)
{
- for (col_vnp = row_vnp->data.ptrvalue, col_num = 0;
- col_vnp != NULL && col_num < row_list_column;
- col_vnp = col_vnp->next, col_num++)
+ if (row < 0)
{
+ SetRowListColumn (row_list, row_list_column, new_value);
}
- if (col_vnp != NULL)
+ else if (row_vnp != NULL)
{
- col_vnp->data.ptrvalue = MemFree (col_vnp->data.ptrvalue);
- col_vnp->data.ptrvalue = StringSave (new_value);
+ for (col_vnp = row_vnp->data.ptrvalue, col_num = 0;
+ col_vnp != NULL && col_num < row_list_column;
+ col_vnp = col_vnp->next, col_num++)
+ {
+ }
+ if (col_vnp != NULL)
+ {
+ col_vnp->data.ptrvalue = MemFree (col_vnp->data.ptrvalue);
+ col_vnp->data.ptrvalue = StringSave (new_value);
+ }
}
}
- }
- new_value = MemFree (new_value);
- UpdateOrgModDlg (sap);
- Remove (w);
+ new_value = MemFree (new_value);
+ UpdateOrgModDlg (sap);
+ done = TRUE;
+ }
}
+ Remove (w);
}
static void
@@ -12136,7 +12617,7 @@ static void OrgModDblClick (PoinT cell_coord, CharPtr header_text, CharPtr cell_
static void SourceAssistant (ButtoN b)
{
SequencesFormPtr sqfp;
- SeqEntryPtr seq_list, cntr_sep;
+ SeqEntryPtr seq_list, cntr_sep, nsep;
SourceAssistantData sad;
CharPtr ttl;
BioseqPtr bsp;
@@ -12149,6 +12630,7 @@ static void SourceAssistant (ButtoN b)
FastaPagePtr fpp;
Int4 doc_width = stdCharWidth * 40;
ButtoN export_btn;
+ PrompT ppt1, ppt2;
sqfp = (SequencesFormPtr) GetObjectExtra (b);
if (sqfp == NULL) return;
@@ -12202,10 +12684,11 @@ static void SourceAssistant (ButtoN b)
cntr_sep = cntr_sep->next, i++)
{
ttl = NULL;
- SeqEntryExplore (cntr_sep, (Pointer) (&ttl), FindFirstTitle);
+ nsep = FindNucSeqEntry (cntr_sep);
+ SeqEntryExplore (nsep, (Pointer) (&ttl), FindFirstTitle);
sad.defline_list[i] = StringSaveNoNull (ttl);
- bsp = FindNucBioseq (cntr_sep);
+ bsp = FindNucBioseq (nsep);
if (bsp != NULL)
{
sip = SeqIdFindWorst (bsp->id);
@@ -12260,9 +12743,12 @@ static void SourceAssistant (ButtoN b)
SetDocAutoAdjust (sad.mod_doc, TRUE);
sad.orgmod_dlg = TableDisplayDialog (h, doc_width, stdLineHeight * 16, 1, 1,
- OrgModDblClick, &sad);
+ OrgModDblClick, &sad,
+ OrganismMatchesAnotherRow, NULL);
UpdateOrgModDlg (&sad);
+ ppt1 = StaticPrompt (h, "Sequence IDs in red have source information", 0, 0, programFont, 'l');
+ ppt2 = StaticPrompt (h, "that matches at least one other sequence.", 0, 0, programFont, 'l');
export_btn = PushButton (h, "Export Source Modifier Table", SourceAssistantExport);
SetObjectExtra (export_btn, &sad, NULL);
@@ -12277,6 +12763,8 @@ static void SourceAssistant (ButtoN b)
(HANDLE) g,
(HANDLE) sad.mod_doc,
(HANDLE) sad.orgmod_dlg,
+ (HANDLE) ppt1,
+ (HANDLE) ppt2,
(HANDLE) export_btn,
(HANDLE) c,
NULL);
@@ -12298,9 +12786,10 @@ static void SourceAssistant (ButtoN b)
cntr_sep = cntr_sep->next, i++)
{
ttlvnp = NULL;
- SeqEntryExplore (cntr_sep, (Pointer) (&ttlvnp), FindFirstSeqDescrTitle);
+ nsep = FindNucSeqEntry (cntr_sep);
+ SeqEntryExplore (nsep, (Pointer) (&ttlvnp), FindFirstSeqDescrTitle);
if (ttlvnp == NULL) {
- ttlvnp = CreateNewDescriptor (cntr_sep, Seq_descr_title);
+ ttlvnp = CreateNewDescriptor (nsep, Seq_descr_title);
}
if (ttlvnp != NULL) {
ttlvnp->data.ptrvalue = MemFree (ttlvnp->data.ptrvalue);
@@ -12436,33 +12925,6 @@ static void ApplyModValuesAllBtn (ButtoN b)
Remove (w);
}
-static void ApplyOrganismValuesAllBtn (ButtoN b)
-{
- WindoW w;
-
- w = ParentWindow ((Nlm_GraphiC) b);
- ApplyOneValueToAllSequencesDialog (b, "organism");
- Remove (w);
-}
-
-static void ApplyLocationValuesAllBtn (ButtoN b)
-{
- WindoW w;
-
- w = ParentWindow ((Nlm_GraphiC) b);
- ApplyOneValueToAllSequencesDialog (b, "location");
- Remove (w);
-}
-
-static void ApplyGeneticCodeValuesAllBtn (ButtoN b)
-{
- WindoW w;
-
- w = ParentWindow ((Nlm_GraphiC) b);
- ApplyOneValueToAllSequencesDialog (b, "genetic_code");
- Remove (w);
-}
-
static void ApplyModValuesIndividuallyBtn (ButtoN b)
{
WindoW w;
@@ -12478,15 +12940,6 @@ static void ApplyModValuesIndividuallyBtn (ButtoN b)
Remove (w);
}
-static void ApplyOrgLocGcodeValuesIndividuallyBtn (ButtoN b)
-{
- WindoW w;
-
- w = ParentWindow ((Nlm_GraphiC) b);
- ApplyModValuesIndividually (b, "organism");
- Remove (w);
-}
-
static void SpecifyModValueButton (ButtoN b, CharPtr mod_name)
{
SequencesFormPtr sqfp;
@@ -12554,25 +13007,10 @@ static void SpecifyModValueButton (ButtoN b, CharPtr mod_name)
}
-static void SpecifyOrganisms (ButtoN b)
-{
- SpecifyModValueButton (b, "organism");
-}
-
-static void SpecifyLocations (ButtoN b)
-{
- SpecifyModValueButton (b, "location");
-}
-
static void SpecifyOrganismLocationGeneticCodeButton (ButtoN b)
{
SequencesFormPtr sqfp;
- WindoW w;
- GrouP h;
SeqEntryPtr seq_list;
- ButtoN apply_one_org_btn, apply_one_loc_btn, apply_one_gc_btn;
- ButtoN apply_all_btn = NULL;
- ButtoN cancel_btn;
sqfp = (SequencesFormPtr) GetObjectExtra (b);
if (sqfp == NULL)
@@ -12585,100 +13023,12 @@ static void SpecifyOrganismLocationGeneticCodeButton (ButtoN b)
{
Message (MSG_ERROR, "You must add sequences before you can add organisms, locations, or genetic codes!");
}
- else if (seq_list->next == NULL || sqfp->seqPackage == SEQ_PKG_SEGMENTED)
- {
- ApplyModValuesIndividually (b, "organism");
- }
- else
- {
- w = MovableModalWindow (-20, -13, -10, -10, "Edit Organisms, Locations, and Genetic Codes", NULL);
- h = HiddenGroup(w, -1, 0, NULL);
- SetGroupSpacing (h, 10, 10);
-
- apply_one_org_btn = PushButton (h, "Apply one organism name to all sequences", ApplyOrganismValuesAllBtn);
- SetObjectExtra (apply_one_org_btn, sqfp, NULL);
-
- apply_one_loc_btn = PushButton (h, "Apply one location to all sequences", ApplyLocationValuesAllBtn);
- SetObjectExtra (apply_one_loc_btn, sqfp, NULL);
-
- apply_one_gc_btn = PushButton (h, "Apply one genetic to all sequences", ApplyGeneticCodeValuesAllBtn);
- SetObjectExtra (apply_one_gc_btn, sqfp, NULL);
-
- apply_all_btn = PushButton (h, "Apply organism name, location, and genetic code to sequences individually", ApplyOrgLocGcodeValuesIndividuallyBtn);
- SetObjectExtra (apply_all_btn, sqfp, NULL);
-
- cancel_btn = PushButton (h, "Cancel", StdCancelButtonProc);
-
- if (apply_all_btn == NULL)
- {
- AlignObjects (ALIGN_CENTER, (HANDLE) apply_one_org_btn,
- (HANDLE) apply_one_loc_btn,
- (HANDLE) apply_one_gc_btn,
- (HANDLE) cancel_btn,
- NULL);
- }
- else
- {
- AlignObjects (ALIGN_CENTER, (HANDLE) apply_one_org_btn,
- (HANDLE) apply_one_loc_btn,
- (HANDLE) apply_one_gc_btn,
- (HANDLE) apply_all_btn,
- (HANDLE) cancel_btn,
- NULL);
- }
- Show(w);
- Select (w);
- }
-}
-
-static void ApplyOneGeneticCodeToAllSequencesDialog (ButtoN b, Boolean is_nuc)
-{
- WindoW w;
-
- w = ParentWindow ((Nlm_GraphiC) b);
- if (is_nuc)
- {
- ApplyOneValueToAllSequencesDialog (b, "gcode");
- }
- else
- {
- ApplyOneValueToAllSequencesDialog (b, "mgcode");
- }
- Remove (w);
-}
-
-static void ApplyOneNuclearGeneticCodeToAllSequencesDialog (ButtoN b)
-{
- ApplyOneGeneticCodeToAllSequencesDialog (b, TRUE);
-}
-
-static void ApplyOneMitochondrialGeneticCodeToAllSequencesDialog (ButtoN b)
-{
- ApplyOneGeneticCodeToAllSequencesDialog (b, FALSE);
-}
-
-static void ApplyGeneticCodeIndividually (ButtoN b, Boolean is_nuc)
-{
- if (is_nuc)
- {
- ApplyModValuesIndividually (b, "gcode");
- }
else
{
- ApplyModValuesIndividually (b, "mgcode");
+ ApplyModValuesIndividually (b, "organism");
}
}
-static void ApplyNuclearGeneticCodeIndividually (ButtoN b)
-{
- ApplyGeneticCodeIndividually (b, TRUE);
-}
-
-static void ApplyMitochondrialGeneticCodeIndividually (ButtoN b)
-{
- ApplyGeneticCodeIndividually (b, FALSE);
-}
-
static void SpecifyGeneticCode (ButtoN b)
{
SpecifyModValueButton (b, "genetic_code");
@@ -12687,7 +13037,7 @@ static void SpecifyGeneticCode (ButtoN b)
static void ClearAllSequenceModifiers (ButtoN b)
{
SequencesFormPtr sqfp;
- SeqEntryPtr seq_list, sep;
+ SeqEntryPtr seq_list, sep, nsep;
CharPtr ttl;
ValNodePtr found_modifiers = NULL, mod_vnp;
FastaPagePtr fpp;
@@ -12713,7 +13063,8 @@ static void ClearAllSequenceModifiers (ButtoN b)
for (sep = seq_list; sep != NULL; sep = sep->next)
{
ttl = NULL;
- SeqEntryExplore (sep, (Pointer) (&ttl), FindFirstTitle);
+ nsep = FindNucSeqEntry (sep);
+ SeqEntryExplore (nsep, (Pointer) (&ttl), FindFirstTitle);
found_modifiers = BuildModifierTypeList (found_modifiers, ttl);
for (mod_vnp = found_modifiers; mod_vnp != NULL; mod_vnp = mod_vnp->next)
{
@@ -12726,7 +13077,7 @@ static void ClearAllSequenceModifiers (ButtoN b)
&& mod_type != eModifierType_GeneticCodeComment
&& mod_type != eModifierType_Organism)
{
- ApplyOneModToSeqEntry (sep, mod_vnp->data.ptrvalue, NULL);
+ ApplyOneModToSeqEntry (nsep, mod_vnp->data.ptrvalue, NULL);
}
}
found_modifiers = ValNodeFreeData (found_modifiers);
@@ -12743,7 +13094,7 @@ static void ClearAllSequenceModifiers (ButtoN b)
static void SummaryDocOnClick (DoC d, PoinT pt)
{
SequencesFormPtr sqfp;
- SeqEntryPtr seq_list, sep;
+ SeqEntryPtr seq_list;
Int2 pos_item, pos_row, pos_col;
Int2 start_item = 0;
Int2 end_item = -1;
@@ -12771,16 +13122,53 @@ static void SummaryDocOnClick (DoC d, PoinT pt)
MapDocPoint (d, pt, &(pos_item), &(pos_row), &(pos_col), NULL);
/* get list of modifiers */
- ValNodeAddPointer (&found_modifiers, 0, "organism");
- for (sep = seq_list; sep != NULL; sep = sep->next)
+ found_modifiers = GetListOfCurrentModifiers (seq_list);
+
+ for (vnp = found_modifiers, mod_num = 1;
+ vnp != NULL && mod_num < pos_item;
+ vnp = vnp->next, mod_num++)
{
- ttl = NULL;
- SeqEntryExplore (sep, (Pointer) (&ttl), FindFirstTitle);
- found_modifiers = BuildModifierTypeList (found_modifiers, ttl);
+ }
+ if (vnp != NULL)
+ {
+ EditOrgModColumn (vnp->data.ptrvalue, NULL, seq_list, sqfp->seqPackage);
+ SeqEntryPtrToSourceTab (sqfp);
+ fpp = (FastaPagePtr) GetObjectExtra (sqfp->dnaseq);
+ if (fpp != NULL)
+ {
+ Reset (fpp->doc);
+ FormatFastaDoc (fpp);
+ }
+ }
+ ValNodeFreeData (found_modifiers);
+}
+
+static void SummaryDblClick (PoinT cell_coord, CharPtr header_text, CharPtr cell_text, Pointer userdata)
+{
+ ValNodePtr found_modifiers = NULL, vnp;
+ SequencesFormPtr sqfp;
+ SeqEntryPtr seq_list;
+ Int4 mod_num;
+ FastaPagePtr fpp;
+
+ if (cell_coord.y < 1 || userdata == NULL)
+ {
+ return;
}
+ sqfp = (SequencesFormPtr) userdata;
+
+ seq_list = GetSeqEntryFromSequencesForm (sqfp);
+ if (seq_list == NULL)
+ {
+ return;
+ }
+
+ /* get list of modifiers */
+ found_modifiers = GetListOfCurrentModifiers (seq_list);
+
for (vnp = found_modifiers, mod_num = 1;
- vnp != NULL && mod_num < pos_item;
+ vnp != NULL && mod_num < cell_coord.y;
vnp = vnp->next, mod_num++)
{
}
@@ -12795,6 +13183,7 @@ static void SummaryDocOnClick (DoC d, PoinT pt)
FormatFastaDoc (fpp);
}
}
+ ValNodeFreeData (found_modifiers);
}
static GrouP CreateSourceTab (GrouP h, SequencesFormPtr sqfp)
@@ -12816,11 +13205,14 @@ static GrouP CreateSourceTab (GrouP h, SequencesFormPtr sqfp)
sqfp->org_doc = DocumentPanel (mod_grp, stdCharWidth * 27, stdLineHeight * 2);
SetDocAutoAdjust (sqfp->org_doc, TRUE);
+ sqfp->ident_org_btn = PushButton (mod_grp, "Some Sequences Have Identical Organisms!", SourceAssistant);
+ SetObjectExtra (sqfp->ident_org_btn, sqfp, NULL);
+ Disable (sqfp->source_assist_btn);
- sqfp->summary_doc = DocumentPanel (mod_grp, stdCharWidth * 27, stdLineHeight * 12);
- SetObjectExtra (sqfp->summary_doc, sqfp, NULL);
- SetDocAutoAdjust (sqfp->summary_doc, TRUE);
- SetDocProcs (sqfp->summary_doc, SummaryDocOnClick, NULL, NULL, NULL);
+ sqfp->summary_dlg = TableDisplayDialog (mod_grp, stdCharWidth * 30, stdLineHeight * 12, 1, 1,
+ SummaryDblClick, sqfp,
+ NULL, NULL);
+
sqfp->specify_orgs_btn = PushButton (mod_grp,
"Add Organisms, Locations, and Genetic Codes",
@@ -12849,6 +13241,8 @@ static GrouP CreateSourceTab (GrouP h, SequencesFormPtr sqfp)
SeqEntryPtrToSourceTab (sqfp);
AlignObjects (ALIGN_CENTER, (HANDLE) sqfp->org_doc,
+ (HANDLE) sqfp->ident_org_btn,
+ (HANDLE) sqfp->summary_dlg,
(HANDLE) sqfp->specify_orgs_btn,
(HANDLE) k,
NULL);
@@ -12927,37 +13321,6 @@ static DialoG FastaSummaryDialog (GrouP parent)
return (DialoG) p;
}
-static void SetDefaultMolTypesAndTopologies (SeqEntryPtr seq_list, Int2 seqPackage)
-{
- SeqEntryPtr sep;
- CharPtr ttl = NULL;
- Char tmp[128];
-
- for (sep = seq_list; sep != NULL; sep = sep->next)
- {
- ttl = NULL;
- SeqEntryExplore (sep, (Pointer) (&ttl), FindFirstTitle);
-
- if (!LookForSearchString (ttl, "[moltype=", tmp, sizeof (tmp) - 1))
- {
- if (PackageTypeDefaultMolTypeIsDNA (seqPackage))
- {
- ApplyOneModToSeqEntry (sep, "moltype", "Genomic DNA");
- }
- else
- {
- ApplyOneModToSeqEntry (sep, "moltype", "Genomic RNA");
- }
- }
- ttl = NULL;
- SeqEntryExplore (sep, (Pointer) (&ttl), FindFirstTitle);
- if (!LookForSearchString (ttl, "[topology=", tmp, sizeof (tmp) - 1))
- {
- ApplyOneModToSeqEntry (sep, "topology", "Linear");
- }
- }
-}
-
/* The Sequence Assistant will allow users to paste in FASTA or create sequences one at a time.
* The list control for selecting a sequence to view and edit should be a DocPanel, so that we
* can add and remove sequences without needing to destroy and recreate the dialog.
@@ -12999,7 +13362,7 @@ static ValNodePtr PrepareSequenceAssistantTableData (SequenceAssistantPtr sap)
{
return NULL;
}
- SetDefaultMolTypesAndTopologies (sap->seq_list, sap->seqPackage);
+ SetDefaultMolTypesAndTopologies (sap->seq_list);
/* create header line for table */
/* store max column width in choice */
@@ -13058,14 +13421,7 @@ static ValNodePtr PrepareSequenceAssistantTableData (SequenceAssistantPtr sap)
header_vnp = header_vnp->next;
if (!LookForSearchString (ttl, "[moltype=", tmp, sizeof (tmp) - 1))
{
- if (PackageTypeDefaultMolTypeIsDNA (sap->seqPackage))
- {
- sprintf (tmp, "Genomic DNA");
- }
- else
- {
- sprintf (tmp, "Genomic RNA");
- }
+ sprintf (tmp, "Genomic DNA");
}
column_width = MAX (StringLen (tmp), header_vnp->choice);
column_width = MIN (column_width, max_column_width);
@@ -13202,184 +13558,252 @@ static Boolean
IsDuplicateID (SeqEntryPtr seq_list, BioseqPtr edit_bsp, SeqIdPtr sip);
static Uint2 idedit_types [] = {
- TAGLIST_PROMPT, TAGLIST_TEXT, TAGLIST_TEXT
+ TAGLIST_PROMPT, TAGLIST_PROMPT, TAGLIST_TEXT, TAGLIST_TEXT
};
static Uint2 idedit_widths [] = {
- 4, 10, 40,
+ 6, 5, 10, 40,
};
-typedef struct seqedittag
-{
- ValNodePtr current_list;
- ValNodePtr new_list;
-} SeqEditTagData, PNTR SeqEditTagPtr;
-
-static void
-AddSeqInfoToTagListData
-(SeqEntryPtr list,
- SeqEntryPtr current_list,
- SeqEntryPtr new_list,
- Int4Ptr pnum_sequences,
- ValNodePtr PNTR taglist_data)
+static Int4 CountSequencesAndSegments (SeqEntryPtr list)
{
- SeqEntryPtr sep;
- Char id_str [128];
- CharPtr title_txt;
- BioseqPtr bsp;
- BioseqSetPtr bssp;
- Int4 num_sequences = 0;
- SeqDescrPtr sdp;
- Boolean is_dup;
- CharPtr str;
- Int4 len;
-
- if (taglist_data == NULL)
- {
- return;
- }
+ Int4 num_seqs = 0;
+ BioseqSetPtr bssp;
- /* collect current IDs and titles */
- for (sep = list; sep != NULL; sep = sep->next)
+ while (list != NULL)
{
- if (sep->data.ptrvalue == NULL)
- {
- continue;
- }
- else if (IS_Bioseq (sep))
+ if (list->data.ptrvalue != NULL)
{
- bsp = (BioseqPtr) sep->data.ptrvalue;
- /* collect ID */
- SeqIdWrite (bsp->id, id_str, PRINTID_REPORT, sizeof (id_str) - 1);
- /* collect title */
- title_txt = NULL;
- sdp = bsp->descr;
- while (sdp != NULL && sdp->choice != Seq_descr_title)
- {
- sdp = sdp->next;
- }
- if (sdp != NULL)
+ if (IS_Bioseq (list))
{
- title_txt = sdp->data.ptrvalue;
+ num_seqs ++;
}
- /* determine whether this is a duplicate */
- is_dup = IsDuplicateID (current_list, NULL, bsp->id)
- || IsDuplicateID (new_list, bsp, bsp->id);
-
- len = StringLen (id_str) + StringLen (title_txt);
- str = MemNew (len + 9);
- if (str != NULL)
+ else if (IS_Bioseq_set (list))
{
- sprintf (str, "%s\t%s\t%s\n",
- is_dup ? "DUP" : "",
- id_str,
- title_txt == NULL ? "" : title_txt);
- ValNodeAddPointer (taglist_data, 0, str);
+ bssp = (BioseqSetPtr) list->data.ptrvalue;
+ num_seqs += CountSequencesAndSegments (bssp->seq_set);
}
- num_sequences ++;
- }
- else if (IS_Bioseq_set (sep))
- {
- bssp = (BioseqSetPtr) sep->data.ptrvalue;
- AddSeqInfoToTagListData (bssp->seq_set, current_list, new_list,
- &num_sequences, taglist_data);
}
+ list = list->next;
}
- if (pnum_sequences != NULL)
+ return num_seqs;
+}
+
+static BioseqPtr FindNthSequenceInSet (SeqEntryPtr seq_list, Int4 nth)
+{
+ Int4 pos = 0;
+ BioseqPtr bsp = NULL;
+ BioseqSetPtr bssp;
+ SeqEntryPtr sep;
+
+ while (seq_list != NULL && bsp == NULL)
{
- *pnum_sequences += num_sequences;
+ if (seq_list->data.ptrvalue != NULL)
+ {
+ if (IS_Bioseq (seq_list))
+ {
+ if (nth == pos)
+ {
+ bsp = seq_list->data.ptrvalue;
+ }
+ else
+ {
+ pos ++;
+ }
+ }
+ else if (IS_Bioseq_set (seq_list))
+ {
+ bssp = (BioseqSetPtr) seq_list->data.ptrvalue;
+ sep = bssp->seq_set;
+ while (sep != NULL && bsp == NULL)
+ {
+ bsp = FindNthSequenceInSet (sep, nth - pos);
+ if (bsp == NULL)
+ {
+ if (IS_Bioseq_set (sep))
+ {
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ pos += CountSequencesAndSegments (bssp->seq_set);
+ }
+ else if (IS_Bioseq (sep))
+ {
+ pos ++;
+ }
+ }
+ sep = sep->next;
+ }
+ }
+ }
+ seq_list = seq_list->next;
}
+ return bsp;
}
-static void SeqListToTagListDialog (DialoG d, Pointer userdata)
+static void
+SetSeqListInTagListDialog
+(DialoG d,
+ SeqEntryPtr new_list,
+ SeqEntryPtr current_list,
+ Boolean show_all)
{
TagListPtr tlp;
- SeqEditTagPtr setp;
- Int4 num_sequences = 0;
+ Int4 num_sequences = 0, total_sequences, seq_num;
ValNodePtr taglist_data = NULL;
+ Boolean is_dup;
+ BioseqPtr bsp;
+ Char id_str [128];
+ CharPtr title_txt;
+ SeqDescrPtr sdp;
+ CharPtr str;
+ Int4 len;
+ Int4 row_to_hide, row_to_show;
tlp = (TagListPtr) GetObjectExtra (d);
- setp = (SeqEditTagPtr) userdata;
- if (tlp == NULL || setp == NULL || setp->new_list == NULL)
+ if (tlp == NULL || new_list == NULL)
{
return;
}
/* collect current IDs and titles */
- AddSeqInfoToTagListData (setp->new_list, setp->current_list, setp->new_list,
- &num_sequences, &taglist_data);
+ total_sequences = CountSequencesAndSegments (new_list);
+ for (seq_num = 0; seq_num < total_sequences; seq_num++)
+ {
+ bsp = FindNthSequenceInSet (new_list, seq_num);
+ if (bsp == NULL)
+ {
+ continue;
+ }
+
+ /* determine whether this is a duplicate */
+ is_dup = IsDuplicateID (current_list, NULL, bsp->id)
+ || IsDuplicateID (new_list, bsp, bsp->id);
+ if (!is_dup && ! show_all)
+ {
+ continue;
+ }
+ /* collect ID */
+ SeqIdWrite (bsp->id, id_str, PRINTID_REPORT, sizeof (id_str) - 1);
+ /* collect title */
+ title_txt = NULL;
+ sdp = bsp->descr;
+ while (sdp != NULL && sdp->choice != Seq_descr_title)
+ {
+ sdp = sdp->next;
+ }
+ if (sdp != NULL)
+ {
+ title_txt = sdp->data.ptrvalue;
+ }
+ /* determine whether this is a duplicate */
+ is_dup = IsDuplicateID (current_list, NULL, bsp->id)
+ || IsDuplicateID (new_list, bsp, bsp->id);
+
+ len = StringLen (id_str) + StringLen (title_txt);
+ str = MemNew (len + 18);
+ if (str != NULL)
+ {
+ sprintf (str, "%s\t%d\t%s\t%s\n",
+ is_dup ? "Duplicate ID" : "",
+ seq_num + 1,
+ id_str,
+ title_txt == NULL ? "" : title_txt);
+ ValNodeAddPointer (&taglist_data, 0, StringSave (str));
+ }
+ num_sequences ++;
+ }
+
SendMessageToDialog (tlp->dialog, VIB_MSG_RESET);
tlp->vnp = taglist_data;
SendMessageToDialog (tlp->dialog, VIB_MSG_REDRAW);
tlp->max = MAX ((Int2) 0, (Int2) (num_sequences - tlp->rows));
CorrectBarMax (tlp->bar, tlp->max);
CorrectBarPage (tlp->bar, tlp->rows - 1, tlp->rows - 1);
+ for (row_to_show = 0; row_to_show < MIN (num_sequences, tlp->rows); row_to_show ++)
+ {
+ SafeShow (tlp->control [row_to_show * MAX_TAGLIST_COLS + 2]);
+ SafeShow (tlp->control [row_to_show * MAX_TAGLIST_COLS + 3]);
+ }
if (tlp->max > 0) {
SafeShow (tlp->bar);
} else {
SafeHide (tlp->bar);
+ for (row_to_hide = num_sequences; row_to_hide < tlp->rows; row_to_hide ++)
+ {
+ SafeHide (tlp->control [row_to_hide * MAX_TAGLIST_COLS + 2]);
+ SafeHide (tlp->control [row_to_hide * MAX_TAGLIST_COLS + 3]);
+ }
}
}
-static void CollectIdAndTitleFromDialog (TagListPtr tlp, SeqEntryPtr sep, Int4Ptr seq_num)
+static void CollectIdAndTitleFromDialog (TagListPtr tlp, SeqEntryPtr sep)
{
BioseqPtr bsp;
- BioseqSetPtr bssp;
CharPtr str;
SeqDescrPtr sdp;
SeqIdPtr new_sip;
+ Int4 num_rows, row_num, seq_pos;
- if (tlp == NULL || sep == NULL || seq_num == NULL)
+ if (tlp == NULL || sep == NULL)
{
return;
}
-
- if (sep->data.ptrvalue != NULL)
+
+ num_rows = ValNodeLen (tlp->vnp);
+ for (row_num = 0; row_num < num_rows; row_num++)
{
- if (IS_Bioseq (sep))
+ /* get position for this sequence */
+ str = GetTagListValueEx (tlp, row_num, 1);
+ seq_pos = atoi (str);
+ if (seq_pos < 1)
{
- bsp = (BioseqPtr) sep->data.ptrvalue;
- /* collect ID */
- str = GetTagListValueEx (tlp, *seq_num, 1);
- new_sip = MakeSeqID (str);
- str = MemFree (str);
- if (new_sip != NULL)
- {
- if (bsp->id != NULL)
- {
- new_sip->next = bsp->id->next;
- bsp->id->next = NULL;
- bsp->id = SeqIdFree (bsp->id);
- }
- bsp->id = new_sip;
- }
- /* collect title */
- str = GetTagListValueEx (tlp, *seq_num, 2);
- sdp = bsp->descr;
- while (sdp != NULL && sdp->choice != Seq_descr_title)
- {
- sdp = sdp->next;
- }
- if (sdp == NULL)
- {
- sdp = CreateNewDescriptor (sep, Seq_descr_title);
- sdp->data.ptrvalue = str;
- }
- else
+ continue;
+ }
+ seq_pos --;
+ bsp = FindNthSequenceInSet (sep, seq_pos);
+ if (bsp == NULL)
+ {
+ continue;
+ }
+ /* collect ID */
+ str = GetTagListValueEx (tlp, row_num, 2);
+ new_sip = MakeSeqID (str);
+ str = MemFree (str);
+ if (new_sip != NULL)
+ {
+ if (bsp->id != NULL)
{
- sdp->data.ptrvalue = MemFree (sdp->data.ptrvalue);
- sdp->data.ptrvalue = str;
+ new_sip->next = bsp->id->next;
+ bsp->id->next = NULL;
+ bsp->id = SeqIdFree (bsp->id);
}
- (*seq_num)++;
+ bsp->id = new_sip;
+ SeqMgrReplaceInBioseqIndex(bsp);
}
- else if (IS_Bioseq_set (sep))
+ else
{
- bssp = (BioseqSetPtr) sep->data.ptrvalue;
- CollectIdAndTitleFromDialog (tlp, bssp->seq_set, seq_num);
+ bsp->id = SeqIdFree (bsp->id);
+ }
+
+ /* collect title */
+ str = GetTagListValueEx (tlp, row_num, 3);
+ sdp = bsp->descr;
+ while (sdp != NULL && sdp->choice != Seq_descr_title)
+ {
+ sdp = sdp->next;
+ }
+ if (sdp == NULL)
+ {
+ sdp = CreateNewDescriptor (sep, Seq_descr_title);
+ sdp->data.ptrvalue = str;
+ }
+ else
+ {
+ sdp->data.ptrvalue = MemFree (sdp->data.ptrvalue);
+ sdp->data.ptrvalue = str;
}
}
- CollectIdAndTitleFromDialog (tlp, sep->next, seq_num);
+
}
@@ -13437,9 +13861,9 @@ static Boolean FixDefinitionLinesInAddSequence (SeqEntryPtr sep_list)
}
}
-static Boolean IDsNeedFix (SeqEntryPtr list, SeqEntryPtr current_list)
+static Boolean HasBlankIDs (SeqEntryPtr list)
{
- Boolean need_fix = FALSE;
+ Boolean has_blank = FALSE;
BioseqPtr bsp;
BioseqSetPtr bssp;
SeqEntryPtr sep;
@@ -13449,7 +13873,7 @@ static Boolean IDsNeedFix (SeqEntryPtr list, SeqEntryPtr current_list)
return FALSE;
}
/* check for unique IDs or missing IDs */
- for (sep = list; sep != NULL && ! need_fix; sep = sep->next)
+ for (sep = list; sep != NULL && ! has_blank; sep = sep->next)
{
if (sep->data.ptrvalue == NULL)
{
@@ -13458,55 +13882,495 @@ static Boolean IDsNeedFix (SeqEntryPtr list, SeqEntryPtr current_list)
else if (IS_Bioseq (sep))
{
bsp = (BioseqPtr) sep->data.ptrvalue;
- need_fix = bsp->id == NULL
- || IsDuplicateID (current_list, NULL, bsp->id)
- || IsDuplicateID (list, bsp, bsp->id);
+ if (bsp->id == NULL)
+ {
+ has_blank = TRUE;
+ }
}
else if (IS_Bioseq_set (sep))
{
bssp = (BioseqSetPtr) sep->data.ptrvalue;
- need_fix |= IDsNeedFix (bssp->seq_set, current_list);
+ has_blank |= HasBlankIDs (bssp->seq_set);
}
}
+ return has_blank;
+}
+
+static Boolean HasDuplicateIDs (SeqEntryPtr list, SeqEntryPtr current_list)
+{
+ Boolean has_dup = FALSE;
+ BioseqPtr bsp;
+ Int4 this_num, num_this_list;
+
+ if (list == NULL)
+ {
+ return FALSE;
+ }
+
+ /* check for unique IDs or missing IDs */
+
+ num_this_list = CountSequencesAndSegments (list);
+ for (this_num = 0; this_num < num_this_list && ! has_dup; this_num++)
+ {
+ bsp = FindNthSequenceInSet (list, this_num);
+ if (bsp != NULL)
+ {
+ has_dup |= IsDuplicateID (current_list, NULL, bsp->id)
+ || IsDuplicateID (list, bsp, bsp->id);
+ }
+ }
+ return has_dup;
+}
+
+static Boolean IDsNeedFix (SeqEntryPtr list, SeqEntryPtr current_list)
+{
+ Boolean need_fix = FALSE;
+ BioseqPtr bsp;
+ Int4 this_num, num_this_list;
+
+ if (list == NULL)
+ {
+ return FALSE;
+ }
+
+ /* check for unique IDs or missing IDs */
+
+ num_this_list = CountSequencesAndSegments (list);
+ for (this_num = 0; this_num < num_this_list && ! need_fix; this_num++)
+ {
+ bsp = FindNthSequenceInSet (list, this_num);
+ need_fix |= (bsp->id == NULL)
+ || IsDuplicateID (current_list, NULL, bsp->id)
+ || IsDuplicateID (list, bsp, bsp->id);
+ }
return need_fix;
}
-static Int4 CountSequencesAndSegments (SeqEntryPtr list)
+static void
+FindExtraTextForLocalIDs
+(SeqEntryPtr list,
+ ValNodePtr PNTR extended_ids,
+ ValNodePtr PNTR sep_for_ids)
{
- Int4 num_seqs = 0;
+ Boolean has_spaces = FALSE;
+ SeqEntryPtr sep;
+ BioseqPtr bsp;
BioseqSetPtr bssp;
+ SeqDescrPtr sdp;
+ CharPtr title, add_str;
+ Int4 len, add_str_len;
+ ObjectIdPtr oip;
+ SeqIdPtr new_sip;
- while (list != NULL)
+ if (list == NULL || extended_ids == NULL || sep_for_ids == NULL)
{
- if (list->data.ptrvalue != NULL)
+ return;
+ }
+ /* check for unique IDs or missing IDs */
+ for (sep = list; sep != NULL; sep = sep->next)
+ {
+ if (sep->data.ptrvalue == NULL)
{
- if (IS_Bioseq (list))
+ /* do nothing */
+ }
+ else if (IS_Bioseq (sep))
+ {
+ bsp = (BioseqPtr) sep->data.ptrvalue;
+ sdp = bsp->descr;
+ while (sdp != NULL
+ && (sdp->choice != Seq_descr_title
+ || StringHasNoText (sdp->data.ptrvalue)))
{
- num_seqs ++;
+ sdp = sdp->next;
}
- else if (IS_Bioseq_set (list))
+ title = NULL;
+ if (sdp != NULL)
{
- bssp = (BioseqSetPtr) list->data.ptrvalue;
- num_seqs += CountSequencesAndSegments (bssp->seq_set);
+ title = sdp->data.ptrvalue;
+ }
+ if (bsp->id != NULL
+ && IsDuplicateID (list, bsp, bsp->id)
+ && bsp->id->choice == SEQID_LOCAL
+ && (oip = bsp->id->data.ptrvalue) != NULL
+ && ! StringHasNoText (oip->str)
+ && title != NULL
+ && title [0] != '[')
+ {
+ len = StringCSpn (title, " \t[]");
+ if (len > 0)
+ {
+ add_str_len = len + StringLen (oip->str);
+ add_str = (CharPtr) MemNew ((add_str_len + 1) * sizeof (Char));
+ if (add_str != NULL)
+ {
+ StringCpy (add_str, oip->str);
+ StringNCat (add_str, title, len);
+ add_str [add_str_len] = 0;
+ new_sip = MakeSeqID (add_str);
+ ValNodeAddPointer (extended_ids, 0, new_sip);
+ ValNodeAddPointer (sep_for_ids, 0, sep);
+ add_str = MemFree (add_str);
+ }
+ }
}
}
- list = list->next;
+ else if (IS_Bioseq_set (sep))
+ {
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ FindExtraTextForLocalIDs (bssp->seq_set, extended_ids, sep_for_ids);
+ }
+ }
+}
+
+static ParData idParFmt = {FALSE, FALSE, FALSE, FALSE, FALSE, 0, 0};
+static ColData idColFmt[] =
+ {
+ {0, 0, 40, 0, NULL, 'l', TRUE, FALSE, FALSE, FALSE, FALSE},
+ {0, 0, 40, 0, NULL, 'l', TRUE, FALSE, FALSE, FALSE, TRUE}
+ };
+
+static void AddIDStatement (ValNodePtr id_vnp, ValNodePtr seq_vnp, DoC doc)
+{
+ CharPtr doc_txt;
+ CharPtr doc_txt_fmt = "%s\t%s %s\n";
+ ObjectIdPtr oip_old, oip_new;
+ SeqEntryPtr sep;
+ BioseqPtr bsp;
+ SeqDescrPtr sdp;
+ SeqIdPtr sip;
+ Int4 len;
+
+ if (id_vnp == NULL || id_vnp->data.ptrvalue == NULL
+ || seq_vnp == NULL || seq_vnp->data.ptrvalue == NULL)
+ {
+ return;
+ }
+
+ sip = (SeqIdPtr) id_vnp->data.ptrvalue;
+ if (sip->choice != SEQID_LOCAL || sip->data.ptrvalue == NULL)
+ {
+ return;
+ }
+ oip_new = (ObjectIdPtr) sip->data.ptrvalue;
+ if (StringHasNoText (oip_new->str))
+ {
+ return;
+ }
+
+ sep = (SeqEntryPtr) seq_vnp->data.ptrvalue;
+ if (!IS_Bioseq (sep))
+ {
+ return;
+ }
+
+ bsp = (BioseqPtr) sep->data.ptrvalue;
+
+ if (bsp->id == NULL || bsp->id->choice != SEQID_LOCAL || bsp->id->data.ptrvalue == NULL)
+ {
+ return;
+ }
+
+ oip_old = bsp->id->data.ptrvalue;
+ if (StringHasNoText (oip_old->str))
+ {
+ return;
+ }
+
+ len = StringLen (oip_old->str);
+ if (StringNCmp (oip_old->str, oip_new->str, len) != 0)
+ {
+ return;
+ }
+
+ sdp = bsp->descr;
+ while (sdp != NULL
+ && (sdp->choice != Seq_descr_title
+ || StringHasNoText (sdp->data.ptrvalue)))
+ {
+ sdp = sdp->next;
+ }
+ if (sdp == NULL)
+ {
+ return;
+ }
+
+ len = StringLen (doc_txt_fmt)
+ + StringLen (oip_new->str)
+ + StringLen (oip_old->str)
+ + StringLen (sdp->data.ptrvalue);
+ doc_txt = (CharPtr) MemNew (len * sizeof (Char));
+ if (doc_txt != NULL)
+ {
+ sprintf (doc_txt, doc_txt_fmt, oip_new->str, oip_old->str, sdp->data.ptrvalue);
+ AppendText (doc, doc_txt, &idParFmt, idColFmt, programFont);
+ doc_txt = MemFree (doc_txt);
+ }
+}
+
+
+static void FixOneSequenceIDWithSpaces (ValNodePtr id_vnp, ValNodePtr seq_vnp)
+{
+ ObjectIdPtr oip_old, oip_new;
+ SeqEntryPtr sep;
+ BioseqPtr bsp;
+ SeqDescrPtr sdp;
+ SeqIdPtr sip;
+ Int4 len_old, len_new, def_offset;
+ CharPtr defline, new_defline;
+
+ if (id_vnp == NULL || id_vnp->data.ptrvalue == NULL
+ || seq_vnp == NULL || seq_vnp->data.ptrvalue == NULL)
+ {
+ return;
+ }
+
+ sip = (SeqIdPtr) id_vnp->data.ptrvalue;
+ if (sip->choice != SEQID_LOCAL || sip->data.ptrvalue == NULL)
+ {
+ return;
+ }
+ oip_new = (ObjectIdPtr) sip->data.ptrvalue;
+ if (StringHasNoText (oip_new->str))
+ {
+ return;
+ }
+
+ sep = (SeqEntryPtr) seq_vnp->data.ptrvalue;
+ if (!IS_Bioseq (sep))
+ {
+ return;
+ }
+ bsp = (BioseqPtr) sep->data.ptrvalue;
+
+ if (bsp->id == NULL || bsp->id->choice != SEQID_LOCAL || bsp->id->data.ptrvalue == NULL)
+ {
+ return;
+ }
+
+ oip_old = bsp->id->data.ptrvalue;
+ if (StringHasNoText (oip_old->str))
+ {
+ return;
+ }
+
+ len_old = StringLen (oip_old->str);
+ if (StringNCmp (oip_old->str, oip_new->str, len_old) != 0)
+ {
+ return;
+ }
+
+ sdp = bsp->descr;
+ while (sdp != NULL
+ && (sdp->choice != Seq_descr_title
+ || StringHasNoText (sdp->data.ptrvalue)))
+ {
+ sdp = sdp->next;
+ }
+ if (sdp == NULL)
+ {
+ return;
+ }
+
+ defline = (CharPtr) sdp->data.ptrvalue;
+
+ len_new = StringLen (oip_new->str);
+ def_offset = len_new - len_old - 1;
+ if (def_offset > 0 && StringNCmp (oip_new->str + len_old + 1, defline, def_offset) == 0)
+ {
+ if (*(defline + def_offset) == 0)
+ {
+ new_defline = StringSave ("");
+ }
+ else
+ {
+ new_defline = StringSave (defline + def_offset + StringSpn (defline + def_offset, " \t"));
+ }
+ sdp->data.ptrvalue = MemFree (sdp->data.ptrvalue);
+ sdp->data.ptrvalue = new_defline;
+ }
+
+ sip->next = bsp->id->next;
+ bsp->id->next = NULL;
+ /* put old ID in list to be freed later */
+ id_vnp->data.ptrvalue = bsp->id;
+ /* put new ID on Bioseq */
+ bsp->id = sip;
+}
+
+static void FixSpacesInLocalIDs (SeqEntryPtr list)
+{
+ ValNodePtr extended_ids = NULL, sep_for_ids = NULL;
+ WindoW w;
+ GrouP h, c;
+ ButtoN b;
+ DoC doc;
+ ModalAcceptCancelData acd;
+ ValNodePtr id_vnp, seq_vnp;
+ RecT r;
+
+ if (list == NULL)
+ {
+ return;
+ }
+
+ FindExtraTextForLocalIDs (list, &extended_ids, &sep_for_ids);
+
+ if (extended_ids != NULL && sep_for_ids != NULL)
+ {
+ w = MovableModalWindow (-20, -13, -10, -10, "Spaces in Sequence IDs", NULL);
+ h = HiddenGroup(w, -1, 0, NULL);
+ SetGroupSpacing (h, 10, 10);
+
+ doc = DocumentPanel (h, stdCharWidth * 27, stdLineHeight * 12);
+ SetDocAutoAdjust (doc, TRUE);
+ AppendText (doc, "Your sequence IDs are not unique. Did you try to put spaces in your sequence IDs? This is not allowed.\n\n", NULL, NULL, programFont);
+
+ ObjectRect (doc, &r);
+ InsetRect (&r, 4, 4);
+ idColFmt[0].pixWidth = (r.right - r.left) / 2;
+ idColFmt[1].pixWidth = (r.right - r.left) / 2;
+
+
+ AppendText (doc, "Corrected ID\tOriginal Description\n", &idParFmt, idColFmt, programFont);
+
+ for (id_vnp = extended_ids, seq_vnp = sep_for_ids;
+ id_vnp != NULL && seq_vnp != NULL;
+ id_vnp = id_vnp->next, seq_vnp = seq_vnp->next)
+ {
+ AddIDStatement (id_vnp, seq_vnp, doc);
+ }
+
+ c = HiddenGroup (h, 2, 0, NULL);
+ b = PushButton (c, "Make automatic corrections", ModalAcceptButton);
+ SetObjectExtra (b, &acd, NULL);
+ b = PushButton (c, "Allow manual corrections", ModalCancelButton);
+ SetObjectExtra (b, &acd, NULL);
+
+ AlignObjects (ALIGN_CENTER, (HANDLE) doc, (HANDLE) c, (HANDLE) NULL);
+
+ Show (w);
+ Select (w);
+
+ acd.cancelled = FALSE;
+ acd.accepted = FALSE;
+ while (!acd.accepted && ! acd.cancelled)
+ {
+ ProcessExternalEvent ();
+ Update ();
+ }
+ ProcessAnEvent ();
+ if (! acd.cancelled)
+ {
+ for (id_vnp = extended_ids, seq_vnp = sep_for_ids;
+ id_vnp != NULL && seq_vnp != NULL;
+ id_vnp = id_vnp->next, seq_vnp = seq_vnp->next)
+ {
+ FixOneSequenceIDWithSpaces (id_vnp, seq_vnp);
+ }
+ ResetSegSetIDLists (list);
+ }
+ Remove (w);
}
- return num_seqs;
+}
+
+typedef struct seqidedit
+{
+ SeqEntryPtr new_list;
+ SeqEntryPtr current_list;
+ DialoG dlg;
+ PrompT p_instr[3];
+} SeqIdEditData, PNTR SeqIdEditPtr;
+
+static void ShowErrorInstructions (Pointer userdata)
+{
+ Int4 i = 0;
+ SeqIdEditPtr siep;
+ TagListPtr tlp;
+
+ siep = (SeqIdEditPtr) userdata;
+ if (siep == NULL)
+ {
+ return;
+ }
+
+ tlp = (TagListPtr) GetObjectExtra (siep->dlg);
+ if (tlp != NULL)
+ {
+ CollectIdAndTitleFromDialog (tlp, siep->new_list);
+ }
+
+ if (HasBlankIDs (siep->new_list))
+ {
+ SetTitle (siep->p_instr [i++], "Some of your sequences lack sequence IDs.");
+ }
+
+ if (HasDuplicateIDs (siep->new_list, siep->current_list))
+ {
+ SetTitle (siep->p_instr [i++], "Some of your sequence IDs are duplicated.");
+ }
+
+ if (i == 0)
+ {
+ SetTitle (siep->p_instr [i++], "Sequence ID errors have been corrected.");
+ }
+ else
+ {
+ SetTitle (siep->p_instr [i++], "Please provide unique sequence IDs for every sequence.");
+ }
+ while (i < 3)
+ {
+ SetTitle (siep->p_instr [i++], "");
+ }
+}
+
+static void ShowAllSequences (ButtoN b)
+{
+ SeqIdEditPtr siep;
+ Boolean show_all;
+ TagListPtr tlp;
+
+ siep = (SeqIdEditPtr) GetObjectExtra (b);
+ if (siep == NULL || siep->dlg == NULL || siep->new_list == NULL)
+ {
+ return;
+ }
+
+ tlp = (TagListPtr) GetObjectExtra (siep->dlg);
+ if (tlp == NULL)
+ {
+ return;
+ }
+
+ show_all = HasBlankIDs (siep->new_list);
+ show_all |= GetStatus (b);
+
+ CollectIdAndTitleFromDialog (tlp, siep->new_list);
+ SetSeqListInTagListDialog (siep->dlg, siep->new_list, siep->current_list, show_all);
+ ShowErrorInstructions (siep);
}
static Boolean CollectIDsAndTitles (SeqEntryPtr new_list, SeqEntryPtr current_list)
{
WindoW w;
- GrouP h, ppt, c;
+ GrouP h, ppt, instr_grp, c;
ButtoN b;
- Int4 num_sequences = 0, seq_num;
+ Int4 num_sequences = 0;
BoolPtr is_dup_list = NULL;
Boolean need_fix = FALSE;
DialoG dlg;
TagListPtr tlp;
ModalAcceptCancelData acd;
- SeqEditTagData setd;
+ PrompT p1, p2, p3, p4;
+ Boolean show_all;
+ ButtoN force_all_btn;
+ SeqIdEditData sied;
+ TaglistCallback callback_list[4] =
+ { ShowErrorInstructions, ShowErrorInstructions, ShowErrorInstructions, ShowErrorInstructions };
+
+ ArrowCursor ();
+
+ /* look for spaces in local IDs */
+ FixSpacesInLocalIDs (new_list);
/* check for unique IDs - don't need to present dialog if they
* are all present and unique */
@@ -13519,33 +14383,61 @@ static Boolean CollectIDsAndTitles (SeqEntryPtr new_list, SeqEntryPtr current_li
}
num_sequences = CountSequencesAndSegments (new_list);
- setd.current_list = current_list;
- setd.new_list = new_list;
+ show_all = HasBlankIDs (new_list);
w = MovableModalWindow (-20, -13, -10, -10, "Provide Sequence IDs for your Sequences", NULL);
h = HiddenGroup(w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
- ppt = HiddenGroup (h, 3, 0, NULL);
- StaticPrompt (ppt, "", 4 * stdCharWidth, 0, programFont, 'l');
- StaticPrompt (ppt, "Sequence ID", 10 * stdCharWidth, 0, programFont, 'l');
- StaticPrompt (ppt, "Description", 40 * stdCharWidth, 0, programFont, 'l');
+ instr_grp = HiddenGroup (h, -1, 0, NULL);
+ sied.p_instr [0] = StaticPrompt (instr_grp, "", 40 * stdCharWidth, 0, programFont, 'l');
+ sied.p_instr [1] = StaticPrompt (instr_grp, "", 40 * stdCharWidth, 0, programFont, 'l');
+ sied.p_instr [2] = StaticPrompt (instr_grp, "", 40 * stdCharWidth, 0, programFont, 'l');
- dlg = CreateTagListDialogEx (h, MIN (num_sequences, 8), 3, 2,
- idedit_types, idedit_widths,
- NULL, TRUE, TRUE, SeqListToTagListDialog, NULL);
- PointerToDialog (dlg, &setd);
+ ppt = HiddenGroup (h, 4, 0, NULL);
+ p1 = StaticPrompt (ppt, "", 6 * stdCharWidth, 0, programFont, 'l');
+ p2 = StaticPrompt (ppt, "Position", 5 * stdCharWidth, 0, programFont, 'l');
+ p3 = StaticPrompt (ppt, "Sequence ID", 10 * stdCharWidth, 0, programFont, 'l');
+ p4 = StaticPrompt (ppt, "Description", 40 * stdCharWidth, 0, programFont, 'l');
+ dlg = CreateTagListDialogExEx (h, MIN (num_sequences, 8), 4, 2,
+ idedit_types, idedit_widths,
+ NULL, TRUE, TRUE, NULL, NULL,
+ callback_list, &sied);
+
+
tlp = (TagListPtr) GetObjectExtra (dlg);
if (tlp == NULL) return;
+
+ sied.dlg = dlg;
+ sied.new_list = new_list;
+ sied.current_list = current_list;
+ SetSeqListInTagListDialog (dlg, new_list, current_list, show_all);
+ ShowErrorInstructions (&sied);
+
+ force_all_btn = CheckBox (h, "Show all sequences in set", ShowAllSequences);
+ SetObjectExtra (force_all_btn, &sied, NULL);
+ if (show_all)
+ {
+ Disable (force_all_btn);
+ }
+ else
+ {
+ Enable (force_all_btn);
+ }
+
c = HiddenGroup (h, 2, 0, NULL);
b = PushButton (c, "Accept", ModalAcceptButton);
SetObjectExtra (b, &acd, NULL);
b = PushButton (c, "Cancel", ModalCancelButton);
SetObjectExtra (b, &acd, NULL);
- AlignObjects (ALIGN_CENTER, (HANDLE) ppt, (HANDLE) dlg, (HANDLE) c, (HANDLE) NULL);
+ AlignObjects (ALIGN_CENTER, (HANDLE) instr_grp, (HANDLE) dlg, (HANDLE) force_all_btn, (HANDLE) c, NULL);
+ AlignObjects (ALIGN_JUSTIFY, (HANDLE) tlp->control [0], (HANDLE) p1, NULL);
+ AlignObjects (ALIGN_JUSTIFY, (HANDLE) tlp->control [1], (HANDLE) p2, NULL);
+ AlignObjects (ALIGN_JUSTIFY, (HANDLE) tlp->control [2], (HANDLE) p3, NULL);
+ AlignObjects (ALIGN_JUSTIFY, (HANDLE) tlp->control [3], (HANDLE) p4, NULL);
Show (w);
Select (w);
@@ -13562,15 +14454,25 @@ static Boolean CollectIDsAndTitles (SeqEntryPtr new_list, SeqEntryPtr current_li
ProcessAnEvent ();
if (! acd.cancelled)
{
- seq_num = 0;
- CollectIdAndTitleFromDialog (tlp, new_list, &seq_num);
+ CollectIdAndTitleFromDialog (tlp, new_list);
/* now check for unique IDs */
need_fix = IDsNeedFix (new_list, current_list);
if (need_fix)
{
Message (MSG_ERROR, "Blank or Duplicate IDs are not allowed!");
- PointerToDialog (dlg, &setd);
+ show_all = HasBlankIDs (new_list);
+ if (show_all)
+ {
+ Disable (force_all_btn);
+ }
+ else
+ {
+ Enable (force_all_btn);
+ show_all = GetStatus (force_all_btn);
+ }
+ SetSeqListInTagListDialog (dlg, new_list, current_list, show_all);
+ ShowErrorInstructions (&sied);
}
else if (! FixDefinitionLinesInAddSequence (new_list))
{
@@ -13579,7 +14481,18 @@ static Boolean CollectIDsAndTitles (SeqEntryPtr new_list, SeqEntryPtr current_li
if (need_fix)
{
- PointerToDialog (dlg, &setd);
+ show_all = HasBlankIDs (new_list);
+ if (show_all)
+ {
+ Disable (force_all_btn);
+ }
+ else
+ {
+ Enable (force_all_btn);
+ show_all = GetStatus (force_all_btn);
+ }
+ SetSeqListInTagListDialog (dlg, new_list, current_list, show_all);
+ ShowErrorInstructions (&sied);
}
}
}
@@ -13600,6 +14513,7 @@ static void ReplaceFakeIDWithIDFromTitle (BioseqPtr bsp)
SeqDescrPtr sdp;
CharPtr title_txt, new_id_str;
Int4 id_len;
+ Boolean remove_punct = FALSE;
if (bsp == NULL)
{
@@ -13618,7 +14532,38 @@ static void ReplaceFakeIDWithIDFromTitle (BioseqPtr bsp)
title_txt = sdp->data.ptrvalue;
/* skip any leading spaces */
title_txt += StringSpn (title_txt, " \t");
- id_len = StringCSpn (title_txt, " \t");
+ /* look for local IDs surrounded by quotes - the real way to have an ID with a space */
+ if (*title_txt == '\'')
+ {
+ title_txt ++;
+ id_len = StringCSpn (title_txt, "\'");
+ if (title_txt [id_len] == '\'')
+ {
+ remove_punct = TRUE;
+ }
+ else
+ {
+ id_len = 0;
+ }
+ }
+ else if (*title_txt == '\"')
+ {
+ title_txt ++;
+ id_len = StringCSpn (title_txt, "\"");
+ if (title_txt [id_len] == '\"')
+ {
+ remove_punct = TRUE;
+ }
+ else
+ {
+ id_len = 0;
+ }
+ }
+ else
+ {
+ id_len = StringCSpn (title_txt, " \t");
+ }
+
if (id_len > 0)
{
new_id_str = (CharPtr) MemNew ((id_len + 1) * sizeof (Char));
@@ -13630,6 +14575,10 @@ static void ReplaceFakeIDWithIDFromTitle (BioseqPtr bsp)
new_id_str = MemFree (new_id_str);
/* remove id from title */
title_txt += id_len;
+ if (remove_punct)
+ {
+ title_txt ++;
+ }
title_txt += StringSpn (title_txt, " \t");
title_txt = StringSave (title_txt);
sdp->data.ptrvalue = MemFree (sdp->data.ptrvalue);
@@ -13668,7 +14617,8 @@ static SeqEntryPtr GetSequencesFromFile (CharPtr path, SeqEntryPtr current_list)
return NULL;
}
else if (!CollectIDsAndTitles (new_sep_list, current_list))
- {
+ {
+ new_sep = new_sep_list;
while (new_sep != NULL)
{
test_sep = new_sep->next;
@@ -13685,6 +14635,7 @@ static SeqEntryPtr GetSequencesFromFile (CharPtr path, SeqEntryPtr current_list)
if (cancelled)
{
+ new_sep = new_sep_list;
while (new_sep != NULL)
{
test_sep = new_sep->next;
@@ -14032,6 +14983,22 @@ static Boolean CheckBracketingInDefLine (CharPtr PNTR defline, CharPtr id_txt)
return !cancelled;
}
+static void PasteSequenceAssistant (IteM i)
+{
+ TexT txt;
+ CharPtr str;
+
+ txt = (TexT) GetObjectExtra (i);
+ if (txt == NULL)
+ {
+ return;
+ }
+
+ str = ClipboardToString ();
+ SetTitle (txt, str);
+ str = MemFree (str);
+}
+
static void SequenceAssistantAddSequence (SequenceAssistantPtr sap)
{
ModalAcceptCancelData acd;
@@ -14044,11 +15011,13 @@ static void SequenceAssistantAddSequence (SequenceAssistantPtr sap)
Char str [200];
ButtoN b;
SeqEntryPtr last_sep = NULL, new_sep;
- CharPtr errormsg = NULL;
- ValNodePtr err_list = NULL;
- Boolean done = FALSE;
+ CharPtr errormsg = NULL;
+ ValNodePtr err_list = NULL;
+ Boolean done = FALSE;
ByteStorePtr new_bs = NULL;
SeqIdPtr new_sip = NULL;
+ MenU edit_menu;
+ IteM local_item;
if (sap == NULL)
{
@@ -14084,6 +15053,11 @@ static void SequenceAssistantAddSequence (SequenceAssistantPtr sap)
(HANDLE) sequence_grp,
(HANDLE) c,
NULL);
+
+ /* Edit Menu */
+ edit_menu = PulldownMenu (w, "Edit");
+ local_item = CommandItem (edit_menu, "Paste", PasteSequenceAssistant);
+ SetObjectExtra (local_item, sequence_txt, NULL);
Show(w);
Select (w);
@@ -14145,6 +15119,8 @@ static void SequenceAssistantEditSequence (SequenceAssistantPtr sap, Int4 seq_nu
ByteStorePtr new_bs = NULL;
SeqIdPtr new_sip = NULL;
SeqDescrPtr sdp;
+ MenU edit_menu;
+ IteM local_item;
if (sap == NULL)
{
@@ -14173,7 +15149,7 @@ static void SequenceAssistantEditSequence (SequenceAssistantPtr sap, Int4 seq_nu
bsp = sep->data.ptrvalue;
if (bsp->repr == Seq_repr_delta)
{
- Message (MSG_ERROR, "Can't edit delta sequence!");
+ Message (MSG_ERROR, "Can't edit gapped sequence!");
return;
}
sip = SeqIdFindWorst (bsp->id);
@@ -14240,6 +15216,11 @@ static void SequenceAssistantEditSequence (SequenceAssistantPtr sap, Int4 seq_nu
AlignObjects (ALIGN_CENTER, (HANDLE) g1, (HANDLE) g2, (HANDLE) sequence_grp,
(HANDLE) c, NULL);
}
+
+ /* Edit Menu */
+ edit_menu = PulldownMenu (w, "Edit");
+ local_item = CommandItem (edit_menu, "Paste", PasteSequenceAssistant);
+ SetObjectExtra (local_item, sequence_txt, NULL);
Show(w);
Select (w);
@@ -15025,7 +16006,7 @@ static void EditOneSequenceTitle (SequenceAssistantPtr sap, Int4 seq_num)
WindoW w;
CharPtr title = NULL;
BioseqPtr bsp = NULL;
- CharPtr title_fmt = "Title for %s";
+ CharPtr title_fmt = "Description for %s";
Char id_txt [128];
GrouP h, g, c;
ButtoN b;
@@ -15085,8 +16066,8 @@ static void EditOneSequenceTitle (SequenceAssistantPtr sap, Int4 seq_num)
SetGroupSpacing (h, 10, 10);
g = HiddenGroup (h, 2, 0, NULL);
- StaticPrompt (g, "Title", 0, popupMenuHeight, programFont, 'l');
- new_title_txt = DialogText (g, "", 20, NULL);
+ StaticPrompt (g, "Description", 0, popupMenuHeight, programFont, 'l');
+ new_title_txt = DialogText (g, "", 40, NULL);
if (sdp != NULL && !StringHasNoText (sdp->data.ptrvalue))
{
SetTitle (new_title_txt, sdp->data.ptrvalue);
@@ -15342,12 +16323,12 @@ static void EditSequenceTitleColumns (SequenceAssistantPtr sap)
}
rows_shown = MIN (rows_shown, 5);
- w = MovableModalWindow (-20, -13, -10, -10, "Sequence Titles", NULL);
+ w = MovableModalWindow (-20, -13, -10, -10, "Sequence Descriptions", NULL);
h = HiddenGroup(w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
- ppt = StaticPrompt (h, "Title", 18 * stdCharWidth, 0, programFont, 'l');
+ ppt = StaticPrompt (h, "Description", 18 * stdCharWidth, 0, programFont, 'l');
dlg = CreateTagListDialogEx (h, rows_shown, 2, 2,
titleedit_types, titleedit_widths,
@@ -15583,7 +16564,8 @@ static void SequenceAssistant (ButtoN b)
sad.summary_dlg = FastaSummaryDialog (h);
sad.sequence_table = TableDisplayDialog (h, stdCharWidth * 27, stdLineHeight * 8, 1, 2,
- SequenceDblClick, &sad);
+ SequenceDblClick, &sad,
+ NULL, NULL);
c = HiddenGroup (h, 2, 0, NULL);
b = PushButton(c, "Done", SequenceAssistantOkButton);
@@ -18011,109 +18993,6 @@ extern void LoadHistoryAccessionNumbersFromFile (
LoadSecondaryAccessionNumbersPlusHistFromFile (i, TRUE);
}
-/* This section of code is used for managing lists of features.
- * Sometimes the features will be displayed alphabetically, sometimes
- * they will be displayed alphabetically with a list of the most used features
- * also appearing at the top of the list.
- */
-
-/* This is used to compare feature names with the special alphabetical order */
-static int CompareFeatureNames (CharPtr cp1, CharPtr cp2)
-{
- /* NULL name goes at the end */
- if (cp1 == NULL && cp2 == NULL) return 0;
- if (cp1 == NULL) return 1;
- if (cp2 == NULL) return -1;
-
- /* starts with a space goes at the beginning */
- if (cp1 [0] == ' ' && cp2 [0] == ' ') return 0;
- if (cp1 [0] == ' ') return -1;
- if (cp2 [0] == ' ') return 1;
-
- /* Is "All" or [ALL FEATURES] goes at the beginning */
- if ((StringCmp (cp1, "All") == 0
- || StringCmp (cp1, "[ALL FEATURES]") == 0)
- && (StringCmp (cp2, "All") == 0
- || StringCmp (cp2, "[ALL FEATURES]") == 0))
- {
- return 0;
- }
- if (StringCmp (cp1, "All") == 0
- || StringCmp (cp1, "[ALL FEATURES]") == 0)
- {
- return -1;
- }
- if (StringCmp (cp2, "All") == 0
- || StringCmp (cp2, "[ALL FEATURES]") == 0)
- {
- return 1;
- }
-
- /* starts with a number -> goes at the end */
- if (cp1 [0] >= '0' && cp1 [0] <= '9'
- && cp2 [0] >= '0' && cp2 [0] <= '9')
- {
- return StringICmp (cp1, cp2);
- }
- if (cp1 [0] >= '0' && cp1 [0] <= '9')
- {
- return 1;
- }
- if (cp2 [0] >= '0' && cp2 [0] <= '9')
- {
- return -1;
- }
-
- /* starts with a tilde or dash - sort with other tildes, put before numbers after alphas */
- if (cp1 [0] == '~' && cp2 [0] == '~')
- {
- return StringICmp (cp1 + 1, cp2 + 1);
- }
- if (cp1 [0] == '~') return 1;
- if (cp2 [0] == '~') return -1;
-
- if (cp1 [0] == '-' && cp2 [0] == '-')
- {
- return StringICmp (cp1 + 1, cp2 + 1);
- }
- if (cp1 [0] == '-') return 1;
- if (cp2 [0] == '-') return -1;
-
- return StringICmp (cp1, cp2);
-}
-
-extern int LIBCALLBACK CompareFeatureValNodeStrings (VoidPtr ptr1, VoidPtr ptr2)
-{
- ValNodePtr vnp1, vnp2;
-
- if (ptr1 == NULL || ptr2 == NULL) return 0;
-
- vnp1 = *((ValNodePtr PNTR) ptr1);
- vnp2 = *((ValNodePtr PNTR) ptr2);
-
- if (vnp1 == NULL || vnp2 == NULL) return 0;
-
- return CompareFeatureNames (vnp1->data.ptrvalue, vnp2->data.ptrvalue);
-}
-
-extern int LIBCALLBACK CompareImpFeatEnumFieldAssoc (VoidPtr ptr1, VoidPtr ptr2)
-{
- ValNodePtr vnp1, vnp2;
- EnumFieldAssocPtr ap1, ap2;
-
- if (ptr1 == NULL || ptr2 == NULL) return 0;
-
- vnp1 = *((ValNodePtr PNTR) ptr1);
- vnp2 = *((ValNodePtr PNTR) ptr2);
- if (vnp1 == NULL || vnp2 == NULL) return 0;
-
- ap1 = (EnumFieldAssocPtr) vnp1->data.ptrvalue;
- ap2 = (EnumFieldAssocPtr) vnp2->data.ptrvalue;
- if (ap1 == NULL || ap2 == NULL) return 0;
-
- return CompareFeatureNames (ap1->name, ap2->name);
-}
-
CharPtr MostUsedFeatureList[] = {
"CDS",
"exon",
@@ -18239,38 +19118,6 @@ extern EnumFieldAssocPtr InsertMostUsedFeatureEnumFieldAssoc (
}
-extern void SortEnumFieldAssocPtrArray (EnumFieldAssocPtr alist, CompareFunc compar)
-{
- ValNodePtr head, vnp;
- EnumFieldAssocPtr ap;
- Int4 index;
-
- /* first, create ValNode list so we can sort the data */
- head = NULL;
- for (ap = alist; ap != NULL && ap->name != NULL; ap++)
- {
- vnp = ValNodeNew (head);
- if (vnp == NULL) return;
- vnp->data.ptrvalue = MemNew (sizeof (EnumFieldAssoc));
- if (vnp->data.ptrvalue == NULL) return;
- MemCpy (vnp->data.ptrvalue, ap, sizeof (EnumFieldAssoc));
- if (head == NULL) head = vnp;
- }
-
- /* Now sort the ValNode list */
- head = SortValNode (head, compar);
-
- /* Now repopulate the EnumFieldAssoc list */
- index = 0;
- for (vnp = head; vnp != NULL; vnp = vnp->next)
- {
- MemCpy (alist + index++, vnp->data.ptrvalue, sizeof (EnumFieldAssoc));
- }
-
- /* And free the ValNode list */
- ValNodeFreeData (head);
-}
-
static Uint2 UnusualFeatureTypes [] = {
FEATDEF_ORG,
FEATDEF_mutation,
diff --git a/sequin/sequin3.c b/sequin/sequin3.c
index 6993ca0f..ea33ccec 100644
--- a/sequin/sequin3.c
+++ b/sequin/sequin3.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/22/95
*
-* $Revision: 6.550 $
+* $Revision: 6.565 $
*
* File Description:
*
@@ -1362,6 +1362,7 @@ static void RemoveSelFeats (IteM i)
SeqEntryPtr sep;
SeqFeatPtr sfp;
SelStructPtr ssp;
+ Boolean unremoved_feats = FALSE;
#ifdef WIN_MAC
bfp = currentFormDataPtr;
@@ -1376,7 +1377,11 @@ static void RemoveSelFeats (IteM i)
if (ssp == NULL) return;
for (sel = ssp; sel != NULL; sel = sel->next) {
- if (sel->entityID != bfp->input_entityID) continue;
+ if (sel->entityID != bfp->input_entityID)
+ {
+ unremoved_feats = TRUE;
+ continue;
+ }
if (sel->itemtype == OBJ_SEQFEAT) {
sfp = SeqMgrGetDesiredFeature (sel->entityID, NULL, sel->itemID, 0, NULL, &fcontext);
if (sfp != NULL) {
@@ -1406,6 +1411,10 @@ static void RemoveSelFeats (IteM i)
ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+ if (unremoved_feats)
+ {
+ Message (MSG_ERROR, "Warning! Features mapped to far sequences cannot be deleted!");
+ }
}
static void RemoveUnselFeats (IteM i)
@@ -1423,6 +1432,8 @@ static void RemoveUnselFeats (IteM i)
SeqFeatPtr sfp;
SelStructPtr ssp;
SeqEntryPtr scope;
+ Boolean sel_on_local = FALSE;
+ Boolean sel_on_far = FALSE;
#ifdef WIN_MAC
bfp = currentFormDataPtr;
@@ -1439,15 +1450,30 @@ static void RemoveUnselFeats (IteM i)
scope = SeqEntrySetScope (NULL);
bsp = NULL;
for (sel = ssp; sel != NULL && bsp == NULL; sel = sel->next) {
- if (sel->entityID != bfp->input_entityID) continue;
+ if (sel->entityID != bfp->input_entityID)
+ {
+ if (sel->itemtype == OBJ_SEQFEAT)
+ {
+ sel_on_far = TRUE;
+ }
+ continue;
+ }
if (sel->itemtype == OBJ_SEQFEAT) {
+ sel_on_local = TRUE;
sfp = SeqMgrGetDesiredFeature (sel->entityID, NULL, sel->itemID, 0, NULL, &fcontext);
if (sfp != NULL) {
bsp = BioseqFindFromSeqLoc (sfp->location);
}
}
}
- if (bsp == NULL) return;
+ if (bsp == NULL)
+ {
+ if (sel_on_far && ! sel_on_local)
+ {
+ Message (MSG_ERROR, "Warning! Features mapped to far sequences cannot be deleted!");
+ }
+ return;
+ }
SeqEntrySetScope (scope);
sfp = SeqMgrGetNextFeature (bsp, NULL, 0, 0, &fcontext);
@@ -2101,7 +2127,7 @@ typedef struct gapconversiondata
TexT known_val_txt;
ButtoN acceptBtn;
DoC explanation;
-
+ ButtoN adjust_CDS_locations;
} GapConversionData, PNTR GapConversionPtr;
@@ -2113,7 +2139,7 @@ static void SetConvertGapsAcceptAndText (GapConversionPtr gcp)
Char str[15];
Int4 unknown_val, known_val;
Int4 unknown_op, known_op;
- Char explanation[255];
+ Char explanation[300];
if (gcp == NULL || gcp->explanation == NULL) return;
GetTitle (gcp->unknown_val_txt, str, sizeof (str));
@@ -2380,6 +2406,10 @@ static void ConvertGaps (ButtoN b)
Hide (gcp->form);
VisitBioseqsInSep (sep, gap_sizes, ConvertNsToGaps);
+ if (GetStatus (gcp->adjust_CDS_locations))
+ {
+ VisitFeaturesInSep (sep, NULL, AdjustCDSLocationsForGapsCallback);
+ }
ObjMgrSetDirtyFlag (gcp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, gcp->input_entityID, 0, 0);
Remove (gcp->form);
@@ -2390,8 +2420,9 @@ static void RawSeqToDeltaSeqUnknownWithUnknownLengthGaps (IteM i)
BaseFormPtr bfp;
GapConversionPtr gcp;
WindoW w;
- GrouP h, k, l, g, c;
+ GrouP h, l, g, c;
RecT r;
+ PrompT p1, p2;
#ifdef WIN_MAC
bfp = currentFormDataPtr;
@@ -2409,8 +2440,7 @@ static void RawSeqToDeltaSeqUnknownWithUnknownLengthGaps (IteM i)
gcp->form = (ForM) w;
h = HiddenGroup (w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
- k = HiddenGroup (h, 1, 0, NULL);
- StaticPrompt (k, "Choose size of length of Ns to convert to gaps of unknown length", 0, dialogTextHeight, programFont, 'c');
+ p1 = StaticPrompt (h, "Choose size of length of Ns to convert to gaps of unknown length", 0, dialogTextHeight, programFont, 'c');
g = HiddenGroup (h, 2, 0, NULL);
gcp->unknown_op = HiddenGroup (g, 0, 2, SetGapsConvertAcceptButtonAndTextGroup);
SetObjectExtra (gcp->unknown_op, gcp, NULL);
@@ -2419,8 +2449,7 @@ static void RawSeqToDeltaSeqUnknownWithUnknownLengthGaps (IteM i)
SetValue (gcp->unknown_op, 1);
gcp->unknown_val_txt = DialogText (g, "100", 14, SetGapsConvertAcceptButtonAndTextText);
SetObjectExtra (gcp->unknown_val_txt, gcp, NULL);
- k = HiddenGroup (h, 1, 0, NULL);
- StaticPrompt (k, "Choose size of length of Ns to convert to gaps of known length", 0, dialogTextHeight, programFont, 'c');
+ p2 = StaticPrompt (h, "Choose size of length of Ns to convert to gaps of known length", 0, dialogTextHeight, programFont, 'c');
l = HiddenGroup (h, 2, 0, NULL);
gcp->known_op = HiddenGroup (l, 0, 2, SetGapsConvertAcceptButtonAndTextGroup);
SetObjectExtra (gcp->known_op, gcp, NULL);
@@ -2431,17 +2460,28 @@ static void RawSeqToDeltaSeqUnknownWithUnknownLengthGaps (IteM i)
SetObjectExtra (gcp->known_val_txt, gcp, NULL);
/* status text */
- l = HiddenGroup (h, 1, 0, NULL);
- gcp->explanation = DocumentPanel (l, stdCharWidth * 27, stdLineHeight * 8);
+ gcp->explanation = DocumentPanel (h, stdCharWidth * 27, stdLineHeight * 8);
ObjectRect (gcp->explanation, &r);
InsetRect (&r, 4, 4);
faColFmt.pixWidth = r.right - r.left;
+
+ gcp->adjust_CDS_locations = CheckBox (h, "Adjust CDS locations for gaps", NULL);
+ SetStatus (gcp->adjust_CDS_locations, TRUE);
c = HiddenGroup (h, 4, 0, NULL);
gcp->acceptBtn = PushButton (c, "Accept", ConvertGaps);
SetObjectExtra (gcp->acceptBtn, gcp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
+ AlignObjects (ALIGN_CENTER, (HANDLE) p1,
+ (HANDLE) g,
+ (HANDLE) p2,
+ (HANDLE) l,
+ (HANDLE) gcp->explanation,
+ (HANDLE) gcp->adjust_CDS_locations,
+ (HANDLE) c,
+ NULL);
+
SetConvertGapsAcceptAndText (gcp);
RealizeWindow (w);
Show (w);
@@ -2472,6 +2512,7 @@ typedef struct deltaconversion
DialoG gap_locations;
GrouP coord_grp;
+ ButtoN adjust_CDS_locations;
} DeltaConversionData, PNTR DeltaConversionPtr;
@@ -2714,12 +2755,7 @@ static Pointer DeltaLocToData (DialoG d)
if (start_pos > 0)
{
str = ExtractTagListColumn ((CharPtr) vnp->data.ptrvalue, 1);
- if (StringICmp (str, "0"))
- {
- is_known = FALSE;
- len = 100;
- }
- else
+ if (StringICmp (str, "1") == 0)
{
is_known = TRUE;
len = -1;
@@ -2735,6 +2771,12 @@ static Pointer DeltaLocToData (DialoG d)
return NULL;
}
}
+ else
+ {
+ is_known = FALSE;
+ len = 100;
+ }
+
glip = (GapLocInfoPtr) MemNew (sizeof (GapLocInfoData));
if (glip != NULL)
{
@@ -2786,6 +2828,12 @@ static void DoConvertRawToDeltaWithGapLocations (ButtoN b)
VisitBioseqsInSep (sep, location_list, ConvertBioseqToDeltaWithAlignmentGapList);
}
location_list = ValNodeFreeData (location_list);
+
+ if (GetStatus (dcp->adjust_CDS_locations))
+ {
+ VisitFeaturesInSep (sep, NULL, AdjustCDSLocationsForGapsCallback);
+ }
+
ObjMgrSetDirtyFlag (dcp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, dcp->input_entityID, 0, 0);
Remove (dcp->form);
@@ -2851,6 +2899,9 @@ static void ConvertRawToDeltaWithGapLocations (IteM i)
Disable (dcp->coord_grp);
}
+ dcp->adjust_CDS_locations = CheckBox (h, "Adjust CDS locations for gaps", NULL);
+ SetStatus (dcp->adjust_CDS_locations, TRUE);
+
c = HiddenGroup (h, 2, 0, NULL);
b = PushButton (c, "Accept", DoConvertRawToDeltaWithGapLocations);
SetObjectExtra (b, dcp, NULL);
@@ -2858,6 +2909,7 @@ static void ConvertRawToDeltaWithGapLocations (IteM i)
AlignObjects (ALIGN_CENTER, (HANDLE) dcp->gap_locations,
(HANDLE) dcp->coord_grp,
+ (HANDLE) dcp->adjust_CDS_locations,
(HANDLE) c,
NULL);
@@ -3078,193 +3130,393 @@ static void GeneToXref (IteM i)
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
}
+typedef struct featurefieldforgenechoice
+{
+ Int4 first_choice;
+ Int4 second_choice;
+ CharPtr field_txt;
+} FeatureFieldForGeneChoiceData, PNTR FeatureFieldForGeneChoicePtr;
+
+static FeatureFieldForGeneChoicePtr FeatureFieldForGeneChoiceFree (FeatureFieldForGeneChoicePtr fcp)
+{
+ if (fcp != NULL)
+ {
+ fcp->field_txt = MemFree (fcp->field_txt);
+ fcp = MemFree (fcp);
+ }
+ return fcp;
+}
+
typedef struct featuretogene
{
FEATURE_FORM_BLOCK
- Uint1 subtype;
- PopuP qualchoice[3];
+ DialoG *gene_src_dlg_list;
+ Int4 num_choices;
+ ValNodePtr feature_choices;
+
+ TexT label_txt;
PopuP genechoice;
- ButtoN accept_btn;
GrouP qual_caps_grp;
+ DialoG feature_dlg;
+ DialoG filter_grp;
+ DialoG accept_cancel;
ButtoN single_interval_btn;
ButtoN selected_features_only_btn;
Boolean single_interval;
+ FeatureFieldForGeneChoicePtr fcp;
} FeatureToGeneData, PNTR FeatureToGenePtr;
-static void EnableFeatureToGeneControlsPopup (PopuP p)
+static Int4 GetGeneSrcDlgIndex (FeatureToGenePtr fgp)
+{
+ ValNodePtr vnp, check_vnp;
+ Int4 rval = -1, i;
+
+ if (fgp == NULL) return -1;
+
+ vnp = DialogToPointer (fgp->feature_dlg);
+ if (vnp == NULL)
+ {
+ return -1;
+ }
+
+ check_vnp = fgp->feature_choices;
+ i = 0;
+ while (check_vnp != NULL && check_vnp->choice != vnp->choice)
+ {
+ check_vnp = check_vnp->next;
+ i++;
+ }
+ if (check_vnp != NULL)
+ {
+ rval = i;
+ }
+ ValNodeFreeData (vnp);
+ return rval;
+}
+
+static void EnableFeatureToGeneControls (Pointer userdata)
{
+ Int4 i;
FeatureToGenePtr fgp;
- Int4 i, j, val;
+ FeatureFieldForGeneChoicePtr fcp;
- fgp = (FeatureToGenePtr) GetObjectExtra (p);
+ fgp = (FeatureToGenePtr) userdata;
if (fgp == NULL) return;
Disable (fgp->qual_caps_grp);
Disable (fgp->genechoice);
- for (i = 0; i < 2; i++)
+
+ i = GetGeneSrcDlgIndex (fgp);
+ if (i >= 0)
{
- val = GetValue (fgp->qualchoice[i]);
- if (val == 1)
- {
- for (j = i + 1; i < 3; i++)
- {
- Disable (fgp->qualchoice[j]);
- SetValue (fgp->qualchoice[j], 1);
- }
- }
- else
- {
- Enable (fgp->qualchoice [i + 1]);
- Enable (fgp->qual_caps_grp);
- Enable (fgp->genechoice);
- }
+ fcp = (FeatureFieldForGeneChoicePtr) DialogToPointer (fgp->gene_src_dlg_list [i]);
+ if (fcp != NULL)
+ {
+ if (fcp->first_choice > 1 || !StringHasNoText (fcp->field_txt))
+ {
+ Enable (fgp->qual_caps_grp);
+ Enable (fgp->genechoice);
+ }
+ fcp = FeatureFieldForGeneChoiceFree (fcp);
+ }
}
}
-static PopuP MakeCDSPopup (GrouP g, FeatureToGenePtr fgp)
+static void EnableFeatureToGeneControlsPopup (PopuP p)
{
- PopuP p;
+ FeatureToGenePtr fgp;
- p = PopupList (g, TRUE, EnableFeatureToGeneControlsPopup);
- SetObjectExtra (p, fgp, NULL);
- PopupItem (p, "None");
- PopupItem (p, "Comment");
- PopupItem (p, "Product");
- SetValue (p, 1);
- return p;
+ fgp = (FeatureToGenePtr) GetObjectExtra (p);
+ EnableFeatureToGeneControls (fgp);
}
-static CharPtr GetCDSPopupText (PopuP p, SeqFeatPtr cds)
+static void EnableFeatureToGeneControlsText (TexT t)
{
- Int4 val;
- SeqMgrFeatContext context;
- if (p == NULL || cds == NULL) return NULL;
- val = GetValue (p);
+ FeatureToGenePtr fgp;
- if (val == 2 && !StringHasNoText (cds->comment))
+ fgp = (FeatureToGenePtr) GetObjectExtra (t);
+ EnableFeatureToGeneControls (fgp);
+
+}
+
+typedef struct featurefieldforgenedlg
+{
+ DIALOG_MESSAGE_BLOCK
+ PopuP first_choice_popup;
+ PopuP second_choice_popup;
+ TexT label_txt;
+ Nlm_ChangeNotifyProc change_notify;
+ Pointer change_userdata;
+} FeatureFieldForGeneDlgData, PNTR FeatureFieldForGeneDlgPtr;
+
+static void ResetFeatureFieldForGeneDlg (FeatureFieldForGeneDlgPtr dlg)
+{
+ if (dlg == NULL)
{
- return StringSave (cds->comment);
+ return;
}
- else if (val == 3)
+
+ SetValue (dlg->first_choice_popup, 1);
+ SafeSetValue (dlg->second_choice_popup, 1);
+ SetTitle (dlg->label_txt, "");
+}
+
+static void FeatureFieldForGeneToDialog (DialoG d, Pointer userdata)
+{
+ FeatureFieldForGeneDlgPtr dlg;
+ FeatureFieldForGeneChoicePtr data;
+
+ dlg = (FeatureFieldForGeneDlgPtr) GetObjectExtra (d);
+ data = (FeatureFieldForGeneChoicePtr) userdata;
+ if (dlg == NULL)
{
- cds = SeqMgrGetDesiredFeature (cds->idx.entityID, NULL, 0, 0, cds, &context);
- if (cds == NULL || StringHasNoText (context.label)) return NULL;
- return StringSave (context.label);
+ return;
}
- else
+ ResetFeatureFieldForGeneDlg (dlg);
+ if (data == NULL)
{
- return NULL;
+ return;
+ }
+ if (data->first_choice > 0)
+ {
+ SetValue (dlg->first_choice_popup, data->first_choice);
+ }
+ if (data->second_choice > 0)
+ {
+ SafeSetValue (dlg->second_choice_popup, data->second_choice);
+ }
+ if (!StringHasNoText (data->field_txt))
+ {
+ SetTitle (dlg->label_txt, data->field_txt);
}
}
-static PopuP MaketRNAPopup (GrouP g, FeatureToGenePtr fgp)
+static Pointer FeatureFieldForGeneFromDialog (DialoG d)
{
- PopuP p;
-
- p = PopupList (g, TRUE, EnableFeatureToGeneControlsPopup);
- SetObjectExtra (p, fgp, NULL);
- PopupItem (p, "None");
- PopupItem (p, "Comment");
- SetValue (p, 1);
- return p;
+ FeatureFieldForGeneDlgPtr dlg;
+ FeatureFieldForGeneChoicePtr data;
+
+ dlg = (FeatureFieldForGeneDlgPtr) GetObjectExtra (d);
+ if (dlg == NULL)
+ {
+ return NULL;
+ }
+ data = (FeatureFieldForGeneChoicePtr) MemNew (sizeof (FeatureFieldForGeneChoiceData));
+ if (data != NULL)
+ {
+ data->first_choice = GetValue (dlg->first_choice_popup);
+ if (dlg->second_choice_popup != NULL)
+ {
+ data->second_choice = GetValue (dlg->second_choice_popup);
+ }
+ else
+ {
+ data->second_choice = 0;
+ }
+ if (TextHasNoText (dlg->label_txt))
+ {
+ data->field_txt = NULL;
+ }
+ else
+ {
+ data->field_txt = SaveStringFromText (dlg->label_txt);
+ }
+ }
+ return data;
}
-static CharPtr GettRNAPopupText (PopuP p, SeqFeatPtr cds)
+static void FeatureFieldForGeneChange (FeatureFieldForGeneDlgPtr dlg)
{
- Int4 val;
- if (p == NULL || cds == NULL) return NULL;
- val = GetValue (p);
-
- if (val == 2 && !StringHasNoText (cds->comment))
+ if (dlg == NULL)
{
- return StringSave (cds->comment);
+ return;
+ }
+ if (GetValue (dlg->first_choice_popup) > 1)
+ {
+ SafeEnable (dlg->second_choice_popup);
}
else
{
- return NULL;
+ SafeDisable (dlg->second_choice_popup);
+ }
+ if (dlg->change_notify != NULL)
+ {
+ (dlg->change_notify) (dlg->change_userdata);
}
}
-static PopuP MakerRNAPopup (GrouP g, FeatureToGenePtr fgp)
+static void FeatureFieldForGeneChangePopup (PopuP p)
+{
+ FeatureFieldForGeneDlgPtr dlg;
+
+ dlg = (FeatureFieldForGeneDlgPtr) GetObjectExtra (p);
+ FeatureFieldForGeneChange (dlg);
+}
+
+static void FeatureFieldForGeneChangeText (TexT t)
+{
+ FeatureFieldForGeneDlgPtr dlg;
+
+ dlg = (FeatureFieldForGeneDlgPtr) GetObjectExtra (t);
+ FeatureFieldForGeneChange (dlg);
+}
+
+static PopuP MakeFieldChoicePopup (GrouP g, Int4 featdef_choice, Pointer extradata)
{
PopuP p;
- p = PopupList (g, TRUE, EnableFeatureToGeneControlsPopup);
- SetObjectExtra (p, fgp, NULL);
- PopupItem (p, "None");
- PopupItem (p, "Comment");
- PopupItem (p, "Product Name");
+ p = PopupList (g, TRUE, FeatureFieldForGeneChangePopup);
+ SetObjectExtra (p, extradata, NULL);
+
+ if (featdef_choice == FEATDEF_CDS
+ || featdef_choice == FEATDEF_tRNA
+ || featdef_choice == FEATDEF_rRNA
+ || featdef_choice == FEATDEF_misc_RNA
+ || featdef_choice == FEATDEF_mRNA)
+ {
+ PopupItem (p, "None");
+ PopupItem (p, "Comment");
+ PopupItem (p, "Product");
+ }
+ else
+ {
+ PopupItem (p, "None");
+ PopupItem (p, "Comment");
+ }
SetValue (p, 1);
- return p;
+ return p;
}
-static CharPtr GetrRNAPopupText (PopuP p, SeqFeatPtr sfp)
+static DialoG
+FeatureFieldForGeneDialog
+(GrouP parent,
+ Int4 featdef_choice,
+ Nlm_ChangeNotifyProc change_notify,
+ Pointer change_userdata)
{
- Int4 val;
- RnaRefPtr rrp;
-
- if (p == NULL || sfp == NULL || sfp->data.choice != SEQFEAT_RNA) return NULL;
+ FeatureFieldForGeneDlgPtr dlg;
+ GrouP p;
- val = GetValue (p);
- rrp = (RnaRefPtr) (sfp->data.value.ptrvalue);
-
- if (val == 2 && !StringHasNoText (sfp->comment))
+ dlg = (FeatureFieldForGeneDlgPtr) MemNew (sizeof (FeatureFieldForGeneDlgData));
+ if (dlg == NULL)
{
- return StringSave (sfp->comment);
+ return NULL;
}
- else if (val == 3 && rrp != NULL && rrp->ext.choice == 1
- && !StringHasNoText (rrp->ext.value.ptrvalue))
+
+ p = NormalGroup (parent, 2, 0, "Select qualifier to use in gene", NULL, NULL);
+ SetObjectExtra (p, dlg, StdCleanupExtraProc);
+
+ dlg->dialog = (DialoG) p;
+ dlg->todialog = FeatureFieldForGeneToDialog;
+ dlg->fromdialog = FeatureFieldForGeneFromDialog;
+ dlg->dialogmessage = NULL;
+ dlg->testdialog = NULL;
+ dlg->change_notify = change_notify;
+ dlg->change_userdata = change_userdata;
+
+ StaticPrompt (p, "1st Choice", 0, 0, programFont, 'c');
+ dlg->first_choice_popup = MakeFieldChoicePopup (p, featdef_choice, dlg);
+
+ if (featdef_choice == FEATDEF_CDS
+ || featdef_choice == FEATDEF_tRNA
+ || featdef_choice == FEATDEF_rRNA
+ || featdef_choice == FEATDEF_misc_RNA
+ || featdef_choice == FEATDEF_mRNA)
{
- return StringSave (rrp->ext.value.ptrvalue);
+ StaticPrompt (p, "2nd Choice", 0, 0, programFont, 'c');
+ dlg->second_choice_popup = MakeFieldChoicePopup (p, featdef_choice, dlg);
+ Disable (dlg->second_choice_popup);
}
else
{
- return NULL;
+ dlg->second_choice_popup = NULL;
}
+
+ StaticPrompt (p, "Use this string:", 0, 0, programFont, 'c');
+ dlg->label_txt = DialogText (p, "", 10, FeatureFieldForGeneChangeText);
+ SetObjectExtra (dlg->label_txt, dlg, NULL);
+
+ return (DialoG) p;
}
-static PopuP MakemiscRNAPopup (GrouP g, FeatureToGenePtr fgp)
+static CharPtr GetGeneSrcChoice (SeqFeatPtr sfp, Int4 choice)
{
- PopuP p;
+ CharPtr src_txt = NULL;
+ RnaRefPtr rrp;
+ SeqMgrFeatContext fcontext;
- p = PopupList (g, TRUE, EnableFeatureToGeneControlsPopup);
- SetObjectExtra (p, fgp, NULL);
- PopupItem (p, "None");
- PopupItem (p, "Comment");
- PopupItem (p, "Product Name");
- SetValue (p, 1);
- return p;
+ if (sfp == NULL || choice < 2)
+ {
+ return NULL;
+ }
+
+ if (choice == 2 && !StringHasNoText (sfp->comment))
+ {
+ src_txt = StringSave (sfp->comment);
+ }
+ else if (choice == 3)
+ {
+ if (sfp->idx.subtype == FEATDEF_tRNA)
+ {
+ sfp = SeqMgrGetDesiredFeature (sfp->idx.entityID, NULL,
+ 0, 0, sfp, &fcontext);
+ if (!StringHasNoText (fcontext.label))
+ {
+ src_txt = (CharPtr) MemNew (StringLen (fcontext.label) + 6);
+ if (src_txt != NULL)
+ {
+ sprintf (src_txt, "tRNA-%s", fcontext.label);
+ }
+ }
+ }
+ else if (sfp->idx.subtype == FEATDEF_CDS
+ || sfp->idx.subtype == FEATDEF_mRNA)
+ {
+ sfp = SeqMgrGetDesiredFeature (sfp->idx.entityID, NULL,
+ 0, 0, sfp, &fcontext);
+ if (!StringHasNoText (fcontext.label))
+ {
+ src_txt = StringSave (fcontext.label);
+ }
+ }
+ else if (sfp->data.choice == SEQFEAT_RNA)
+ {
+ rrp = (RnaRefPtr) (sfp->data.value.ptrvalue);
+ if (rrp != NULL && rrp->ext.choice == 1
+ && !StringHasNoText (rrp->ext.value.ptrvalue))
+ {
+ src_txt = StringSave (rrp->ext.value.ptrvalue);
+ }
+ }
+ }
+ return src_txt;
}
-static CharPtr GetmiscRNAPopupText (PopuP p, SeqFeatPtr sfp)
+static CharPtr GetGeneSrc (SeqFeatPtr sfp, FeatureFieldForGeneChoicePtr fcp)
{
- Int4 val;
- RnaRefPtr rrp;
-
- if (p == NULL || sfp == NULL || sfp->data.choice != SEQFEAT_RNA) return NULL;
+ CharPtr src_txt = NULL;
- val = GetValue (p);
- rrp = (RnaRefPtr) (sfp->data.value.ptrvalue);
-
- if (val == 2 && !StringHasNoText (sfp->comment))
+ if (sfp == NULL || fcp == NULL)
{
- return StringSave (sfp->comment);
+ return NULL;
}
- else if (val == 3 && rrp != NULL && rrp->ext.choice == 1
- && !StringHasNoText (rrp->ext.value.ptrvalue))
+
+ src_txt = GetGeneSrcChoice (sfp, fcp->first_choice);
+ if (src_txt == NULL)
{
- return StringSave (rrp->ext.value.ptrvalue);
+ src_txt = GetGeneSrcChoice (sfp, fcp->second_choice);
}
- else
+ if (src_txt == NULL && !StringHasNoText (fcp->field_txt))
{
- return NULL;
+ src_txt = StringSave (fcp->field_txt);
}
+ return src_txt;
}
-static void FeatureToGeneCallback (SeqFeatPtr sfp, Pointer userdata)
+static void FeatureToGeneCallback (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr fsp)
{
SeqFeatPtr gene, overlap_gene;
GeneRefPtr grp, overlap_grp = NULL;
@@ -3279,7 +3531,6 @@ static void FeatureToGeneCallback (SeqFeatPtr sfp, Pointer userdata)
if (sfp == NULL || userdata == NULL) return;
fgp = (FeatureToGenePtr) userdata;
- if (sfp->idx.subtype != fgp->subtype) return;
if (SeqMgrGetGeneXref (sfp) != NULL) return;
bsp = BioseqFindFromSeqLoc (sfp->location);
@@ -3295,24 +3546,8 @@ static void FeatureToGeneCallback (SeqFeatPtr sfp, Pointer userdata)
return;
}
- for (i = 0; gene_val == NULL && i < 2 && GetValue (fgp->qualchoice[i]) != 1; i++)
- {
- switch (fgp->subtype)
- {
- case FEATDEF_CDS:
- gene_val = GetCDSPopupText (fgp->qualchoice[i], sfp);
- break;
- case FEATDEF_tRNA:
- gene_val = GettRNAPopupText (fgp->qualchoice[i], sfp);
- break;
- case FEATDEF_rRNA:
- gene_val = GetrRNAPopupText (fgp->qualchoice[i], sfp);
- break;
- case FEATDEF_otherRNA:
- gene_val = GetmiscRNAPopupText (fgp->qualchoice[i], sfp);
- break;
- }
- }
+ gene_val = GetGeneSrc (sfp, fgp->fcp);
+
if (gene_val != NULL)
{
/* apply capitalization */
@@ -3370,17 +3605,37 @@ static void FeatureToGeneCallback (SeqFeatPtr sfp, Pointer userdata)
sfp->next = gene;
}
-static void FeatureToGeneAccept (ButtoN b)
+static Boolean FeatureToGeneAccept (Pointer userdata)
{
FeatureToGenePtr fgp;
SeqEntryPtr sep;
SelStructPtr sel;
SeqFeatPtr sfp;
SeqMgrFeatContext fcontext;
+ FilterSetPtr fsp;
+ Int4 i, featdef_choice;
+ ValNodePtr vnp;
- fgp = (FeatureToGenePtr) GetObjectExtra (b);
- if (fgp == NULL) return;
- Hide (fgp->form);
+ fgp = (FeatureToGenePtr) userdata;
+ if (fgp == NULL) return FALSE;
+
+ vnp = DialogToPointer (fgp->feature_dlg);
+ if (vnp == NULL)
+ {
+ return FALSE;
+ }
+ featdef_choice = vnp->choice;
+ vnp = ValNodeFreeData (vnp);
+
+ i = GetGeneSrcDlgIndex (fgp);
+ if (i < 0)
+ {
+ return FALSE;
+ }
+
+ fgp->fcp = DialogToPointer (fgp->gene_src_dlg_list [i]);
+
+ fsp = DialogToPointer (fgp->filter_grp);
sep = GetTopSeqEntryForEntityID (fgp->input_entityID);
if (sep == NULL) return;
@@ -3395,7 +3650,7 @@ static void FeatureToGeneAccept (ButtoN b)
sfp = SeqMgrGetDesiredFeature (sel->entityID, NULL, sel->itemID, 0, NULL, &fcontext);
if (sfp != NULL)
{
- FeatureToGeneCallback (sfp, fgp);
+ FeatureToGeneCallback (sfp, fgp, NULL);
}
}
sel = sel->next;
@@ -3403,22 +3658,126 @@ static void FeatureToGeneAccept (ButtoN b)
}
else
{
- VisitFeaturesInSep (sep, fgp, FeatureToGeneCallback);
+ OperateOnSeqEntryConstrainedObjects (sep, fsp, FeatureToGeneCallback,
+ NULL, 0, featdef_choice, 0, fgp);
}
+
+ FilterSetFree (fsp);
+ fgp->fcp = FeatureFieldForGeneChoiceFree (fgp->fcp);
+
ObjMgrSetDirtyFlag (fgp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, fgp->input_entityID, 0, 0);
- Remove (fgp->form);
+ return TRUE;
+}
+
+static void ChangeGeneFeatureSelection (Pointer userdata)
+{
+ FeatureToGenePtr fgp;
+ Int4 i;
+
+ fgp = (FeatureToGenePtr) userdata;
+ if (fgp == NULL)
+ {
+ return;
+ }
+
+ for (i = 0; i < fgp->num_choices; i++)
+ {
+ Hide (fgp->gene_src_dlg_list [i]);
+ }
+
+ i = GetGeneSrcDlgIndex (fgp);
+
+ if (i < 0)
+ {
+ DisableAcceptCancelDialogAccept (fgp->accept_cancel);
+ }
+ else
+ {
+ EnableAcceptCancelDialogAccept (fgp->accept_cancel);
+ Show (fgp->gene_src_dlg_list [i]);
+ }
+ EnableFeatureToGeneControls (fgp);
}
-static void FeatureToGene (IteM i, Uint1 subtype)
+static void CleanupFeatureToGeneForm (GraphiC g, VoidPtr data)
+{
+ FeatureToGenePtr fgp;
+
+ fgp = (FeatureToGenePtr) data;
+ if (fgp != NULL)
+ {
+ fgp->feature_choices = ValNodeFreeData (fgp->feature_choices);
+ MemFree (fgp);
+ }
+}
+
+static void FeatureToGeneClearText (Pointer userdata)
+{
+ FeatureToGenePtr fgp;
+ Int4 j;
+ FilterSetPtr fsp;
+ FeatureFieldForGeneChoicePtr fcp;
+
+ fgp = (FeatureToGenePtr) userdata;
+ if (fgp == NULL)
+ {
+ return;
+ }
+
+ for (j = 0; j < fgp->num_choices; j++)
+ {
+ fcp = (FeatureFieldForGeneChoicePtr) DialogToPointer (fgp->gene_src_dlg_list [j]);
+ if (fcp != NULL)
+ {
+ fcp->field_txt = MemFree (fcp->field_txt);
+ }
+ PointerToDialog (fgp->gene_src_dlg_list [j], fcp);
+ FeatureFieldForGeneChoiceFree (fcp);
+ }
+
+ fsp = (FilterSetPtr) DialogToPointer (fgp->filter_grp);
+ FilterSetClearText (fsp);
+ PointerToDialog (fgp->filter_grp, fsp);
+ FilterSetFree (fsp);
+ EnableFeatureToGeneControls (fgp);
+}
+
+static void FeatureToGeneClear (Pointer userdata)
+{
+ FeatureToGenePtr fgp;
+ Int4 j;
+
+ fgp = (FeatureToGenePtr) userdata;
+ if (fgp == NULL)
+ {
+ return;
+ }
+
+ PointerToDialog (fgp->feature_dlg, NULL);
+ for (j = 0; j < fgp->num_choices; j++)
+ {
+ PointerToDialog (fgp->gene_src_dlg_list [j], NULL);
+ }
+ PointerToDialog (fgp->filter_grp, NULL);
+
+ SetValue (fgp->qual_caps_grp, 1);
+ SetValue (fgp->genechoice, 1);
+ SetStatus (fgp->single_interval_btn, TRUE);
+ SetStatus (fgp->selected_features_only_btn, FALSE);
+
+ ChangeGeneFeatureSelection (fgp);
+ EnableFeatureToGeneControls (fgp);
+}
+
+static void FeatureToGene (IteM i)
{
BaseFormPtr bfp;
FeatureToGenePtr fgp;
WindoW w;
Int4 j;
- CharPtr choice_labels[3] = { "1st Choice", "2nd Choice", "3rd Choice" };
- GrouP h, g, k, m, n, c;
- ButtoN b;
+ GrouP h, k, m, n;
+ ValNodePtr vnp;
#ifdef WIN_MAC
bfp = currentFormDataPtr;
@@ -3432,63 +3791,38 @@ static void FeatureToGene (IteM i, Uint1 subtype)
fgp = (FeatureToGenePtr) MemNew (sizeof (FeatureToGeneData));
if (fgp == NULL) return;
- fgp->subtype = subtype;
fgp->input_entityID = bfp->input_entityID;
- switch (fgp->subtype)
- {
- case FEATDEF_CDS:
- w = FixedWindow (-50, -33, -10, -10, "CDS to Gene", StdCloseWindowProc);
- break;
- case FEATDEF_tRNA:
- w = FixedWindow (-50, -33, -10, -10, "tRNA to Gene", StdCloseWindowProc);
- break;
- case FEATDEF_rRNA:
- w = FixedWindow (-50, -33, -10, -10, "rRNA to Gene", StdCloseWindowProc);
- break;
- case FEATDEF_otherRNA:
- w = FixedWindow (-50, -33, -10, -10, "miscRNA to Gene", StdCloseWindowProc);
- break;
- default:
- Message (MSG_ERROR, "Unrecognized subtype for feature to gene");
- return;
- break;
- }
- SetObjectExtra (w, fgp, NULL);
+ w = FixedWindow (-50, -33, -10, -10, "Feature to Gene", StdCloseWindowProc);
+ SetObjectExtra (w, fgp, CleanupFeatureToGeneForm);
fgp->form = (ForM) w;
h = HiddenGroup (w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
- g = HiddenGroup (h, 0, 6, NULL);
+ fgp->feature_dlg = FeatureSelectionDialog (h, FALSE, ChangeGeneFeatureSelection, fgp);
+ k = HiddenGroup (h, 0, 0, NULL);
- k = NormalGroup (g, 2, 0, "Select qualifier to use in gene", NULL, NULL);
- for (j = 0; j < 2; j++)
+ fgp->feature_choices = BuildFeatureDialogList (TRUE);
+ fgp->num_choices = ValNodeLen (fgp->feature_choices);
+ fgp->gene_src_dlg_list = (DialoG *) MemNew (fgp->num_choices * sizeof (DialoG));
+
+ for (j = 0, vnp = fgp->feature_choices;
+ j < fgp->num_choices && vnp != NULL;
+ j++, vnp = vnp->next)
{
- StaticPrompt (k, choice_labels [j], 0, 0, programFont, 'c');
- switch (fgp->subtype)
- {
- case FEATDEF_CDS:
- fgp->qualchoice[j] = MakeCDSPopup (k, fgp);
- break;
- case FEATDEF_tRNA:
- fgp->qualchoice[j] = MaketRNAPopup (k, fgp);
- break;
- case FEATDEF_rRNA:
- fgp->qualchoice[j] = MakerRNAPopup (k, fgp);
- break;
- case FEATDEF_otherRNA:
- fgp->qualchoice[j] = MakemiscRNAPopup (k, fgp);
- break;
- }
- }
- fgp->qual_caps_grp = NormalGroup (g, 3, 0,
+ fgp->gene_src_dlg_list [j] = FeatureFieldForGeneDialog (k, vnp->choice,
+ EnableFeatureToGeneControls,
+ fgp);
+ }
+
+ fgp->qual_caps_grp = NormalGroup (h, 3, 0,
"Capitalization for gene", NULL, NULL);
RadioButton (fgp->qual_caps_grp, "As is");
RadioButton (fgp->qual_caps_grp, "Capitalize first initial");
RadioButton (fgp->qual_caps_grp, "Capitalize all");
SetValue (fgp->qual_caps_grp, 1);
Disable (fgp->qual_caps_grp);
- m = HiddenGroup (g, 2, 0, NULL);
+ m = HiddenGroup (h, 2, 0, NULL);
StaticPrompt (m, "Select gene qualifier to populate", 0,0, programFont, 'c');
fgp->genechoice = PopupList (m, TRUE, NULL);
PopupItem (fgp->genechoice, "locus");
@@ -3499,45 +3833,29 @@ static void FeatureToGene (IteM i, Uint1 subtype)
SetValue (fgp->genechoice, 1);
Disable (fgp->genechoice);
- n = HiddenGroup (g, 2, 0, NULL);
+ n = HiddenGroup (h, 2, 0, NULL);
fgp->single_interval_btn = CheckBox (n, "Create gene with single interval location", NULL);
SetStatus (fgp->single_interval_btn, TRUE);
fgp->selected_features_only_btn = CheckBox (n, "Only create genes for selected features", NULL);
SetStatus (fgp->selected_features_only_btn, FALSE);
- c = HiddenGroup (g, 4, 0, NULL);
- b = PushButton (c, "Accept", FeatureToGeneAccept);
- SetObjectExtra (b, fgp, NULL);
-
- PushButton (c, "Cancel", StdCancelButtonProc);
+ fgp->filter_grp = FilterGroup (h, TRUE, FALSE, FALSE, FALSE, "Where feature field contains");
+ fgp->accept_cancel = AcceptCancelDialog (h, FeatureToGeneAccept, NULL, FeatureToGeneClear, FeatureToGeneClearText, (Pointer)fgp, w);
- AlignObjects (ALIGN_CENTER, (HANDLE) k, (HANDLE) fgp->qual_caps_grp, (HANDLE) n,
- (HANDLE) c, NULL);
+ AlignObjects (ALIGN_CENTER, (HANDLE) fgp->feature_dlg,
+ (HANDLE) k,
+ (HANDLE) fgp->qual_caps_grp,
+ (HANDLE) m,
+ (HANDLE) n,
+ (HANDLE) fgp->filter_grp,
+ (HANDLE) fgp->accept_cancel,
+ NULL);
RealizeWindow (w);
Show (w);
Update ();
-}
-
-static void CdsToGene (IteM i)
-{
- FeatureToGene (i, FEATDEF_CDS);
-}
-
-static void tRNAtoGene (IteM i)
-{
- FeatureToGene (i, FEATDEF_tRNA);
-}
-
-static void rRNAtoGene (IteM i)
-{
- FeatureToGene (i, FEATDEF_rRNA);
-}
-
-static void MiscRNAtoGene (IteM i)
-{
- FeatureToGene (i, FEATDEF_otherRNA);
+ ChangeGeneFeatureSelection (fgp);
}
typedef struct genetocdsform
@@ -6485,126 +6803,6 @@ static void RemoveTaxonXrefsFromFeaturesAndBioSources (IteM i)
RemoveTaxonXrefs (i, TRUE);
}
-/*-------------------------------------------------------------------------*/
-/* */
-/* SuppressGeneXref_Callback () -- Suppresses any gene xref on the feature */
-/* that is passed to it. */
-/* */
-/*-------------------------------------------------------------------------*/
-
-static Boolean LIBCALLBACK SuppressGeneXref_Callback (SeqFeatPtr sfp,
- SeqMgrFeatContextPtr context)
-{
- GeneRefPtr grp = NULL;
- SeqFeatXrefPtr xref;
-
- /* If there is a gene xref, then change it */
- /* to a suppression gene xref. */
-
- grp = SeqMgrGetGeneXref (sfp);
- if (NULL != grp)
- {
- if (SeqMgrGeneIsSuppressed (grp) == FALSE)
- {
- if (NULL != grp->locus)
- {
- MemFree(grp->locus);
- grp->locus = NULL;
- }
- if (NULL != grp->allele)
- {
- MemFree(grp->allele);
- grp->allele = NULL;
- }
- if (NULL != grp->desc)
- {
- MemFree(grp->desc);
- grp->desc = NULL;
- }
- if (NULL != grp->maploc)
- {
- MemFree (grp->maploc);
- grp->maploc = NULL;
- }
- if (NULL != grp->locus_tag)
- {
- MemFree (grp->locus_tag);
- grp->locus_tag = NULL;
- }
- grp->db = ValNodeFreeData (grp->db);
- grp->syn = ValNodeFreeData (grp->syn);
- }
- }
-
- /* Otherwise, if there is an overlapping gene, add */
- /* a suppression xref for it. */
-
- else if (SeqMgrGetOverlappingGene (sfp->location, NULL) != NULL)
- {
- grp = GeneRefNew ();
- if (grp != NULL) {
- xref = SeqFeatXrefNew ();
- xref->data.choice = SEQFEAT_GENE;
- xref->data.value.ptrvalue = grp;
- xref->next = sfp->xref;
- sfp->xref = xref;
- }
- }
-
- /* Return successfully */
-
- return TRUE;
-}
-
-/*-------------------------------------------------------------------------*/
-/* */
-/* SuppressGeneXrefsForFeatureType () -- Suppresses gene xrefs for all */
-/* features of the given type. */
-/* */
-/*-------------------------------------------------------------------------*/
-
-static void SuppressGeneXrefsForFeatureType (BioseqPtr bsp,
- Int2 seqfeat,
- Int2 featdef)
-{
- Boolean featDefFilterArray [FEATDEF_MAX];
- Boolean seqFeatFilterArray [SEQFEAT_MAX];
-
- /* Check for valid parameters */
-
- if (bsp == NULL)
- return;
-
- if ((seqfeat == 0) && (featdef == 0))
- return;
-
- /* Explore all of the given feature type */
-
- WatchCursor ();
- Update ();
-
- if (featdef != 0)
- {
- MemSet ((Pointer) (featDefFilterArray),
- (int) FALSE,
- sizeof (featDefFilterArray));
- featDefFilterArray [featdef] = TRUE;
-
- SeqMgrExploreFeatures (bsp, NULL, SuppressGeneXref_Callback,
- NULL, NULL, featDefFilterArray);
- }
- else /* featdef != 0 */
- {
- MemSet ((Pointer) (seqFeatFilterArray),
- (int) FALSE,
- sizeof (seqFeatFilterArray));
- seqFeatFilterArray [seqfeat] = TRUE;
-
- SeqMgrExploreFeatures (bsp, NULL, SuppressGeneXref_Callback,
- NULL, seqFeatFilterArray, NULL);
- }
-}
-
/*=========================================================================*/
/* */
/* SuppressError_Callback () -- */
@@ -6793,29 +6991,173 @@ static void RestoreCDSGeneRangeError (IteM i)
return;
}
-/*=========================================================================*/
+/*-------------------------------------------------------------------------*/
/* */
-/* SuppressGenesOnAllRBS () -- Suppress gene xrefs on all RBS features */
+/* SuppressFeatureGeneXref () -- Suppresses any gene xref on the feature */
+/* that is passed to it. */
/* */
-/*=========================================================================*/
+/*-------------------------------------------------------------------------*/
+
+static void SuppressFeatureGeneXref (SeqFeatPtr sfp)
+{
+ GeneRefPtr grp = NULL;
+ SeqFeatXrefPtr xref;
+
+ if (sfp == NULL)
+ {
+ return;
+ }
+ /* If there is a gene xref, then change it */
+ /* to a suppression gene xref. */
+
+ grp = SeqMgrGetGeneXref (sfp);
+ if (grp != NULL)
+ {
+ if (SeqMgrGeneIsSuppressed (grp) == FALSE)
+ {
+ if (NULL != grp->locus)
+ {
+ MemFree(grp->locus);
+ grp->locus = NULL;
+ }
+ if (NULL != grp->allele)
+ {
+ MemFree(grp->allele);
+ grp->allele = NULL;
+ }
+ if (NULL != grp->desc)
+ {
+ MemFree(grp->desc);
+ grp->desc = NULL;
+ }
+ if (NULL != grp->maploc)
+ {
+ MemFree (grp->maploc);
+ grp->maploc = NULL;
+ }
+ if (NULL != grp->locus_tag)
+ {
+ MemFree (grp->locus_tag);
+ grp->locus_tag = NULL;
+ }
+ grp->db = ValNodeFreeData (grp->db);
+ grp->syn = ValNodeFreeData (grp->syn);
+ }
+ }
+ /* Otherwise, if there is an overlapping gene, add */
+ /* a suppression xref for it. */
+ else if (SeqMgrGetOverlappingGene (sfp->location, NULL) != NULL)
+ {
+ grp = GeneRefNew ();
+ if (grp != NULL)
+ {
+ xref = SeqFeatXrefNew ();
+ xref->data.choice = SEQFEAT_GENE;
+ xref->data.value.ptrvalue = grp;
+ xref->next = sfp->xref;
+ sfp->xref = xref;
+ }
+ }
+}
-static void DoOneSuppressGeneOnRBS (BioseqPtr bsp, Pointer userdata)
+/*=============================================================================*/
+/* */
+/* SuppressGenesOnFeatures () -- Suppress gene xrefs on selected feature types */
+/* */
+/*=============================================================================*/
+typedef struct suppressgenes
{
- /* Suppress the gene xrefs for all RBS features */
+ FORM_MESSAGE_BLOCK
+ DialoG feature_choice_dlg;
+ DialoG constraint_dlg;
+ ButtoN accept_btn;
+
+} SuppressGenesData, PNTR SuppressGenesPtr;
+
+static void SetSuppressGenesAccept (Pointer userdata)
+{
+ SuppressGenesPtr dlg;
+ ValNodePtr feature_type_list;
- SuppressGeneXrefsForFeatureType (bsp, 0, FEATDEF_RBS);
+ dlg = (SuppressGenesPtr) userdata;
+ if (dlg == NULL)
+ {
+ return;
+ }
+ feature_type_list = DialogToPointer (dlg->feature_choice_dlg);
+ if (feature_type_list == NULL)
+ {
+ Disable (dlg->accept_btn);
+ }
+ else
+ {
+ Enable (dlg->accept_btn);
+ }
+ feature_type_list = ValNodeFree (feature_type_list);
}
-static void SuppressGenesOnAllRBS (IteM i)
+static void SuppressOneGeneOnFeature (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr fsp)
+{
+ SuppressFeatureGeneXref (sfp);
+}
+static void DoSuppressGenesOnFeatures (ButtoN b)
{
- BaseFormPtr bfp;
- BioseqPtr bsp;
- Uint2 entityID;
- SeqEntryPtr sep;
+ SuppressGenesPtr dlg;
+ ValNodePtr feature_type_list, vnp;
+ FilterSetPtr fsp;
+ Int2 feat_def_choice;
+ SeqEntryPtr sep;
- /* Get the Bioseq */
+ dlg = (SuppressGenesPtr) GetObjectExtra (b);
+ if (dlg == NULL)
+ {
+ return;
+ }
+
+ sep = GetTopSeqEntryForEntityID (dlg->input_entityID);
+ if (sep == NULL)
+ {
+ return;
+ }
+
+ feature_type_list = DialogToPointer (dlg->feature_choice_dlg);
+ if (feature_type_list == NULL)
+ {
+ return;
+ }
+
+ fsp = (FilterSetPtr) DialogToPointer (dlg->constraint_dlg);
+
+ for (vnp = feature_type_list; vnp != NULL; vnp = vnp->next)
+ {
+ feat_def_choice = vnp->choice;
+ if (feat_def_choice == 255)
+ {
+ feat_def_choice = 0;
+ }
+ OperateOnSeqEntryConstrainedObjects (sep, fsp,
+ SuppressOneGeneOnFeature,
+ NULL, 0, feat_def_choice, 0, dlg);
+ }
+
+ ValNodeFree (feature_type_list);
+ FilterSetFree (fsp);
+
+ ObjMgrSetDirtyFlag (dlg->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, dlg->input_entityID, 0, 0);
+ Remove (dlg->form);
+ Update ();
+}
+
+static void SuppressGenesOnFeatures (IteM i)
+{
+ BaseFormPtr bfp;
+ SuppressGenesPtr dlg;
+ WindoW w;
+ GrouP h, c;
+ ButtoN b;
#ifdef WIN_MAC
bfp = currentFormDataPtr;
@@ -6824,25 +7166,36 @@ static void SuppressGenesOnAllRBS (IteM i)
#endif
if (bfp == NULL) return;
- bsp = GetBioseqGivenIDs (bfp->input_entityID, 1, OBJ_BIOSEQ);
- sep = SeqMgrGetSeqEntryForData (bsp);
- entityID = ObjMgrGetEntityIDForChoice (sep);
- sep = GetTopSeqEntryForEntityID (entityID);
-
- VisitBioseqsInSep (sep, NULL, DoOneSuppressGeneOnRBS);
-
- /* Force an update and redraw */
+ dlg = (SuppressGenesPtr) MemNew (sizeof (SuppressGenesData));
+ if (dlg == NULL) return;
+
+ w = FixedWindow (-50, -33, -10, -10, "Suppress Genes on Features", StdCloseWindowProc);
+ SetObjectExtra (w, dlg, StdCleanupExtraProc);
+ dlg->form = (ForM) w;
+ dlg->input_entityID = bfp->input_entityID;
+
+ h = HiddenGroup (w, -1, 0, NULL);
+ SetGroupSpacing (h, 10, 10);
- ObjMgrSetDirtyFlag (entityID, TRUE);
- ObjMgrSendMsg (OM_MSG_UPDATE, entityID, 0, 0);
- ArrowCursor ();
+ dlg->feature_choice_dlg = FeatureSelectionDialog (h, TRUE, SetSuppressGenesAccept, dlg);
+ dlg->constraint_dlg = FilterGroup (h, TRUE, FALSE, TRUE, FALSE, "Where feature text");
+
+ c = HiddenGroup (h, 2, 0, NULL);
+ dlg->accept_btn = PushButton (c, "Accept", DoSuppressGenesOnFeatures);
+ SetObjectExtra (dlg->accept_btn, dlg, NULL);
+ b = PushButton (c, "Cancel", StdCancelButtonProc);
+
+ AlignObjects (ALIGN_CENTER, (HANDLE) dlg->feature_choice_dlg,
+ (HANDLE) dlg->constraint_dlg,
+ (HANDLE) c,
+ NULL);
+ RealizeWindow (w);
+ Show (w);
+ Select (w);
Update ();
-
- /* Return successfully */
-
- return;
}
+
/*=======================================================================*/
/* */
/* CopyGeneRef () - */
@@ -7552,6 +7905,7 @@ static void EditMolInfoCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, In
MolInfoEditPtr miep;
MolInfoPtr mip;
ValNodePtr sdp;
+ Uint1 new_mol;
if (mydata == NULL) return;
if (sep == NULL || sep->data.ptrvalue == NULL) return;
@@ -7572,8 +7926,17 @@ static void EditMolInfoCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, In
{
if (GetValue (miep->to.molPopup) != 1)
{
- bsp->mol = (Uint1) GetValNodePopup (miep->to.molPopup,
- miep->to.mol_values);
+ new_mol = (Uint1) GetValNodePopup (miep->to.molPopup,
+ miep->to.mol_values);
+ if (ISA_na (bsp->mol) && ISA_aa (new_mol))
+ {
+ BioseqConvert (bsp, Seq_code_ncbieaa);
+ }
+ else if (ISA_aa (bsp->mol) && ISA_na (new_mol))
+ {
+ BioseqConvert (bsp, Seq_code_ncbi2na);
+ }
+ bsp->mol = new_mol;
}
}
if ((Uint1)GetValNodePopup (miep->from.strandPopup,
@@ -10360,8 +10723,10 @@ static void AttcBioSourceStrainToXref (BioSourcePtr biop)
if (onp == NULL) return;
for (omp = onp->mod; omp != NULL; omp = omp->next) {
if (omp->subtype == ORGMOD_strain) {
- if (StringNICmp (omp->subname, "ATCC", 4) == 0) {
- str = omp->subname + 4;
+ str = StringISearch (omp->subname, "ATCC");
+ if (str != NULL)
+ {
+ str += 4;
ch = *str;
while (IS_WHITESP (ch) || ch == ':') {
str++;
@@ -13755,7 +14120,36 @@ static Boolean AmbiguousCdsMrna (BioseqPtr bsp)
return FALSE;
}
-static void InstantiateMrnaIntoProt (SeqFeatPtr cds, SeqFeatPtr mrna, Int2Ptr ctrp)
+static SeqIdPtr MakeIdFromLocusTag (SeqFeatPtr mrna)
+
+{
+ Char buf [64];
+ SeqFeatPtr gene;
+ GeneRefPtr grp;
+
+ if (mrna == NULL) return NULL;
+ grp = SeqMgrGetGeneXref (mrna);
+ if (grp != NULL) {
+ if (SeqMgrGeneIsSuppressed (grp)) return NULL;
+ }
+ if (grp == NULL) {
+ gene = SeqMgrGetOverlappingGene (mrna->location, NULL);
+ if (gene != NULL) {
+ grp = (GeneRefPtr) gene->data.value.ptrvalue;
+ }
+ }
+ if (grp != NULL) {
+ if (StringDoesHaveText (grp->locus_tag)) {
+ /* StringCpy (buf, "lcl|"); */
+ StringCpy (buf, "gnl|MTRACK|");
+ StringCat (buf, grp->locus_tag);
+ return MakeSeqID (buf);
+ }
+ }
+ return NULL;
+}
+
+static void InstantiateMrnaIntoProt (SeqFeatPtr cds, SeqFeatPtr mrna, Int2Ptr ctrp, Boolean useLocusTag)
{
ByteStorePtr bs;
@@ -13793,7 +14187,14 @@ static void InstantiateMrnaIntoProt (SeqFeatPtr cds, SeqFeatPtr mrna, Int2Ptr ct
mbsp->length = BSLen (bs);
BioseqPack (mbsp);
- mbsp->id = MakeNewProteinSeqIdEx (mrna->location, NULL, NULL, ctrp);
+ if (useLocusTag) {
+ mbsp->id = MakeIdFromLocusTag (mrna);
+ if (mbsp->id == NULL) {
+ mbsp->id = MakeNewProteinSeqIdEx (mrna->location, NULL, NULL, ctrp);
+ }
+ } else {
+ mbsp->id = MakeNewProteinSeqIdEx (mrna->location, NULL, NULL, ctrp);
+ }
CheckSeqLocForPartial (mrna->location, &partial5, &partial3);
SeqMgrAddToBioseqIndex (mbsp);
@@ -13823,7 +14224,7 @@ static void InstantiateMrnaIntoProt (SeqFeatPtr cds, SeqFeatPtr mrna, Int2Ptr ct
AddSeqEntryToSeqEntry (psep, msep, FALSE);
}
-static void NPStoGPS (IteM i)
+static void NPStoGPS (IteM i, Boolean useLocusTag)
{
BaseFormPtr bfp;
@@ -13907,7 +14308,7 @@ static void NPStoGPS (IteM i)
mrna = SeqMgrGetOverlappingFeature (sfp->location, FEATDEF_mRNA, NULL, 0,
NULL, CHECK_INTERVALS, &mcontext);
if (mrna != NULL) {
- InstantiateMrnaIntoProt (sfp, mrna, &ctr);
+ InstantiateMrnaIntoProt (sfp, mrna, &ctr, useLocusTag);
}
sfp = SeqMgrGetNextFeature (bsp, sfp, SEQFEAT_CDREGION, 0, &fcontext);
}
@@ -13957,6 +14358,18 @@ static void NPStoGPS (IteM i)
Update ();
}
+static void NPStoGPSLocusTag (IteM i)
+
+{
+ NPStoGPS (i, TRUE);
+}
+
+static void NPStoGPSArbitrary (IteM i)
+
+{
+ NPStoGPS (i, FALSE);
+}
+
static void MakePhrap (IteM i)
{
@@ -15752,7 +16165,7 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
}
- i = CommandItem (s, "Suppress Genes On All RBS", SuppressGenesOnAllRBS);
+ i = CommandItem (s, "Suppress Genes On Features", SuppressGenesOnFeatures);
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Suppress CDSGeneRange Error", SuppressCDSGeneRangeError);
SetObjectExtra (i, bfp, NULL);
@@ -15824,6 +16237,8 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
SetObjectExtra (i, bfp, NULL);
i = CommandItem (x, "Ignore Stop Codon Except at End of Complete CDS", RetranslateCdRegionsNoStopExceptEndCompleteCDS);
SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Adjust CDS Locations for Gaps", AdjustCDSLocationsForGaps);
+ SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Retranscribe mRNA Products", ReprocessmRNAProducts);
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Regenerate Peptide Products", ReprocessPeptideProducts);
@@ -15931,7 +16346,10 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
i = CommandItem (s, "Add mRNA Titles to GenProdSet", MrnaTitlesToGPS);
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
- i = CommandItem (s, "Promote NucProtSet to GenProdSet", NPStoGPS);
+ x = SubMenu (s, "Promote NucProtSet to GenProdSet");
+ i = CommandItem (x, "Locus Tag ID", NPStoGPSLocusTag);
+ SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (x, "Arbitrary ID", NPStoGPSArbitrary);
SetObjectExtra (i, bfp, NULL);
}
@@ -15952,14 +16370,7 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
i = CommandItem (s, "Gene Xrefs from Features", GeneToXref);
SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
- x = SubMenu (s, "Gene Features From");
- i = CommandItem (x, "CDS", CdsToGene);
- SetObjectExtra (i, bfp, NULL);
- i = CommandItem (x, "tRNA", tRNAtoGene);
- SetObjectExtra (i, bfp, NULL);
- i = CommandItem (x, "rRNA", rRNAtoGene);
- SetObjectExtra (i, bfp, NULL);
- i = CommandItem (x, "miscRNA", MiscRNAtoGene);
+ i = CommandItem (s, "Gene Features From Other Features", FeatureToGene);
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "CDS Features from Gene", GeneToCds);
SetObjectExtra (i, bfp, NULL);
@@ -15987,6 +16398,8 @@ extern void SetupSpecialMenu (MenU m, BaseFormPtr bfp)
SetObjectExtra (i, bfp, NULL);
i = CommandItem (s, "Merge Multiple CDS Into One", MergeCDS);
SetObjectExtra (i, bfp, NULL);
+ i = CommandItem (s, "Convert CDS to mat_peptide", CombineMultipleCDS);
+ SetObjectExtra (i, bfp, NULL);
SeparatorItem (s);
i = CommandItem (s, "Reload Publications", LookupAllPubs);
SetObjectExtra (i, bfp, NULL);
diff --git a/sequin/sequin4.c b/sequin/sequin4.c
index 707e7a30..ecbb91ab 100644
--- a/sequin/sequin4.c
+++ b/sequin/sequin4.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 6/28/96
*
-* $Revision: 6.296 $
+* $Revision: 6.300 $
*
* File Description:
*
@@ -431,7 +431,7 @@ static void FindSegSetComponentsCallback (SeqEntryPtr sep, Pointer mydata,
ussp = (UpdateSegStrucPtr) mydata;
if (sep->choice == 1) {
bsp = (BioseqPtr) sep->data.ptrvalue;
- if (ISA_na (bsp->mol) && bsp->repr == Seq_repr_seg) {
+ if (bsp->repr == Seq_repr_seg) {
ussp->segseq = bsp;
}
} else if (sep->choice == 2) {
@@ -2056,6 +2056,38 @@ static void RemoveIntermediateGenBankWrapper (BioseqSetPtr bssp)
SeqEntryFree (this_sep);
}
+static Boolean SetContainsProteins (BioseqSetPtr bssp)
+{
+ BioseqPtr bsp;
+ SeqEntryPtr sep;
+ Boolean has_proteins = FALSE;
+
+ if (bssp == NULL || bssp->seq_set == NULL)
+ {
+ return FALSE;
+ }
+
+ for (sep = bssp->seq_set; sep != NULL && !has_proteins; sep = sep->next)
+ {
+ if (sep->data.ptrvalue == NULL)
+ {
+ continue;
+ }
+ if (IS_Bioseq (sep))
+ {
+ bsp = (BioseqPtr) sep->data.ptrvalue;
+ if (ISA_aa (bsp->mol))
+ {
+ has_proteins = TRUE;
+ }
+ }
+ else if (IS_Bioseq_set (sep))
+ {
+ has_proteins |= SetContainsProteins (sep->data.ptrvalue);
+ }
+ }
+ return has_proteins;
+}
static void
RemoveOneSegSet
@@ -2064,7 +2096,8 @@ RemoveOneSegSet
BioseqSetPtr target_bssp,
Uint2 entityID)
{
- SeqEntryPtr seg_list, seg_sep, protein_list, prot_sep;
+ SeqEntryPtr protein_list = NULL;
+ SeqEntryPtr seg_list, seg_sep, prot_sep;
SeqEntryPtr prev_prot_sep, next_prot_sep;
BioseqPtr seg_bsp;
SeqEntryPtr this_prot_list, last_this;
@@ -2084,7 +2117,9 @@ RemoveOneSegSet
target_bssp = (BioseqSetPtr) this_sep->data.ptrvalue;
- if (parent_bssp != NULL && parent_bssp->_class == BioseqseqSet_class_nuc_prot)
+ if (parent_bssp != NULL
+ && parent_bssp->_class == BioseqseqSet_class_nuc_prot
+ && !SetContainsProteins (target_bssp))
{
seg_list = target_bssp->seq_set;
target_bssp->seq_set = NULL;
@@ -2156,7 +2191,7 @@ RemoveOneSegSet
}
prot_sep = next_prot_sep;
}
-
+
if (this_prot_list != NULL)
{
seg_nuc_prot = BioseqSetNew ();
@@ -2173,10 +2208,26 @@ RemoveOneSegSet
parent_bssp->seq_set = seg_list;
}
+ if (protein_list != NULL && parent_bssp != NULL)
+ {
+ seg_sep = parent_bssp->seq_set;
+ while (seg_sep != NULL && seg_sep->next != NULL)
+ {
+ seg_sep = seg_sep->next;
+ }
+ if (seg_sep == NULL)
+ {
+ parent_bssp->seq_set = protein_list;
+ }
+ else
+ {
+ seg_sep->next = protein_list;
+ }
+ }
+
/* if we have just put a genbank set inside another genbank set, move the nuc-prot sets
* up. */
RemoveIntermediateGenBankWrapper (parent_bssp);
-
}
static void
@@ -2248,23 +2299,24 @@ static Int2 LIBCALLBACK RemoveSet (Pointer data)
top_sep = GetTopSeqEntryForEntityID (ompcp->input_entityID);
if (top_sep == NULL) return OM_MSG_RET_ERROR;
- SaveSeqEntryObjMgrData (top_sep, &omdptop, &omdata);
- GetSeqEntryParent (top_sep, &top_parentptr, &top_parenttype);
-
this_sep = SeqMgrGetSeqEntryForData (ompcp->input_data);
GetSeqEntryParent (this_sep, &parentptr, &parenttype);
if (parenttype != OBJ_BIOSEQSET || parentptr == NULL)
{
+ Message (MSG_ERROR, "Can't remove top set!");
return OM_MSG_RET_ERROR;
}
-
+
+ SaveSeqEntryObjMgrData (top_sep, &omdptop, &omdata);
+ GetSeqEntryParent (top_sep, &top_parentptr, &top_parenttype);
+
target_bssp = (BioseqSetPtr) ompcp->input_data;
parent_bssp = (BioseqSetPtr) parentptr;
if (parent_bssp->_class == BioseqseqSet_class_not_set
|| parent_bssp->_class == BioseqseqSet_class_segset
- || parent_bssp->_class == BioseqseqSet_class_parts)
+ || parent_bssp->_class == BioseqseqSet_class_parts)
{
Message (MSG_ERROR, "Can't move sequences up into parent");
return OM_MSG_RET_ERROR;
@@ -2286,7 +2338,8 @@ static Int2 LIBCALLBACK RemoveSet (Pointer data)
DoFixupLocus (top_sep);
DoFixupSegSet (top_sep);
}
- else if (parent_bssp->_class == BioseqseqSet_class_nuc_prot)
+ else if (parent_bssp->_class == BioseqseqSet_class_nuc_prot
+ && ! SetContainsProteins (target_bssp))
{
Message (MSG_ERROR, "Can't move sequences up into parent");
return OM_MSG_RET_ERROR;
@@ -4193,38 +4246,56 @@ static Int2 CreateOneAlignment
sip2 = SeqIdDup(sbp->bsp->id);
revcomp = FALSE;
salp = Sqn_GlobalAlign2Seq(bsp, sbp->bsp, &revcomp);
- if (revcomp) {
- if (flip_for_aln)
- {
- if (!flip_feat)
- {
- ReverseBioseqFeatureStrands (sbp->bsp);
- }
- if (num_reversed == 0)
- {
- fprintf (fp, "The following sequences were reversed in order to "
- "construct the alignment:\n");
- }
- sip = SeqIdFindBest(sbp->bsp->id, 0);
- SeqIdWrite (sip, buf, PRINTID_REPORT, sizeof (buf) - 1);
- fprintf (fp, "%s\n", buf);
- num_reversed ++;
- }
- else
+
+ /* count the number of sequences we are trying to align */
+ num_seqs ++;
+
+ if (salp != NULL
+ && ! ValidateSeqAlign (salp, entityID, FALSE, FALSE, TRUE, FALSE, FALSE, &dirty))
+ {
+ /* if an alignment was created and the sequence was reversed to create the alignment,
+ * but the new alignment wasn't valid, un-reverse the sequence and don't add the
+ * sequence to the list of sequences reversed.
+ */
+ salp = SeqAlignFree (salp);
+ if (revcomp)
{
BioseqRevComp (sbp->bsp);
ReverseBioseqFeatureStrands (sbp->bsp);
- ReverseAlignmentStrand (salp, 2);
+ revcomp = FALSE;
}
- revcomp = FALSE;
- }
- num_seqs ++;
- if (!ValidateSeqAlign (salp, entityID, FALSE, FALSE, TRUE, FALSE, FALSE, &dirty))
- {
- salp = SeqAlignFree (salp);
}
+
if (salp != NULL)
{
+ if (revcomp) {
+ if (flip_for_aln)
+ {
+ if (!flip_feat)
+ {
+ ReverseBioseqFeatureStrands (sbp->bsp);
+ }
+ if (num_reversed == 0)
+ {
+ fprintf (fp, "The following sequences were reversed in order to "
+ "construct the alignment:\n");
+ }
+ sip = SeqIdFindBest(sbp->bsp->id, 0);
+ SeqIdWrite (sip, buf, PRINTID_REPORT, sizeof (buf) - 1);
+ fprintf (fp, "%s\n", buf);
+ num_reversed ++;
+ }
+ else
+ {
+ /* un-reverse the sequence */
+ BioseqRevComp (sbp->bsp);
+ ReverseBioseqFeatureStrands (sbp->bsp);
+ /* change the alignment to show the reversed strand */
+ ReverseAlignmentStrand (salp, 2);
+ }
+ revcomp = FALSE;
+ }
+
dsp = (DenseSegPtr)(salp->segs);
SeqIdSetFree(dsp->ids);
dsp->ids = sip1;
@@ -10624,23 +10695,29 @@ extern void ProcessPseudoMiscFeat (IteM i)
Update ();
}
-static void ParseInfluenzaAVirusNamesCallback (BioSourcePtr biop, Pointer userdata)
-{
- CharPtr desired_name = "Influenza A virus";
- Int4 desired_len = StringLen (desired_name);
- CharPtr first_paren = NULL, second_paren = NULL;
- CharPtr first_paren_close = NULL, second_paren_close = NULL;
- CharPtr cp;
- Int4 strain_len, serotype_len;
- CharPtr strain, serotype;
- OrgModPtr strain_omp, serotype_omp, last_omp, omp;
- Boolean added_strain = FALSE, added_serotype = FALSE;
-
- if (biop == NULL || biop->org == NULL || biop->org->taxname == NULL) return;
+static Boolean
+IsParseableInfluenzaAVirusBioSource
+(BioSourcePtr biop,
+ CharPtr PNTR strain,
+ CharPtr PNTR serotype)
+{
+ CharPtr desired_name = "Influenza A virus";
+ Int4 desired_len = StringLen (desired_name);
+ CharPtr first_paren = NULL, second_paren = NULL;
+ CharPtr first_paren_close = NULL, second_paren_close = NULL;
+ CharPtr cp;
+ Int4 strain_len, serotype_len;
+
+ if (biop == NULL || biop->org == NULL || biop->org->taxname == NULL
+ || strain == NULL
+ || serotype == NULL)
+ {
+ return FALSE;
+ }
if (StringNCmp (biop->org->taxname, desired_name, desired_len) != 0)
{
- return;
+ return FALSE;
}
first_paren = StringChr (biop->org->taxname + desired_len, '(');
@@ -10652,7 +10729,7 @@ static void ParseInfluenzaAVirusNamesCallback (BioSourcePtr biop, Pointer userda
}
if (*cp != '(')
{
- return;
+ return FALSE;
}
second_paren = cp;
cp++;
@@ -10662,7 +10739,7 @@ static void ParseInfluenzaAVirusNamesCallback (BioSourcePtr biop, Pointer userda
}
if (*cp != ')')
{
- return;
+ return FALSE;
}
second_paren_close = cp;
cp++;
@@ -10672,10 +10749,45 @@ static void ParseInfluenzaAVirusNamesCallback (BioSourcePtr biop, Pointer userda
}
if (*cp != ')')
{
- return;
+ return FALSE;
}
first_paren_close = cp;
+ strain_len = second_paren - first_paren + first_paren_close - second_paren_close;
+ serotype_len = second_paren_close - second_paren;
+ *strain = (CharPtr) MemNew (strain_len * sizeof (Char));
+ *serotype = (CharPtr) MemNew (serotype_len * sizeof (Char));
+ if (*strain == NULL || *serotype == NULL)
+ {
+ *strain = MemFree (*strain);
+ *serotype = MemFree (*serotype);
+ return FALSE;
+ }
+ StringNCpy (*strain, first_paren + 1, second_paren - first_paren - 1);
+ if (first_paren_close - second_paren_close > 1)
+ {
+ StringCat (*strain, " ");
+ StringNCat (*strain, second_paren_close + 1, first_paren_close - second_paren_close - 1);
+ }
+ StringNCpy (*serotype, second_paren + 1, second_paren_close - second_paren - 1);
+
+ return TRUE;
+}
+
+static void ParseInfluenzaAVirusNamesCallback (BioSourcePtr biop, Pointer userdata)
+{
+ CharPtr strain = NULL, serotype = NULL;
+ OrgModPtr strain_omp, serotype_omp, last_omp, omp;
+ Boolean added_strain = FALSE, added_serotype = FALSE;
+ ExistingTextPtr etp;
+
+ etp = (ExistingTextPtr) userdata;
+
+ if (!IsParseableInfluenzaAVirusBioSource (biop, &strain, &serotype))
+ {
+ return;
+ }
+
if (biop->org->orgname == NULL)
{
biop->org->orgname = OrgNameNew ();
@@ -10685,24 +10797,6 @@ static void ParseInfluenzaAVirusNamesCallback (BioSourcePtr biop, Pointer userda
}
}
- strain_len = second_paren - first_paren + first_paren_close - second_paren_close;
- serotype_len = second_paren_close - second_paren;
- strain = (CharPtr) MemNew (strain_len * sizeof (Char));
- serotype = (CharPtr) MemNew (serotype_len * sizeof (Char));
- if (strain == NULL || serotype == NULL)
- {
- strain = MemFree (strain);
- serotype = MemFree (serotype);
- return;
- }
- StringNCpy (strain, first_paren + 1, second_paren - first_paren - 1);
- if (first_paren_close - second_paren_close > 1)
- {
- StringCat (strain, " ");
- StringNCat (strain, second_paren_close + 1, first_paren_close - second_paren_close - 1);
- }
- StringNCpy (serotype, second_paren + 1, second_paren_close - second_paren - 1);
-
last_omp = NULL;
for (omp = biop->org->orgname->mod;
omp != NULL && (!added_strain || ! added_serotype);
@@ -10710,14 +10804,12 @@ static void ParseInfluenzaAVirusNamesCallback (BioSourcePtr biop, Pointer userda
{
if (omp->subtype == ORGMOD_strain)
{
- omp->subname = MemFree (omp->subname);
- omp->subname = strain;
+ omp->subname = HandleExistingText (omp->subname, strain, etp);
added_strain = TRUE;
}
else if (omp->subtype == ORGMOD_serotype)
{
- omp->subname = MemFree (omp->subname);
- omp->subname = serotype;
+ omp->subname = HandleExistingText (omp->subname, serotype, etp);
added_serotype = TRUE;
}
last_omp = omp;
@@ -10757,13 +10849,67 @@ static void ParseInfluenzaAVirusNamesCallback (BioSourcePtr biop, Pointer userda
}
}
}
+}
+
+static void ParseInfluenzaAVirusNamesSample (BioSourcePtr biop, Pointer userdata)
+{
+ CharPtr strain = NULL, serotype = NULL;
+ GetSamplePtr gsp;
+ OrgModPtr omp;
+ Boolean found_strain = FALSE, found_serotype = FALSE;
+ CharPtr overwrite_val;
+
+ if (biop == NULL || biop->org == NULL || biop->org->orgname == NULL || userdata == NULL)
+ {
+ return;
+ }
+
+ gsp = (GetSamplePtr) userdata;
+
+ if (!IsParseableInfluenzaAVirusBioSource (biop, &strain, &serotype))
+ {
+ return;
+ }
+ for (omp = biop->org->orgname->mod;
+ omp != NULL && (!found_strain || !found_serotype);
+ omp = omp->next)
+ {
+ overwrite_val = NULL;
+ if (omp->subtype == ORGMOD_strain)
+ {
+ found_strain = TRUE;
+ overwrite_val = omp->subname;
+ }
+ else if (omp->subtype == ORGMOD_serotype)
+ {
+ found_serotype = TRUE;
+ overwrite_val = omp->subname;
+ }
+ if (!StringHasNoText (overwrite_val))
+ {
+ gsp->num_found ++;
+ if (gsp->sample_text == NULL)
+ {
+ gsp->sample_text = StringSave (overwrite_val);
+ }
+ else if (StringCmp (gsp->sample_text, overwrite_val) != 0)
+ {
+ gsp->all_same = FALSE;
+ }
+ }
+ }
+
+ strain = MemFree (strain);
+ serotype = MemFree (serotype);
}
extern void ParseInfluenzaAVirusNames (IteM i)
{
- BaseFormPtr bfp;
- SeqEntryPtr sep;
+ BaseFormPtr bfp;
+ SeqEntryPtr sep;
+ GetSamplePtr gsp;
+ ExistingTextPtr etp;
#ifdef WIN_MAC
bfp = currentFormDataPtr;
@@ -10774,7 +10920,16 @@ extern void ParseInfluenzaAVirusNames (IteM i)
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
if (sep == NULL) return;
- VisitBioSourcesInSep (sep, NULL, ParseInfluenzaAVirusNamesCallback);
+
+ gsp = GetSampleNew ();
+ VisitBioSourcesInSep (sep, gsp, ParseInfluenzaAVirusNamesSample);
+ etp = GetExistingTextHandlerInfo (gsp, FALSE);
+ gsp = GetSampleFree (gsp);
+ if (etp == NULL || etp->existing_text_choice != EXISTING_TEXT_CHOICE_CANCEL)
+ {
+ VisitBioSourcesInSep (sep, etp, ParseInfluenzaAVirusNamesCallback);
+ }
+ etp = MemFree (etp);
ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
Update ();
diff --git a/sequin/sequin5.c b/sequin/sequin5.c
index 36677b64..7c15a2e4 100644
--- a/sequin/sequin5.c
+++ b/sequin/sequin5.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 8/26/97
*
-* $Revision: 6.387 $
+* $Revision: 6.404 $
*
* File Description:
*
@@ -73,7 +73,7 @@
#include <asn2gnbp.h> /* added for mockup parse to flatfile */
#include <seqpanel.h> /* added to include SeqEdTranslateOneCDS */
-
+#include <salpanel.h>
static void CommonLaunchBioseqViewer (SeqEntryPtr sep, CharPtr path, Boolean directToEditor)
@@ -3608,7 +3608,7 @@ static LocationConstraintPtr LocationConstraintCopy (LocationConstraintPtr lcp)
return lcp_new;
}
-static StringConstraintPtr StringConstraintFree (StringConstraintPtr scp)
+extern StringConstraintPtr StringConstraintFree (StringConstraintPtr scp)
{
if (scp == NULL) return NULL;
scp->match_text = MemFree (scp->match_text);
@@ -3710,7 +3710,7 @@ static void ChoiceConstraintClearText (ChoiceConstraintPtr scp)
}
-static void FilterSetClearText (FilterSetPtr fsp)
+extern void FilterSetClearText (FilterSetPtr fsp)
{
if (fsp != NULL)
{
@@ -3720,7 +3720,7 @@ static void FilterSetClearText (FilterSetPtr fsp)
}
}
-static void FilterSetFree (FilterSetPtr fsp)
+extern FilterSetPtr FilterSetFree (FilterSetPtr fsp)
{
if (fsp != NULL)
{
@@ -3728,7 +3728,9 @@ static void FilterSetFree (FilterSetPtr fsp)
fsp->ccp = ChoiceConstraintFree (fsp->ccp);
fsp->lcp = LocationConstraintFree (fsp->lcp);
fsp->cgp = ChoiceConstraintFree (fsp->cgp);
+ fsp = MemFree (fsp);
}
+ return fsp;
}
static FilterSetPtr FilterSetCopy (FilterSetPtr fsp)
@@ -3811,19 +3813,6 @@ static SetSamplePtr SetSampleCopy (SetSamplePtr ssp)
return ssp_new;
}
-typedef struct getsample
-{
- GetFeatureFieldString fieldstring_func;
- GetDescriptorFieldString descrstring_func;
- ValNodePtr requested_field;
- FreeValNodeProc free_vn_proc;
- CopyValNodeDataProc copy_vn_proc;
-
- CharPtr sample_text;
- Int4 num_found;
- Boolean all_same;
-} GetSampleData, PNTR GetSamplePtr;
-
#define PARSE_FIELD_DEFLINE 1
#define PARSE_FIELD_BIOSRC_STRING 2
#define PARSE_FIELD_SOURCE_QUAL 3
@@ -3840,27 +3829,6 @@ typedef struct getsample
#define PARSE_FIELD_LAST_FEATURE 9
extern Boolean DoesLocationMatchConstraint (SeqLocPtr slp, LocationConstraintPtr lcp);
-extern void
-OperateOnSeqEntryConstrainedObjects
-(SeqEntryPtr sep,
- FilterSetPtr fsp,
- FeatureActionProc feature_action,
- DescriptorActionProc descriptor_action,
- Uint1 seqFeatChoice,
- Uint1 featDefChoice,
- Uint1 descriptorChoice,
- Pointer userdata);
-
-extern DialoG AcceptCancelDialog
-(GrouP parent,
- Nlm_AcceptActnProc accept_actn,
- Nlm_CancelActnProc cancel_actn,
- Nlm_ClearActnProc clear_actn,
- Nlm_ClearTextActnProc clear_text_actn,
- Pointer userdata,
- WindoW w);
-extern void EnableAcceptCancelDialogAccept (DialoG d);
-extern void DisableAcceptCancelDialogAccept (DialoG d);
typedef struct acceptpolicy
{
@@ -4077,237 +4045,7 @@ extern void DisableAcceptCancelDialogAccept (DialoG d)
}
-typedef struct sequenceselection
-{
- DIALOG_MESSAGE_BLOCK
- DialoG sequence_list_dlg;
- ValNodePtr sequence_choice_list;
-} SequenceSelectionData, PNTR SequenceSelectionPtr;
-
-static void CleanupSequenceSelectionDialogForm (GraphiC g, VoidPtr data)
-
-{
- SequenceSelectionPtr dlg;
-
- dlg = (SequenceSelectionPtr) data;
- if (dlg != NULL) {
- dlg->sequence_choice_list = ValNodeFree (dlg->sequence_choice_list);
- }
- StdCleanupExtraProc (g, data);
-}
-
-static void ResetSequenceSelectionDialog (SequenceSelectionPtr dlg)
-{
- if (dlg != NULL)
- {
- PointerToDialog (dlg->sequence_list_dlg, NULL);
- }
-}
-
-static void SequenceSelectionListToSequenceSelectionDialog (DialoG d, Pointer userdata)
-{
- SequenceSelectionPtr dlg;
- ValNodePtr sequence_list, vnp_list, vnp_sel, pos_list = NULL;
- Int4 i;
- SeqIdPtr sip;
- Boolean found;
-
- dlg = (SequenceSelectionPtr) GetObjectExtra (d);
- if (dlg == NULL)
- {
- return;
- }
-
- ResetSequenceSelectionDialog (dlg);
- sequence_list = (ValNodePtr) userdata;
- for (vnp_list = sequence_list; vnp_list != NULL; vnp_list = vnp_list->next)
- {
- sip = (SeqIdPtr) vnp_list->data.ptrvalue;
- found = FALSE;
- while (sip != NULL && ! found)
- {
- for (vnp_sel = dlg->sequence_choice_list, i = 1;
- vnp_sel != NULL && !found;
- vnp_sel = vnp_sel->next, i++)
- {
- found = SeqIdIn (sip, vnp_sel->data.ptrvalue);
- if (found)
- {
- ValNodeAddInt (&pos_list, 0, i);
- }
- }
- sip = sip->next;
- }
- }
- PointerToDialog (dlg->sequence_list_dlg, pos_list);
- ValNodeFree (pos_list);
-}
-
-static Pointer SequenceSelectionDialogToSequenceSelectionList (DialoG d)
-{
- SequenceSelectionPtr dlg;
- ValNodePtr sequence_list = NULL, vnp_list, pos_list, vnp_pos;
- Int4 i;
-
- dlg = (SequenceSelectionPtr) GetObjectExtra (d);
- if (dlg == NULL)
- {
- return NULL;
- }
-
- pos_list = DialogToPointer (dlg->sequence_list_dlg);
- for (vnp_pos = pos_list; vnp_pos != NULL; vnp_pos = vnp_pos->next)
- {
- for (i = 1, vnp_list = dlg->sequence_choice_list;
- i < vnp_pos->data.intvalue && vnp_list != NULL;
- i++, vnp_list = vnp_list->next)
- {
- }
- if (i == vnp_pos->data.intvalue && vnp_list != NULL)
- {
- ValNodeAddPointer (&sequence_list, 0, vnp_list->data.ptrvalue);
- }
- }
- return sequence_list;
-}
-
-static void
-GetSequenceChoiceList
-(SeqEntryPtr sep,
- ValNodePtr PNTR list,
- Boolean show_nucs,
- Boolean show_prots)
-{
- BioseqPtr bsp;
- BioseqSetPtr bssp;
-
- if (sep == NULL) return;
-
- if (IS_Bioseq (sep))
- {
- bsp = (BioseqPtr) sep->data.ptrvalue;
- if (bsp == NULL) return;
- if (!show_nucs && ISA_na (bsp->mol))
- {
- return;
- }
- if (!show_prots && ISA_aa (bsp->mol))
- {
- return;
- }
- ValNodeAddPointer (list, 0, bsp->id);
- }
- else
- {
- bssp = (BioseqSetPtr) sep->data.ptrvalue;
- for (sep = bssp->seq_set; sep != NULL; sep = sep->next)
- {
- GetSequenceChoiceList (sep, list, show_nucs, show_prots);
- }
- }
-}
-
-static void SequenceSelectionDialogMessage (DialoG d, Int2 mssg)
-
-{
- SequenceSelectionPtr dlg;
-
- dlg = (SequenceSelectionPtr) GetObjectExtra (d);
- if (dlg != NULL) {
- switch (mssg) {
- case VIB_MSG_INIT :
- /* reset list */
- ResetSequenceSelectionDialog (dlg);
- break;
- case VIB_MSG_SELECT:
- Select (dlg->sequence_list_dlg);
- break;
- case VIB_MSG_ENTER :
- Select (dlg->sequence_list_dlg);
- break;
- case NUM_VIB_MSG + 1:
- SendMessageToDialog (dlg->sequence_list_dlg, NUM_VIB_MSG + 1);
- break;
- default :
- break;
- }
- }
-}
-
-static ValNodePtr TestSequenceSelectionDialog (DialoG d)
-
-{
- SequenceSelectionPtr dlg;
- ValNodePtr head = NULL;
- dlg = (SequenceSelectionPtr) GetObjectExtra (d);
- if (dlg != NULL) {
- head = TestDialog (dlg->sequence_list_dlg);
- }
- return head;
-}
-
-
-extern DialoG SequenceSelectionDialog
-(GrouP h,
- Nlm_ChangeNotifyProc change_notify,
- Pointer change_userdata,
- Boolean allow_multi,
- Boolean show_nucs,
- Boolean show_prots,
- Uint2 entityID)
-
-{
- SequenceSelectionPtr dlg;
- GrouP p;
- ValNodePtr vnp;
- SeqEntryPtr sep;
- SeqIdPtr sip;
- Char tmp[128];
- ValNodePtr choice_name_list = NULL;
-
- if (!show_nucs && ! show_prots)
- {
- return NULL;
- }
-
- sep = GetTopSeqEntryForEntityID (entityID);
- if (sep == NULL)
- {
- return NULL;
- }
-
- dlg = (SequenceSelectionPtr) MemNew (sizeof (SequenceSelectionData));
- if (dlg == NULL)
- {
- return NULL;
- }
-
- p = HiddenGroup (h, 1, 0, NULL);
- SetObjectExtra (p, dlg, CleanupSequenceSelectionDialogForm);
-
- dlg->dialog = (DialoG) p;
- dlg->todialog = SequenceSelectionListToSequenceSelectionDialog;
- dlg->fromdialog = SequenceSelectionDialogToSequenceSelectionList;
- dlg->dialogmessage = SequenceSelectionDialogMessage;
- dlg->testdialog = TestSequenceSelectionDialog;
-
- dlg->sequence_choice_list = NULL;
- GetSequenceChoiceList (sep, &dlg->sequence_choice_list, show_nucs, show_prots);
-
-
- for (vnp = dlg->sequence_choice_list; vnp != NULL; vnp = vnp->next) {
- sip = SeqIdFindWorst ((SeqIdPtr) vnp->data.ptrvalue);
- SeqIdWrite (sip, tmp, PRINTID_REPORT, sizeof (tmp));
- ValNodeAddPointer (&choice_name_list, 0, StringSave (tmp));
- }
-
- dlg->sequence_list_dlg = SelectionDialog (p, change_notify, change_userdata,
- allow_multi, "sequence",
- choice_name_list, TALL_SELECTION_LIST);
- ValNodeFreeData (choice_name_list);
- return (DialoG) p;
-}
static ValNodePtr ValNodeAppend (ValNodePtr list, ValNodePtr second_list)
@@ -4330,7 +4068,7 @@ static ValNodePtr ValNodeAppend (ValNodePtr list, ValNodePtr second_list)
return list;
}
-static ValNodePtr BuildFeatureDialogList (Boolean list_most_used_first)
+extern ValNodePtr BuildFeatureDialogList (Boolean list_most_used_first)
{
ValNodePtr feature_choice_list = NULL;
ValNodePtr import_feature_list = NULL;
@@ -4525,7 +4263,7 @@ static ValNodePtr FeatureSelectionRemap (ValNodePtr orig_list)
return orig_list;
}
-static DialoG
+extern DialoG
FeatureSelectionDialog
(GrouP h,
Boolean allow_multi,
@@ -5783,9 +5521,11 @@ static DialoG GBQualSelectionDialog
static CharPtr GetGBQualString (SeqFeatPtr sfp, ValNodePtr vnp, FilterSetPtr fsp)
{
- GBQualPtr gbqual;
- CharPtr str = NULL;
- Int4 field_choice;
+ GBQualPtr gbqual;
+ CharPtr str = NULL;
+ Int4 field_choice;
+ RnaRefPtr rrp;
+ GeneRefPtr grp;
if (sfp == NULL)
{
@@ -5808,6 +5548,25 @@ static CharPtr GetGBQualString (SeqFeatPtr sfp, ValNodePtr vnp, FilterSetPtr fsp
str = StringSave (sfp->except_text);
}
}
+ else if (StringICmp (EditQualifierList[field_choice - 1].name, "product") == 0
+ && sfp->data.choice == SEQFEAT_RNA)
+ {
+ rrp = (RnaRefPtr) sfp->data.value.ptrvalue;
+ if (rrp != NULL && rrp->ext.choice == 1
+ && !StringHasNoText (rrp->ext.value.ptrvalue))
+ {
+ str = StringSave (rrp->ext.value.ptrvalue);
+ }
+ }
+ else if (StringICmp (EditQualifierList [field_choice - 1].name, "map") == 0
+ && sfp->data.choice == SEQFEAT_GENE)
+ {
+ grp = (GeneRefPtr) sfp->data.value.ptrvalue;
+ if (grp != NULL && !StringHasNoText (grp->maploc))
+ {
+ str = StringSave (grp->maploc);
+ }
+ }
else
{
gbqual = sfp->qual;
@@ -5832,6 +5591,8 @@ static void SetGBQualString (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr fsp)
GBQualPtr gbqual, gbqual_last = NULL;
ApplyValuePtr avp;
Boolean found = FALSE;
+ RnaRefPtr rrp;
+ GeneRefPtr grp;
if (sfp == NULL || userdata == NULL)
{
@@ -5855,6 +5616,34 @@ static void SetGBQualString (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr fsp)
sfp->except_text = HandleApplyValue (sfp->except_text, avp);
return;
}
+ else if (StringICmp (EditQualifierList[avp->field_list->data.intvalue - 1].name, "product") == 0
+ && sfp->data.choice == SEQFEAT_RNA)
+ {
+ rrp = (RnaRefPtr) sfp->data.value.ptrvalue;
+ if (rrp != NULL)
+ {
+ if (rrp->ext.choice == 0)
+ {
+ rrp->ext.choice = 1;
+ rrp->ext.value.ptrvalue = NULL;
+ }
+ if (rrp->ext.choice == 1)
+ {
+ rrp->ext.value.ptrvalue = HandleApplyValue (rrp->ext.value.ptrvalue, avp);
+ }
+ }
+ return;
+ }
+ else if (StringICmp (EditQualifierList [avp->field_list->data.intvalue - 1].name, "map") == 0
+ && sfp->data.choice == SEQFEAT_GENE)
+ {
+ grp = (GeneRefPtr) sfp->data.value.ptrvalue;
+ if (grp != NULL)
+ {
+ grp->maploc = HandleApplyValue (grp->maploc, avp);
+ return;
+ }
+ }
if (!StringHasNoText (avp->text_to_replace))
{
@@ -5895,6 +5684,8 @@ static void RemoveGBQualField (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr fs
{
GBQualPtr gbqual, gbqual_last = NULL, gbqual_next;
ApplyValuePtr avp;
+ RnaRefPtr rrp;
+ GeneRefPtr grp;
if (sfp == NULL || userdata == NULL)
{
@@ -5918,6 +5709,27 @@ static void RemoveGBQualField (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr fs
sfp->except_text = MemFree (sfp->except_text);
return;
}
+ else if (StringICmp (EditQualifierList[avp->field_list->data.intvalue - 1].name, "product") == 0
+ && sfp->data.choice == SEQFEAT_RNA)
+ {
+ rrp = (RnaRefPtr) sfp->data.value.ptrvalue;
+ if (rrp != NULL && rrp->ext.choice == 1)
+ {
+ rrp->ext.choice = 0;
+ rrp->ext.value.ptrvalue = MemFree (rrp->ext.value.ptrvalue);
+ }
+ return;
+ }
+ else if (StringICmp (EditQualifierList [avp->field_list->data.intvalue - 1].name, "map") == 0
+ && sfp->data.choice == SEQFEAT_GENE)
+ {
+ grp = (GeneRefPtr) sfp->data.value.ptrvalue;
+ if (grp != NULL)
+ {
+ grp->maploc = MemFree (grp->maploc);
+ }
+ }
+
gbqual = sfp->qual;
while (gbqual != NULL)
@@ -6408,13 +6220,31 @@ GetGeneFieldString
CharPtr str = NULL;
GeneRefPtr grp;
- if (sfp == NULL || gene_field == NULL || sfp->data.choice != SEQFEAT_GENE)
+ if (sfp == NULL || gene_field == NULL)
+ {
+ return NULL;
+ }
+
+ if (sfp->data.choice == SEQFEAT_GENE)
+ {
+ grp = (GeneRefPtr) sfp->data.value.ptrvalue;
+ }
+ else
+ {
+ grp = SeqMgrGetGeneXref (sfp);
+ }
+
+ if (sfp->data.choice != SEQFEAT_GENE && grp != NULL)
+ {
+ vnp = NULL;
+ }
+
+ if (grp == NULL)
{
return NULL;
}
vnp = gene_field;
- grp = (GeneRefPtr) sfp->data.value.ptrvalue;
while (vnp != NULL && vnp->data.intvalue != FEATUREFIELD_NONE && StringHasNoText (str))
{
str = NULL;
@@ -6433,7 +6263,10 @@ GetGeneFieldString
}
break;
case GENEFIELD_COMMENT:
- str = sfp->comment;
+ if (sfp->data.choice == SEQFEAT_GENE)
+ {
+ str = sfp->comment;
+ }
break;
case GENEFIELD_ALLELE:
if (grp != NULL)
@@ -6480,13 +6313,26 @@ extern void RemoveGeneFieldString (SeqFeatPtr sfp, ValNodePtr gene_field)
GeneRefPtr grp;
ValNodePtr syn_remove;
- if (sfp == NULL || gene_field == NULL || sfp->data.choice != SEQFEAT_GENE)
+ if (sfp == NULL || gene_field == NULL)
+ {
+ return;
+ }
+
+ if (sfp->data.choice == SEQFEAT_GENE)
+ {
+ grp = (GeneRefPtr) sfp->data.value.ptrvalue;
+ }
+ else
+ {
+ grp = SeqMgrGetGeneXref (sfp);
+ }
+
+ if (grp == NULL)
{
return;
}
vnp = gene_field;
- grp = (GeneRefPtr) sfp->data.value.ptrvalue;
while (vnp != NULL && vnp->data.intvalue != FEATUREFIELD_NONE && !found_nonempty)
{
switch (vnp->data.intvalue)
@@ -6574,7 +6420,7 @@ static void SetGeneFieldString (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr f
GeneRefPtr grp;
ApplyValuePtr avp;
- if (sfp == NULL || userdata == NULL || sfp->data.choice != SEQFEAT_GENE)
+ if (sfp == NULL || userdata == NULL)
{
return;
}
@@ -6584,16 +6430,26 @@ static void SetGeneFieldString (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr f
return;
}
- grp = (GeneRefPtr) sfp->data.value.ptrvalue;
- if (grp == NULL)
+ if (sfp->data.choice == SEQFEAT_GENE)
+ {
+ grp = (GeneRefPtr) sfp->data.value.ptrvalue;
+ }
+ else
+ {
+ grp = SeqMgrGetGeneXref (sfp);
+ }
+
+ if (grp == NULL && sfp->data.choice == SEQFEAT_GENE)
{
grp = GeneRefNew ();
sfp->data.value.ptrvalue = grp;
- if (grp == NULL)
- {
- return;
- }
}
+
+ if (grp == NULL)
+ {
+ return;
+ }
+
switch (avp->field_list->data.intvalue)
{
case GENEFIELD_LOCUS:
@@ -7246,48 +7102,118 @@ static CharPtr rna_field_list [] =
static Int4 num_rna_fields = sizeof (rna_field_list) / sizeof (CharPtr);
+static CharPtr GetRNAFieldName (ValNodePtr vnp)
+{
+ CharPtr label = NULL;
+
+ if (vnp != NULL && vnp->data.intvalue >= 1)
+ {
+ if (vnp->data.intvalue <= num_rna_fields)
+ {
+ label = StringSave (rna_field_list [vnp->data.intvalue - 1]);
+ }
+ else if (vnp->data.intvalue <= num_rna_fields + num_gene_fields)
+ {
+ label = (CharPtr) MemNew ((StringLen (gene_field_list [vnp->data.intvalue - 1 - num_rna_fields]) + 6) * sizeof (Char));
+ if (label != NULL)
+ {
+ sprintf (label, "Gene %s", gene_field_list [vnp->data.intvalue - 1 - num_rna_fields]);
+ }
+ }
+ }
+ return label;
+}
+
extern DialoG
RNAAddFieldSelectionDialog
(GrouP h,
- Boolean allow_none,
+ Boolean allow_multi,
Nlm_ChangeNotifyProc change_notify,
Pointer change_userdata)
{
- return FeatureFieldSelectionDialog (h, allow_none,
- 4, rna_field_list,
- change_notify, change_userdata);
+ ValNodePtr choice_list = NULL;
+ DialoG dlg;
+ Int4 i;
+
+ for (i = 0; i < 4; i++)
+ {
+ ValNodeAddInt (&choice_list, 0, i + 1);
+ }
+ for (i = 0; i < num_gene_fields; i++)
+ {
+ ValNodeAddInt (&choice_list, 0, i + num_rna_fields + 1);
+ }
+ dlg = ValNodeSelectionDialog (h, choice_list, TALL_SELECTION_LIST,
+ GetRNAFieldName, NULL,
+ IntValNodeCopy, IntValNodeMatch,
+ "RNA field", change_notify, change_userdata,
+ FALSE);
+
+ return dlg;
}
extern DialoG
RNARemoveFieldSelectionDialog
(GrouP h,
- Boolean allow_none,
+ Boolean allow_multi,
Nlm_ChangeNotifyProc change_notify,
Pointer change_userdata)
{
- return FeatureFieldSelectionDialog (h, allow_none,
- num_rna_fields, rna_field_list,
- change_notify, change_userdata);
+ ValNodePtr choice_list = NULL;
+ DialoG dlg;
+ Int4 i;
+
+ for (i = 0; i < num_rna_fields; i++)
+ {
+ ValNodeAddInt (&choice_list, 0, i + 1);
+ }
+ for (i = 0; i < num_gene_fields; i++)
+ {
+ ValNodeAddInt (&choice_list, 0, i + num_rna_fields + 1);
+ }
+ dlg = ValNodeSelectionDialog (h, choice_list, TALL_SELECTION_LIST,
+ GetRNAFieldName, NULL,
+ IntValNodeCopy, IntValNodeMatch,
+ "RNA field", change_notify, change_userdata,
+ FALSE);
+
+ return dlg;
}
extern DialoG
RNAFieldSelectionDialog
(GrouP h,
- Boolean allow_none,
+ Boolean allow_multi,
Nlm_ChangeNotifyProc change_notify,
Pointer change_userdata)
{
- return FeatureFieldSelectionDialog (h, allow_none,
- 3, rna_field_list,
- change_notify, change_userdata);
+ ValNodePtr choice_list = NULL;
+ DialoG dlg;
+ Int4 i;
+
+ for (i = 0; i < 3; i++)
+ {
+ ValNodeAddInt (&choice_list, 0, i + 1);
+ }
+ for (i = 0; i < num_gene_fields; i++)
+ {
+ ValNodeAddInt (&choice_list, 0, i + num_rna_fields + 1);
+ }
+ dlg = ValNodeSelectionDialog (h, choice_list, TALL_SELECTION_LIST,
+ GetRNAFieldName, NULL,
+ IntValNodeCopy, IntValNodeMatch,
+ "RNA field", change_notify, change_userdata,
+ FALSE);
+
+ return dlg;
}
-static CharPtr rna_subtype_list [] = { "misc_RNA", "preRna", "mRNA", "tRNA",
+static CharPtr rna_subtype_list [] = { "unknown", "preRna", "mRNA", "tRNA",
"rRNA", "snRNA", "scRNA", "snoRNA",
- "unknown" };
+ "misc_RNA" };
static Int2 num_rna_subtypes = sizeof (rna_subtype_list) / sizeof (CharPtr);
static CharPtr GetRNASubtypeName (ValNodePtr vnp)
@@ -7330,9 +7256,14 @@ static DialoG RNASubtypeSelectionDialog
extern CharPtr GetRNAFieldString (SeqFeatPtr sfp, ValNodePtr vnp, FilterSetPtr fsp)
{
- RnaRefPtr rrp;
- CharPtr str = NULL;
- GBQualPtr gbqual;
+ RnaRefPtr rrp;
+ CharPtr str = NULL;
+ GBQualPtr gbqual;
+ ValNode vn;
+ GeneRefPtr grp;
+ SeqFeatPtr gene;
+ SeqMgrFeatContext context;
+ Int4 field_choice;
if (sfp == NULL || sfp->data.choice != SEQFEAT_RNA || vnp == NULL)
{
@@ -7343,6 +7274,7 @@ extern CharPtr GetRNAFieldString (SeqFeatPtr sfp, ValNodePtr vnp, FilterSetPtr f
while (vnp != NULL && str == NULL)
{
+ field_choice = vnp->data.intvalue;
switch (vnp->data.intvalue)
{
case RNAFIELD_NAME :
@@ -7367,7 +7299,26 @@ extern CharPtr GetRNAFieldString (SeqFeatPtr sfp, ValNodePtr vnp, FilterSetPtr f
}
gbqual = gbqual->next;
}
- break;
+ break;
+ default:
+ if (vnp->data.intvalue >= num_rna_fields + 1)
+ {
+ vn.choice = 0;
+ vn.next = NULL;
+ vn.data.intvalue = vnp->data.intvalue - num_rna_fields;
+ grp = SeqMgrGetGeneXref (sfp);
+ if (grp == NULL)
+ {
+ gene = SeqMgrGetOverlappingGene (sfp->location, &context);
+ str = GetGeneFieldString (gene, &vn, NULL);
+ }
+ else
+ {
+ str = GetGeneFieldString (sfp, &vn, NULL);
+ }
+ }
+ break;
+
}
vnp = vnp->next;
}
@@ -7379,6 +7330,9 @@ static void SetRNAFieldString (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr fs
RnaRefPtr rrp;
ApplyValuePtr avp;
GBQualPtr gbqual, gbqual_last = NULL;
+ SeqFeatPtr gene;
+ GeneRefPtr grp;
+ SeqMgrFeatContext context;
if (sfp == NULL || sfp->data.choice != SEQFEAT_RNA || userdata == NULL)
{
@@ -7449,7 +7403,24 @@ static void SetRNAFieldString (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr fs
{
gbqual->val = HandleApplyValue (gbqual->val, avp);
}
- break;
+ break;
+ default:
+ if (avp->field_list->data.intvalue >= num_rna_fields + 1)
+ {
+ avp->field_list->data.intvalue -= num_rna_fields;
+ grp = SeqMgrGetGeneXref (sfp);
+ if (grp == NULL)
+ {
+ gene = SeqMgrGetOverlappingGene (sfp->location, &context);
+ SetGeneFieldString (gene, avp, fsp);
+ }
+ else
+ {
+ SetGeneFieldString (sfp, avp, fsp);
+ }
+ avp->field_list->data.intvalue += num_rna_fields;
+ }
+ break;
}
}
@@ -7459,6 +7430,10 @@ static void RemoveRNAField (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr fsp)
GBQualPtr gbqual, prev_qual = NULL, next_qual;
tRNAPtr trp;
ApplyValuePtr avp;
+ SeqFeatPtr gene;
+ GeneRefPtr grp;
+ ValNode vn;
+ SeqMgrFeatContext context;
if (sfp == NULL || sfp->data.choice != SEQFEAT_RNA || userdata == NULL)
{
@@ -7533,6 +7508,24 @@ static void RemoveRNAField (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr fsp)
case RNAFIELD_TRANSCRIPT_ID :
sfp->product = SeqLocFree (sfp->product);
break;
+ default:
+ if (avp->field_list->data.intvalue >= num_rna_fields + 1)
+ {
+ vn.choice = 1;
+ vn.next = NULL;
+ vn.data.intvalue = avp->field_list->data.intvalue - num_rna_fields;
+ grp = SeqMgrGetGeneXref (sfp);
+ if (grp == NULL)
+ {
+ gene = SeqMgrGetOverlappingGene (sfp->location, &context);
+ RemoveGeneFieldString (gene, &vn);
+ }
+ else
+ {
+ RemoveGeneFieldString (sfp, &vn);
+ }
+ }
+ break;
}
}
@@ -8194,7 +8187,7 @@ static void ResetStringConstraintDialog (StringConstraintDialogPtr scdp)
if (scdp == NULL) return;
SetValue (scdp->match_choice, 1);
- SetTitle (scdp->match_text, " ");
+ SetTitle (scdp->match_text, "");
SetStatus (scdp->insensitive, FALSE);
SetStatus (scdp->whole_word, FALSE);
}
@@ -9543,12 +9536,33 @@ DoesObjectMatchStringConstraint
ObjectHasStringPtr ohsp)
{
+ SeqFeatPtr sfp;
+ SeqMgrFeatContext fcontext;
+ CharPtr search_txt = NULL;
+
if (omtp == NULL || ohsp == NULL)
{
return FALSE;
}
ohsp->found = FALSE;
(omtp->asnwrite) (ptr, aip, NULL);
+
+ if (!ohsp->found && omtp->datatype == OBJ_SEQFEAT)
+ {
+ sfp = (SeqFeatPtr) ptr;
+ sfp = SeqMgrGetDesiredFeature (sfp->idx.entityID, NULL, 0, 0, sfp, &fcontext);
+ ohsp->found = DoesStringMatchConstraint (fcontext.label, ohsp->scp);
+ if (!ohsp->found && sfp->idx.subtype == FEATDEF_tRNA)
+ {
+ search_txt = (CharPtr) MemNew ((StringLen (fcontext.label) + 6) * sizeof (Char));
+ if (search_txt != NULL)
+ {
+ sprintf (search_txt, "tRNA-%s", fcontext.label);
+ ohsp->found = DoesStringMatchConstraint (search_txt, ohsp->scp);
+ search_txt = MemFree (search_txt);
+ }
+ }
+ }
return ohsp->found;
}
@@ -9705,6 +9719,10 @@ DoesOneSourceMatchConstraint
}
}
}
+ if (scp->string_constraint->not_present)
+ {
+ does_match = ! does_match;
+ }
}
else
{
@@ -9888,8 +9906,14 @@ OperateOnSeqEntryConstrainedObjects
Uint1 descriptorChoice,
Pointer userdata)
{
- ConstraintOpData cod;
- AsnExpOptPtr aeop;
+ ConstraintOpData cod;
+ AsnExpOptPtr aeop;
+ SeqEntryPtr old_scope;
+ BioseqPtr bsp = NULL;
+ SeqFeatPtr sfp;
+ SeqDescrPtr sdp;
+ SeqMgrFeatContext fcontext;
+ SeqMgrDescContext dcontext;
if (sep == NULL) return;
if (feature_action == NULL && descriptor_action == NULL) return;
@@ -9905,6 +9929,8 @@ OperateOnSeqEntryConstrainedObjects
cod.seqFeatChoice = seqFeatChoice;
cod.featDefChoice = featDefChoice;
cod.descriptorChoice = descriptorChoice;
+
+ old_scope = SeqEntrySetScope (sep);
cod.aip = AsnIoNullOpen ();
if (fsp == NULL)
@@ -9921,6 +9947,11 @@ OperateOnSeqEntryConstrainedObjects
aeop->user_data = (Pointer) &(cod.ohsd);
}
+ if (IS_Bioseq (sep))
+ {
+ bsp = (BioseqPtr) sep->data.ptrvalue;
+ }
+
if (fsp == NULL || fsp->ccp == NULL || fsp->ccp->constraint_type == CHOICE_CONSTRAINT_ANY)
{
if (feature_action != NULL)
@@ -9928,7 +9959,19 @@ OperateOnSeqEntryConstrainedObjects
cod.omtp = ObjMgrTypeFind (cod.omp, OBJ_SEQFEAT, NULL, NULL);
if (cod.omtp != NULL)
{
- VisitFeaturesInSep (sep, &cod, SeqEntryConstrainedFeaturesCallback);
+ if (bsp == NULL)
+ {
+ VisitFeaturesInSep (sep, &cod, SeqEntryConstrainedFeaturesCallback);
+ }
+ else
+ {
+ sfp = SeqMgrGetNextFeature (bsp, NULL, 0, 0, &fcontext);
+ while (sfp != NULL)
+ {
+ SeqEntryConstrainedFeaturesCallback (sfp, &cod);
+ sfp = SeqMgrGetNextFeature (bsp, sfp, 0, 0, &fcontext);
+ }
+ }
}
}
@@ -9937,7 +9980,19 @@ OperateOnSeqEntryConstrainedObjects
cod.omtp = ObjMgrTypeFind (cod.omp, OBJ_SEQDESC, NULL, NULL);
if (cod.omtp != NULL)
{
- VisitDescriptorsInSep (sep, &cod, SeqEntryConstrainedDescriptorsCallback);
+ if (bsp == NULL)
+ {
+ VisitDescriptorsInSep (sep, &cod, SeqEntryConstrainedDescriptorsCallback);
+ }
+ else
+ {
+ sdp = SeqMgrGetNextDescriptor (bsp, NULL, 0, &dcontext);
+ while (sdp != NULL)
+ {
+ SeqEntryConstrainedDescriptorsCallback (sdp, &cod);
+ sdp = SeqMgrGetNextDescriptor (bsp, sdp, 0, &dcontext);
+ }
+ }
}
}
}
@@ -9947,9 +10002,30 @@ OperateOnSeqEntryConstrainedObjects
}
AsnIoClose (cod.aip);
+ SeqEntrySetScope (old_scope);
+}
+
+extern GetSamplePtr GetSampleNew (void)
+{
+ GetSamplePtr gsp;
+
+ gsp = (GetSamplePtr) MemNew (sizeof (GetSampleData));
+ if (gsp != NULL)
+ {
+ gsp->all_same = TRUE;
+ gsp->sample_text = NULL;
+ gsp->num_found = 0;
+
+ gsp->fieldstring_func = NULL;
+ gsp->descrstring_func = NULL;
+ gsp->requested_field = NULL;
+ gsp->free_vn_proc = NULL;
+ gsp->copy_vn_proc = NULL;
+ }
+ return gsp;
}
-static GetSamplePtr GetSampleFree (GetSamplePtr gsp)
+extern GetSamplePtr GetSampleFree (GetSamplePtr gsp)
{
if (gsp != NULL)
{
@@ -10196,7 +10272,7 @@ static void ChangePreAppIgnoreChoice (GrouP g)
}
}
-static ExistingTextPtr GetExistingTextHandlerInfo (GetSamplePtr gsp, Boolean non_text)
+extern ExistingTextPtr GetExistingTextHandlerInfo (GetSamplePtr gsp, Boolean non_text)
{
WindoW w;
GrouP h, c;
@@ -15983,6 +16059,14 @@ static ValNodePtr AlreadyInCDSList (ValNodePtr cds_list, SeqFeatPtr sfp)
}
}
break;
+ default:
+ /* features that have gene xrefs and are not CDS, PROT, or mRNA
+ * will be in the gene list */
+ if (SeqMgrGetGeneXref (sfp) != NULL && AlreadyInList (cdsp->gene_list, sfp))
+ {
+ return vnp;
+ }
+ break;
}
}
vnp = vnp->next;
@@ -16009,7 +16093,8 @@ static void BuildCDSSetCallback (SeqFeatPtr sfp, Pointer userdata)
if (sfp == NULL || userdata == NULL
|| (sfp->data.choice != SEQFEAT_CDREGION
&& sfp->data.choice != SEQFEAT_GENE
- && sfp->idx.subtype != FEATDEF_mRNA))
+ && sfp->idx.subtype != FEATDEF_mRNA
+ && SeqMgrGetGeneXref (sfp) == NULL))
{
return;
}
@@ -16029,7 +16114,7 @@ static void BuildCDSSetCallback (SeqFeatPtr sfp, Pointer userdata)
ValNodeAddPointer (&(bp->lonely_gene_list), 0, sfp);
}
}
- else
+ else if (sfp->idx.subtype == FEATDEF_mRNA || sfp->data.choice == SEQFEAT_CDREGION)
{
gene = SeqMgrGetOverlappingGene (sfp->location, &fcontext);
@@ -16047,7 +16132,7 @@ static void BuildCDSSetCallback (SeqFeatPtr sfp, Pointer userdata)
}
}
}
- else
+ else if (sfp->data.choice == SEQFEAT_CDREGION)
{
cds = sfp;
mrna = SeqMgrGetOverlappingmRNA (sfp->location, &fcontext);
@@ -16112,6 +16197,11 @@ static void BuildCDSSetCallback (SeqFeatPtr sfp, Pointer userdata)
}
}
}
+ else
+ {
+ /* this is a feature with a gene xref */
+ ValNodeAddPointer (&(bp->lonely_gene_list), 0, sfp);
+ }
}
static CharPtr GetCDSetField (CDSetPtr cdsp, ValNodePtr vnp)
@@ -17457,12 +17547,18 @@ static void SimpleAECRToDialog (DialoG d, Pointer userdata)
{
PointerToDialog (dlg->field_list, data->field_list);
PointerToDialog (dlg->field_list_to, data->field_list_to);
+ SendMessageToDialog (dlg->field_list_to, NUM_VIB_MSG + 1);
PointerToDialog (dlg->subtype_list, data->subtype_list);
PointerToDialog (dlg->edit_apply, data->edit_apply);
SafeSetValue (dlg->leave_on_original, data->leave_on_original);
dlg->free_field_vn_proc = data->free_field_vn_proc;
dlg->free_subtype_vn_proc = data->free_subtype_vn_proc;
}
+ else
+ {
+ SendMessageToDialog (dlg->field_list, NUM_VIB_MSG + 1);
+ SendMessageToDialog (dlg->field_list_to, NUM_VIB_MSG + 1);
+ }
}
static Pointer DialogToSimpleAECR (DialoG d)
@@ -19027,10 +19123,14 @@ static Int2 num_rna_sample_fields = sizeof (rna_sample_field_list) / sizeof (
static CharPtr GetRNASampleFieldString (SeqFeatPtr sfp, ValNodePtr vnp, FilterSetPtr fsp)
{
- RnaRefPtr rrp;
- CharPtr str = NULL;
- GBQualPtr gbqual;
- Int2 rna_subtype, rna_field_type;
+ RnaRefPtr rrp;
+ CharPtr str = NULL;
+ GBQualPtr gbqual;
+ Int2 rna_subtype, rna_field_type;
+ GeneRefPtr grp;
+ SeqFeatPtr gene;
+ ValNode vn;
+ SeqMgrFeatContext fcontext;
if (sfp == NULL || sfp->data.choice != SEQFEAT_RNA || vnp == NULL)
{
@@ -19041,8 +19141,8 @@ static CharPtr GetRNASampleFieldString (SeqFeatPtr sfp, ValNodePtr vnp, FilterSe
while (vnp != NULL && str == NULL)
{
- rna_subtype = (vnp->data.intvalue - 1) / num_rna_sample_fields;
- rna_field_type = (vnp->data.intvalue - 1) % num_rna_sample_fields;
+ rna_subtype = (vnp->data.intvalue - 1) / (num_rna_sample_fields + num_gene_fields);
+ rna_field_type = (vnp->data.intvalue - 1) % (num_rna_sample_fields + num_gene_fields);
if (rna_subtype == 8)
{
rna_subtype = 255;
@@ -19076,7 +19176,22 @@ static CharPtr GetRNASampleFieldString (SeqFeatPtr sfp, ValNodePtr vnp, FilterSe
}
gbqual = gbqual->next;
}
- break;
+ break;
+ default :
+ vn.next = NULL;
+ vn.choice = 0;
+ vn.data.intvalue = rna_field_type - num_rna_sample_fields + 1;
+ grp = SeqMgrGetGeneXref (sfp);
+ if (grp == NULL)
+ {
+ gene = SeqMgrGetOverlappingGene (sfp->location, &fcontext);
+ str = GetGeneFieldString (gene, &vn, NULL);
+ }
+ else
+ {
+ str = GetGeneFieldString (sfp, &vn, NULL);
+ }
+ break;
}
vnp = vnp->next;
}
@@ -19092,16 +19207,30 @@ static CharPtr GetRNAQualSampleName (ValNodePtr vnp)
{
return NULL;
}
- rna_subtype = (vnp->data.intvalue - 1) / num_rna_sample_fields;
- rna_field_type = (vnp->data.intvalue - 1) % num_rna_sample_fields;
+ rna_subtype = (vnp->data.intvalue - 1) / (num_rna_sample_fields + num_gene_fields);
+ rna_field_type = (vnp->data.intvalue - 1) % (num_rna_sample_fields + num_gene_fields);
- label = (CharPtr) MemNew ((StringLen (rna_subtype_list [rna_subtype])
- + StringLen (rna_sample_field_list[rna_field_type])
- + 2) * sizeof (Char));
- if (label != NULL)
+ if (rna_field_type < num_rna_sample_fields)
{
- sprintf (label, "%s %s", rna_subtype_list [rna_subtype],
- rna_sample_field_list[rna_field_type]);
+ label = (CharPtr) MemNew ((StringLen (rna_subtype_list [rna_subtype])
+ + StringLen (rna_sample_field_list[rna_field_type])
+ + 2) * sizeof (Char));
+ if (label != NULL)
+ {
+ sprintf (label, "%s %s", rna_subtype_list [rna_subtype],
+ rna_sample_field_list[rna_field_type]);
+ }
+ }
+ else if (rna_field_type < num_rna_sample_fields + num_gene_fields)
+ {
+ label = (CharPtr) MemNew ((StringLen (rna_subtype_list [rna_subtype])
+ + StringLen (gene_field_list[rna_field_type - num_rna_sample_fields])
+ + 7) * sizeof (Char));
+ if (label != NULL)
+ {
+ sprintf (label, "%s Gene %s", rna_subtype_list [rna_subtype],
+ gene_field_list[rna_field_type - num_rna_sample_fields]);
+ }
}
return label;
}
@@ -19129,7 +19258,13 @@ static DialoG GetRNAQualSample (GrouP h, Uint2 entityID)
{
for (field_type = 0; field_type < num_rna_sample_fields; field_type++)
{
- list_index = (rna_subtype * num_rna_sample_fields) + field_type;
+ list_index = (rna_subtype * (num_rna_sample_fields + num_gene_fields)) + field_type;
+ ValNodeAddInt (&ssd.field_list, 0, list_index + 1);
+ }
+ for (field_type = 0; field_type < num_gene_fields; field_type ++)
+ {
+ list_index = (rna_subtype * (num_rna_sample_fields + num_gene_fields))
+ + field_type + num_rna_sample_fields;
ValNodeAddInt (&ssd.field_list, 0, list_index + 1);
}
}
@@ -19194,6 +19329,7 @@ static void ResetApplyRNAQualDlg (ApplyRNAQualDlgPtr dlg)
if (dlg != NULL)
{
PointerToDialog (dlg->field_list, NULL);
+ SendMessageToDialog (dlg->field_list, NUM_VIB_MSG + 1);
PointerToDialog (dlg->subtype_list, NULL);
ClearTextApplyRNAQualDlg (dlg);
}
@@ -19285,8 +19421,13 @@ static void RNAQualChangeNotify (Pointer userdata)
}
field_list = DialogToPointer (dlg->field_list);
-
- if (field_list->data.intvalue == RNAFIELD_CODONS_RECOGNIZED)
+ if (field_list == NULL)
+ {
+ Hide (dlg->edit_apply);
+ Hide (dlg->anticodon);
+ Hide (dlg->codons);
+ }
+ else if (field_list->data.intvalue == RNAFIELD_CODONS_RECOGNIZED)
{
Show (dlg->codons);
Hide (dlg->edit_apply);
@@ -20588,3 +20729,411 @@ extern void ExportLastLineage (IteM i)
ArrowCursor ();
Update ();
}
+
+typedef struct combinecds
+{
+ FORM_MESSAGE_BLOCK
+ GrouP action_choice_grp;
+ GrouP new_cds_grp;
+ ButtoN cover_sequence_btn;
+ DialoG string_constraint_dlg;
+
+ Int2 action_choice;
+ Boolean cover_sequence;
+ StringConstraintPtr string_constraint;
+ LogInfoPtr lip;
+
+ /* for string constraint */
+ ObjectHasStringData ohsd;
+ ObjMgrTypePtr omtp;
+ AsnIoPtr aip;
+
+ /* for finding location for master CDS */
+ Int4 left_end;
+ Int4 right_end;
+ Boolean partial5;
+ Boolean partial3;
+ Uint2 strand;
+ SeqFeatPtr first_cds;
+
+ /* for product name for master CDS */
+ GrouP prod_name_choice_grp;
+ TexT prod_name_txt;
+} CombineCDSData, PNTR CombineCDSPtr;
+
+
+static void GetCombinedCDSLocationCallback (SeqFeatPtr sfp, Pointer userdata)
+{
+ CombineCDSPtr ccp;
+ Int4 start, stop;
+ Boolean partial5, partial3;
+ Uint2 strand;
+ SeqMgrFeatContext fcontext;
+
+ if (sfp == NULL
+ || sfp->data.choice != SEQFEAT_CDREGION
+ || sfp->location == NULL
+ || userdata == NULL)
+ {
+ return;
+ }
+
+ ccp = (CombineCDSPtr) userdata;
+
+ if (ccp->ohsd.scp != NULL
+ && !DoesObjectMatchStringConstraint (ccp->omtp, ccp->aip, sfp, &(ccp->ohsd)))
+ {
+ sfp = SeqMgrGetDesiredFeature (ccp->input_entityID, NULL, 0, 0, sfp, &fcontext);
+ if (sfp == NULL || !DoesStringMatchConstraint (fcontext.label, ccp->ohsd.scp))
+ {
+ return;
+ }
+ }
+
+ start = SeqLocStart (sfp->location);
+ stop = SeqLocStop (sfp->location);
+ strand = SeqLocStrand (sfp->location);
+ CheckSeqLocForPartial (sfp->location, &partial5, &partial3);
+ if (start < ccp->left_end)
+ {
+ ccp->first_cds = sfp;
+ ccp->left_end = start;
+ if (strand == Seq_strand_minus)
+ {
+ ccp->partial3 = partial3;
+ }
+ else
+ {
+ ccp->partial5 = partial5;
+ }
+ ccp->strand = strand;
+ }
+
+ if (stop > ccp->right_end)
+ {
+ ccp->right_end = stop;
+ if (strand == Seq_strand_minus)
+ {
+ ccp->partial5 = partial5;
+ }
+ else
+ {
+ ccp->partial3 = partial3;
+ }
+ ccp->strand = strand;
+ }
+}
+
+static void ApplyProductName (CombineCDSPtr ccp, SeqFeatPtr new_cds)
+{
+ BioseqPtr first_prot_bsp, new_prot_bsp;
+ SeqFeatPtr first_prot = NULL;
+ SeqMgrFeatContext fcontext;
+ ProtRefPtr prp;
+ CharPtr product_name = NULL;
+
+ if (ccp == NULL || new_cds == NULL)
+ {
+ return;
+ }
+
+ if (GetValue (ccp->prod_name_choice_grp) == 1)
+ {
+ first_prot_bsp = BioseqFindFromSeqLoc (ccp->first_cds->product);
+ if (first_prot_bsp != NULL)
+ {
+ first_prot = SeqMgrGetNextFeature (first_prot_bsp, NULL,
+ SEQFEAT_PROT, 0, &fcontext);
+ if (first_prot != NULL)
+ {
+ prp = (ProtRefPtr) first_prot->data.value.ptrvalue;
+ if (prp != NULL && prp->name != NULL
+ && ! StringHasNoText (prp->name->data.ptrvalue))
+ {
+ product_name = StringSave (prp->name->data.ptrvalue);
+ }
+ }
+ }
+ }
+ else
+ {
+ product_name = SaveStringFromText (ccp->prod_name_txt);
+ if (StringHasNoText (product_name))
+ {
+ product_name = MemFree (product_name);
+ }
+ }
+
+ if (product_name != NULL)
+ {
+ new_prot_bsp = BioseqFindFromSeqLoc (new_cds->product);
+ if (new_prot_bsp != NULL)
+ {
+ first_prot = SeqMgrGetNextFeature (new_prot_bsp, NULL,
+ SEQFEAT_PROT, 0, &fcontext);
+ if (first_prot != NULL)
+ {
+ prp = (ProtRefPtr) first_prot->data.value.ptrvalue;
+ if (prp != NULL)
+ {
+ ValNodeAddPointer (&(prp->name), 0, product_name);
+ product_name = NULL;
+ }
+ }
+ }
+ }
+ product_name = MemFree (product_name);
+}
+
+static SeqLocPtr GetMasterCDSLocation (BioseqPtr bsp, CombineCDSPtr ccp)
+{
+ SeqFeatPtr sfp;
+ SeqMgrFeatContext fcontext;
+ SeqLocPtr cover_loc;
+
+ if (bsp == NULL || ! ISA_na (bsp->mol) || ccp == NULL)
+ {
+ return NULL;
+ }
+
+ /* create location for master CDS */
+ ccp->left_end = bsp->length - 1;
+ ccp->right_end = 0;
+ ccp->partial5 = FALSE;
+ ccp->partial3 = FALSE;
+
+ sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_CDREGION, 0, &fcontext);
+ if (sfp == NULL)
+ {
+ return NULL;
+ }
+ if (ccp->cover_sequence)
+ {
+ ccp->left_end = 0;
+ ccp->right_end = bsp->length - 1;
+ ccp->partial5 = FALSE;
+ ccp->partial3 = FALSE;
+ ccp->first_cds = sfp;
+ }
+ else
+ {
+ while (sfp != NULL)
+ {
+ GetCombinedCDSLocationCallback (sfp, ccp);
+ sfp = SeqMgrGetNextFeature (bsp, sfp, SEQFEAT_CDREGION, 0, &fcontext);
+ }
+ if (ccp->left_end > ccp->right_end || ccp->first_cds == NULL)
+ {
+ return NULL;
+ }
+ }
+
+ cover_loc = SeqLocIntNew (ccp->left_end, ccp->right_end, ccp->strand, bsp->id);
+ SetSeqLocPartial (cover_loc, ccp->partial5, ccp->partial3);
+
+ return cover_loc;
+}
+
+static void CombineCDSsOnBioseq (BioseqPtr bsp, Pointer userdata)
+{
+ CombineCDSPtr ccp;
+ SeqLocPtr cover_loc;
+ SeqFeatPtr cds;
+
+
+ if (bsp == NULL || userdata == NULL)
+ {
+ return;
+ }
+
+ ccp = (CombineCDSPtr) userdata;
+
+ if (ccp->action_choice == 2)
+ {
+ cover_loc = GetMasterCDSLocation (bsp, ccp);
+ if (cover_loc == NULL)
+ {
+ return;
+ }
+
+ cds = CreateNewFeatureOnBioseq (bsp, SEQFEAT_CDREGION, cover_loc);
+ cds->partial = (ccp->partial5 | ccp->partial3);
+
+ cds->data.value.ptrvalue = AsnIoMemCopy (ccp->first_cds->data.value.ptrvalue,
+ (AsnReadFunc) CdRegionAsnRead,
+ (AsnWriteFunc) CdRegionAsnWrite);
+ RetranslateOneCDS (cds, ccp->first_cds->idx.entityID, TRUE, FALSE);
+
+ ObjMgrSetDirtyFlag (ccp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, ccp->input_entityID, 0, 0);
+ ApplyProductName (ccp, cds);
+ }
+ ConvertInnerCDSsToMatPeptidesCallback (bsp, ccp->lip);
+}
+
+static void DoCombineCDS (ButtoN b)
+{
+ CombineCDSPtr ccp;
+ SeqEntryPtr sep, old_scope;
+ ObjMgrPtr omp;
+ AsnExpOptPtr aeop;
+
+ ccp = (CombineCDSPtr) GetObjectExtra (b);
+ if (ccp == NULL)
+ {
+ return;
+ }
+
+ sep = GetTopSeqEntryForEntityID (ccp->input_entityID);
+ if (NULL == sep)
+ return;
+
+ old_scope = SeqEntrySetScope (sep);
+
+ omp = ObjMgrGet ();
+ if (omp == NULL) return;
+
+ ccp->action_choice = GetValue (ccp->action_choice_grp);
+ ccp->cover_sequence = GetStatus (ccp->cover_sequence_btn);
+ ccp->string_constraint = DialogToPointer (ccp->string_constraint_dlg);
+
+ WatchCursor ();
+ Update ();
+
+ ccp->lip = OpenLog ("Combine CDS Features");
+
+ if (ccp->string_constraint != NULL)
+ {
+ ccp->omtp = ObjMgrTypeFind (omp, OBJ_SEQFEAT, NULL, NULL);
+ ccp->aip = AsnIoNullOpen ();
+ ccp->ohsd.scp = ccp->string_constraint;
+ aeop = AsnExpOptNew (ccp->aip, NULL, NULL, AsnWriteConstraintCallBack);
+ if (aeop != NULL) {
+ aeop->user_data = (Pointer) &(ccp->ohsd);
+ }
+ }
+ else
+ {
+ ccp->omtp = NULL;
+ ccp->aip = NULL;
+ ccp->ohsd.scp = NULL;
+ aeop = NULL;
+ }
+
+ VisitBioseqsInSep (sep, ccp, CombineCDSsOnBioseq);
+
+ AsnIoClose (ccp->aip);
+ SeqEntrySetScope (old_scope);
+
+ CloseLog (ccp->lip);
+ FreeLog (ccp->lip);
+ ccp->string_constraint = StringConstraintFree (ccp->string_constraint);
+ Remove (ccp->form);
+ DeleteMarkedObjects (ccp->input_entityID, 0, NULL);
+ ObjMgrSetDirtyFlag (ccp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, ccp->input_entityID, 0, 0);
+ ArrowCursor ();
+ Update ();
+}
+
+static void EnableNewCDSControls (GrouP g)
+{
+ CombineCDSPtr ccp;
+
+ ccp = (CombineCDSPtr) GetObjectExtra (g);
+ if (ccp == NULL) return;
+
+ if (GetValue (ccp->action_choice_grp) == 1)
+ {
+ Disable (ccp->new_cds_grp);
+ }
+ else
+ {
+ Enable (ccp->new_cds_grp);
+ }
+}
+
+static void EnableProdName (GrouP g)
+{
+ CombineCDSPtr ccp;
+
+ ccp = (CombineCDSPtr) GetObjectExtra (g);
+ if (ccp == NULL) return;
+
+ if (GetValue (ccp->prod_name_choice_grp) == 1)
+ {
+ Disable (ccp->prod_name_txt);
+ }
+ else
+ {
+ Enable (ccp->prod_name_txt);
+ }
+}
+
+extern void CombineMultipleCDS (IteM i)
+{
+ BaseFormPtr bfp;
+ CombineCDSPtr ccp;
+ WindoW w;
+ GrouP h, c;
+ ButtoN b;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+
+ ccp = (CombineCDSPtr) MemNew (sizeof (CombineCDSData));
+ if (ccp == NULL) return;
+
+ w = FixedWindow (-50, -33, -10, -10, "Combine CDS Features", StdCloseWindowProc);
+ SetObjectExtra (w, ccp, StdCleanupExtraProc);
+ ccp->form = (ForM) w;
+ ccp->input_entityID = bfp->input_entityID;
+
+ h = HiddenGroup (w, -1, 0, NULL);
+ SetGroupSpacing (h, 10, 10);
+
+ ccp->action_choice_grp = HiddenGroup (h, 0, 2, EnableNewCDSControls);
+ RadioButton (ccp->action_choice_grp, "Convert inner CDSs to mat_peptides");
+ RadioButton (ccp->action_choice_grp, "AND Merge multiple CDSs into one CDS");
+ SetValue (ccp->action_choice_grp, 1);
+ SetObjectExtra (ccp->action_choice_grp, ccp, NULL);
+
+ ccp->new_cds_grp = HiddenGroup (h, -1, 0, NULL);
+ ccp->cover_sequence_btn = CheckBox (ccp->new_cds_grp, "New CDS should cover entire sequence", NULL);
+ SetStatus (ccp->cover_sequence_btn, FALSE);
+
+ ccp->prod_name_choice_grp = HiddenGroup (ccp->new_cds_grp, 0, 2, EnableProdName);
+ SetObjectExtra (ccp->prod_name_choice_grp, ccp, NULL);
+ RadioButton (ccp->prod_name_choice_grp, "Use product name from first CDS");
+ RadioButton (ccp->prod_name_choice_grp, "Use this product name:");
+ StaticPrompt (ccp->prod_name_choice_grp, "", 0, 0, programFont, 'l');
+ ccp->prod_name_txt = DialogText (ccp->prod_name_choice_grp, " ", 10, NULL);
+ SetValue (ccp->prod_name_choice_grp, 1);
+ Disable (ccp->prod_name_txt);
+
+ ccp->string_constraint_dlg = StringConstraintDialog (ccp->new_cds_grp, "Where CDS field", TRUE);
+ Disable (ccp->new_cds_grp);
+
+ AlignObjects (ALIGN_CENTER, (HANDLE) ccp->cover_sequence_btn,
+ (HANDLE) ccp->prod_name_choice_grp,
+ (HANDLE) ccp->string_constraint_dlg,
+ NULL);
+
+ c = HiddenGroup (h, 2, 0, NULL);
+ b = PushButton (c, "Accept", DoCombineCDS);
+ SetObjectExtra (b, ccp, NULL);
+ b = PushButton (c, "Cancel", StdCancelButtonProc);
+
+ AlignObjects (ALIGN_CENTER, (HANDLE) ccp->action_choice_grp,
+ (HANDLE) ccp->new_cds_grp,
+ (HANDLE) c,
+ NULL);
+ RealizeWindow (w);
+ Show (w);
+ Select (w);
+ Update ();
+}
diff --git a/sequin/sequin6.c b/sequin/sequin6.c
index 45d4faa2..60d89815 100644
--- a/sequin/sequin6.c
+++ b/sequin/sequin6.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 11/12/97
*
-* $Revision: 6.208 $
+* $Revision: 6.218 $
*
* File Description:
*
@@ -53,6 +53,7 @@
#include <subutil.h>
#include <gbftdef.h>
#include <edutil.h>
+#include <salpanel.h>
#define NUMBER_OF_SUFFIXES 7
@@ -5861,18 +5862,6 @@ extern void CorrectCDSStartCodon (IteM i)
}
*/
-static ENUM_ALIST(rnax_subtype_alist)
- {" ", 99},
- {"unknown", 0},
- {"preRna", 1},
- {"mRNA", 2},
- {"tRNA", 3},
- {"rRNA", 4},
- {"snRNA", 5},
- {"scRNA", 6},
- {"snoRNA", 7},
- {"misc_RNA", 255},
-END_ENUM_ALIST
typedef struct applyformdata {
FEATURE_FORM_BLOCK
@@ -5886,24 +5875,20 @@ typedef struct applyformdata {
ButtoN partial5;
ButtoN partial3;
TexT onlyThisPart;
- TexT geneName;
- TexT protName;
- TexT protDesc;
- TexT rnaName;
- TexT featcomment;
- TexT defline;
- LisT key;
- PopuP rnaSubType;
- Uint1 rnatype;
- EnumFieldAssoc PNTR realalist;
- EnumFieldAssoc PNTR alist;
+
+ DialoG feature_details_dlg;
+
+ BatchApplyFeatureDetailsPtr feature_details_data;
+
GrouP strand_group;
- PopuP reading_frame;
GrouP use_whole_interval;
TexT left_end;
TexT right_end;
ButtoN add_to_seq_with_like_feature;
ButtoN leaveDlgUp;
+
+ GetSamplePtr gsp;
+ ExistingTextPtr etp;
} ApplyFormData, PNTR ApplyFormPtr;
typedef struct alreadyhas {
@@ -6308,7 +6293,7 @@ extern SeqLocPtr RemoveGapsFromDeltaLocation (SeqLocPtr slp, BioseqPtr bsp)
SeqIdPtr sip;
Uint1 strand;
Int4 start_pos, end_pos, piece_len;
- Boolean add_piece;
+ Boolean add_piece, partial5, partial3;
if (slp == NULL || bsp == NULL
|| bsp->repr != Seq_repr_delta
@@ -6324,6 +6309,8 @@ extern SeqLocPtr RemoveGapsFromDeltaLocation (SeqLocPtr slp, BioseqPtr bsp)
return slp;
}
+ CheckSeqLocForPartial (slp, &partial5, &partial3);
+
loc_slp = SeqLocFindNext (slp, NULL);
while (loc_slp != NULL)
{
@@ -6394,6 +6381,7 @@ extern SeqLocPtr RemoveGapsFromDeltaLocation (SeqLocPtr slp, BioseqPtr bsp)
/* only found one piece */
slp = SeqLocFree (slp);
slp = loc_list;
+ SetSeqLocPartial (slp, partial5, partial3);
}
else
{
@@ -6405,6 +6393,7 @@ extern SeqLocPtr RemoveGapsFromDeltaLocation (SeqLocPtr slp, BioseqPtr bsp)
slp_new->data.ptrvalue = loc_list;
slp = SeqLocFree (slp);
slp = slp_new;
+ SetSeqLocPartial (slp, partial5, partial3);
}
}
return slp;
@@ -6447,6 +6436,33 @@ static SeqLocPtr RemoveGapsFromLocation (SeqLocPtr slp)
}
}
+extern void AdjustCDSLocationsForGapsCallback (SeqFeatPtr sfp, Pointer userdata)
+{
+ if (sfp != NULL && sfp->data.choice == SEQFEAT_CDREGION)
+ {
+ sfp->location = RemoveGapsFromLocation (sfp->location);
+ }
+}
+
+extern void AdjustCDSLocationsForGaps (IteM i)
+{
+ BaseFormPtr bfp;
+ SeqEntryPtr sep;
+
+#ifdef WIN_MAC
+ bfp = currentFormDataPtr;
+#else
+ bfp = GetObjectExtra (i);
+#endif
+ if (bfp == NULL) return;
+
+ sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
+ VisitFeaturesInSep (sep, NULL, AdjustCDSLocationsForGapsCallback);
+
+ ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
+ ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
+}
+
/*---------------------------------------------------------------------*/
/* */
/* Apply_AddCDS () -- */
@@ -6479,7 +6495,6 @@ static void Apply_AddCDS (Uint2 entityID,
SeqFeatPtr sfp;
SeqIdPtr sip;
Char str [128];
- Char desc_str [128];
ValNodePtr vnp;
SeqEntryPtr parent_sep;
SeqEntryPtr gene_sep;
@@ -6525,8 +6540,8 @@ static void Apply_AddCDS (Uint2 entityID,
setSeqFeatStrand (sfp, Seq_strand_minus);
}
sfp->partial = (afp->noLeft || afp->noRight);
- if (! TextHasNoText (afp->featcomment)) {
- sfp->comment = SaveStringFromTextAndStripNewlines (afp->featcomment);
+ if (! StringHasNoText (afp->feature_details_data->featcomment)) {
+ sfp->comment = StringSave (afp->feature_details_data->featcomment);
}
if (afp->use_whole_interval != NULL
@@ -6538,7 +6553,8 @@ static void Apply_AddCDS (Uint2 entityID,
sfp->location = RemoveGapsFromLocation (sfp->location);
- if (GetValue (afp->reading_frame) < 1 || GetValue (afp->reading_frame) > 3)
+ if (afp->feature_details_data->reading_frame < 1
+ || afp->feature_details_data->reading_frame > 3)
{
max = 0;
frame = 0;
@@ -6571,7 +6587,7 @@ static void Apply_AddCDS (Uint2 entityID,
}
else
{
- crp->frame = GetValue (afp->reading_frame);
+ crp->frame = afp->feature_details_data->reading_frame;
}
/* Create corresponding protein sequence data for the CDS */
@@ -6660,19 +6676,20 @@ static void Apply_AddCDS (Uint2 entityID,
SetSeqFeatProduct (sfp, bsp);
/* create a full-length protein feature for the new protein sequence */
- GetTitle (afp->protName, str, sizeof (str));
- GetTitle (afp->protDesc, desc_str, sizeof (desc_str));
- if (! StringHasNoText (str) && ! StringHasNoText (desc_str))
+ if (! StringHasNoText (afp->feature_details_data->protName)
+ && ! StringHasNoText (afp->feature_details_data->protDesc))
{
- prp = CreateNewProtRef (str, desc_str, NULL, NULL);
+ prp = CreateNewProtRef (afp->feature_details_data->protName,
+ afp->feature_details_data->protDesc,
+ NULL, NULL);
}
- else if (!StringHasNoText (str))
+ else if (!StringHasNoText (afp->feature_details_data->protName))
{
- prp = CreateNewProtRef (str, NULL, NULL, NULL);
+ prp = CreateNewProtRef (afp->feature_details_data->protName, NULL, NULL, NULL);
}
- else if (!StringHasNoText (desc_str))
+ else if (!StringHasNoText (afp->feature_details_data->protDesc))
{
- prp = CreateNewProtRef (NULL, desc_str, NULL, NULL);
+ prp = CreateNewProtRef (NULL, afp->feature_details_data->protDesc, NULL, NULL);
}
else
{
@@ -6699,8 +6716,7 @@ static void Apply_AddCDS (Uint2 entityID,
gene_sep = nsep;
}
- GetTitle (afp->geneName, str, sizeof (str));
- if (! StringHasNoText (str)) {
+ if (! StringHasNoText (afp->feature_details_data->geneName)) {
if (entityID > 0
&& suppressDups
&& AlreadyHasFeatOrDesc (gene_sep, SEQFEAT_GENE, 0, 0))
@@ -6708,8 +6724,157 @@ static void Apply_AddCDS (Uint2 entityID,
return;
}
- ApplyGene (str, afp, gene_sep, sfp);
+ ApplyGene (afp->feature_details_data->geneName, afp, gene_sep, sfp);
+ }
+}
+
+static void CheckTitle (SeqEntryPtr sep, GetSamplePtr gsp)
+{
+ BioseqPtr bsp;
+ BioseqSetPtr bssp = NULL, part_set;
+ SeqDescrPtr sdp;
+
+ if (sep == NULL || sep->data.ptrvalue == NULL
+ || gsp == NULL)
+ {
+ return;
+ }
+
+ if (IS_Bioseq_set (sep)) {
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp != NULL
+ && bssp->_class == BioseqseqSet_class_nuc_prot
+ && bssp->seq_set != NULL)
+ {
+ sep = bssp->seq_set;
+ }
+ }
+
+ if (IS_Bioseq_set (sep))
+ {
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp != NULL
+ && bssp->_class == BioseqseqSet_class_segset
+ && bssp->seq_set != NULL)
+ {
+ /* first do parts */
+ if (bssp->seq_set->next != NULL
+ && IS_Bioseq_set (bssp->seq_set->next)
+ && bssp->seq_set->next->data.ptrvalue != NULL)
+ {
+ part_set = (BioseqSetPtr) bssp->seq_set->next->data.ptrvalue;
+ if (part_set->_class == BioseqseqSet_class_parts)
+ {
+ for (sep = part_set->seq_set; sep != NULL; sep = sep->next)
+ {
+ CheckTitle (sep, gsp);
+ }
+ }
+ }
+
+ /* now do master */
+ sep = bssp->seq_set;
+ }
+ }
+
+ if (!IS_Bioseq (sep))
+ {
+ return;
+ }
+
+ bsp = (BioseqPtr) sep->data.ptrvalue;
+ sdp = bsp->descr;
+ while (sdp != NULL && sdp->choice != Seq_descr_title)
+ {
+ sdp = sdp->next;
+ }
+ if (sdp != NULL)
+ {
+ gsp->num_found ++;
+ if (gsp->sample_text == NULL)
+ {
+ gsp->sample_text = StringSave (sdp->data.ptrvalue);
+ }
+ else if (StringCmp (gsp->sample_text, sdp->data.ptrvalue) != 0)
+ {
+ gsp->all_same = FALSE;
+ }
+ }
+
+
+}
+
+static void ApplyOneTitle (SeqEntryPtr sep, ExistingTextPtr etp, CharPtr defline)
+{
+ BioseqPtr bsp;
+ BioseqSetPtr bssp, part_set;
+ SeqDescrPtr sdp;
+
+ if (sep == NULL || sep->data.ptrvalue == NULL
+ || StringHasNoText (defline))
+ {
+ return;
+ }
+
+ if (IS_Bioseq_set (sep)) {
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp != NULL
+ && bssp->_class == BioseqseqSet_class_nuc_prot
+ && bssp->seq_set != NULL)
+ {
+ sep = bssp->seq_set;
+ }
+ }
+
+ if (IS_Bioseq_set (sep))
+ {
+ bssp = (BioseqSetPtr) sep->data.ptrvalue;
+ if (bssp != NULL
+ && bssp->_class == BioseqseqSet_class_segset
+ && bssp->seq_set != NULL)
+ {
+ /* first do parts */
+ if (bssp->seq_set->next != NULL
+ && IS_Bioseq_set (bssp->seq_set->next)
+ && bssp->seq_set->next->data.ptrvalue != NULL)
+ {
+ part_set = (BioseqSetPtr) bssp->seq_set->next->data.ptrvalue;
+ if (part_set->_class == BioseqseqSet_class_parts)
+ {
+ for (sep = part_set->seq_set; sep != NULL; sep = sep->next)
+ {
+ ApplyOneTitle (sep, etp, defline);
+ }
+ }
+ }
+
+ /* now do master */
+ sep = bssp->seq_set;
+ }
+ }
+
+ if (!IS_Bioseq (sep))
+ {
+ return;
+ }
+
+ bsp = (BioseqPtr) sep->data.ptrvalue;
+ sdp = bsp->descr;
+ while (sdp != NULL && sdp->choice != Seq_descr_title)
+ {
+ sdp = sdp->next;
+ }
+
+ if (sdp == NULL)
+ {
+ sdp = CreateNewDescriptor (sep, Seq_descr_title);
+ }
+
+ if (sdp != NULL) {
+ sdp->data.ptrvalue = HandleExistingText (sdp->data.ptrvalue,
+ StringSave (defline), etp);
}
+
}
/*---------------------------------------------------------------------*/
@@ -6719,21 +6884,15 @@ static void Apply_AddCDS (Uint2 entityID,
/*---------------------------------------------------------------------*/
static void RealApplyBioFeatToAll (Uint2 entityID,
- SeqEntryPtr sep,
- SeqEntryPtr nsep,
+ SeqEntryPtr sep,
+ SeqEntryPtr nsep,
ApplyFormPtr afp,
- Boolean suppressDups)
+ Boolean suppressDups)
{
- EnumFieldAssocPtr ap;
- BioseqSetPtr bssp;
- Int2 i;
ImpFeatPtr ifp;
RnaRefPtr rrp;
- ValNodePtr sdp;
SeqFeatPtr sfp = NULL;
- Char str [128];
- Int2 val;
SeqFeatPtr gene_sfp;
Boolean put_comment_on_gene = FALSE;
@@ -6744,30 +6903,18 @@ static void RealApplyBioFeatToAll (Uint2 entityID,
/* Add a title feature */
- if (afp->type == ADD_TITLE)
+ if (afp->type == CHECK_TITLE)
+ {
+ CheckTitle (sep, afp->gsp);
+ return;
+ }
+ else if (afp->type == ADD_TITLE)
{
- if (suppressDups && entityID > 0
- && AlreadyHasFeatOrDesc (sep, 0, Seq_descr_title, 0))
- {
- return;
- }
if (entityID == 0 && SeqEntryGetTitle (sep) != NULL)
{
return;
}
- if (! TextHasNoText (afp->defline)) {
- if (IS_Bioseq_set (sep)) {
- bssp = (BioseqSetPtr) sep->data.ptrvalue;
- if (bssp != NULL && bssp->_class == 1 && bssp->seq_set != NULL) {
- sep = bssp->seq_set;
- }
- }
- sdp = CreateNewDescriptor (sep, Seq_descr_title);
- if (sdp != NULL) {
- sdp->data.ptrvalue =
- (Pointer) SaveStringFromTextAndStripNewlines (afp->defline);
- }
- }
+ ApplyOneTitle (sep, afp->etp, afp->feature_details_data->defline);
return;
}
@@ -6780,13 +6927,13 @@ static void RealApplyBioFeatToAll (Uint2 entityID,
else if (afp->type == ADD_RRNA) {
if (suppressDups && entityID > 0 &&
- AlreadyHasFeatOrDesc (sep, SEQFEAT_RNA, 0, afp->rnatype)) return;
+ AlreadyHasFeatOrDesc (sep, SEQFEAT_RNA, 0, afp->feature_details_data->rnaSubType)) return;
rrp = RnaRefNew ();
if (rrp != NULL) {
- rrp->type = afp->rnatype;
- if (! TextHasNoText (afp->rnaName)) {
+ rrp->type = afp->feature_details_data->rnaSubType;
+ if (! StringHasNoText (afp->feature_details_data->rnaName)) {
rrp->ext.choice = 1;
- rrp->ext.value.ptrvalue = SaveStringFromText (afp->rnaName);
+ rrp->ext.value.ptrvalue = StringSave (afp->feature_details_data->rnaName);
}
sfp = CreateNewFeature (nsep, NULL, SEQFEAT_RNA, NULL);
if (sfp != NULL) {
@@ -6804,21 +6951,19 @@ static void RealApplyBioFeatToAll (Uint2 entityID,
setSeqFeatStrand (sfp, Seq_strand_minus);
}
sfp->partial = (afp->noLeft || afp->noRight);
- if (! TextHasNoText (afp->featcomment)) {
- sfp->comment =
- SaveStringFromTextAndStripNewlines (afp->featcomment);
+ if (! StringHasNoText (afp->feature_details_data->featcomment)) {
+ sfp->comment = StringSave (afp->feature_details_data->featcomment);
}
}
}
- GetTitle (afp->geneName, str, sizeof (str));
- if (! StringHasNoText (str)) {
+ if (! StringHasNoText (afp->feature_details_data->geneName)) {
if (entityID > 0
&& suppressDups
&& AlreadyHasFeatOrDesc (sep, SEQFEAT_GENE, 0, 0))
{
return;
}
- ApplyGene (str, afp, nsep, sfp);
+ ApplyGene (afp->feature_details_data->geneName, afp, nsep, sfp);
}
}
@@ -6826,25 +6971,15 @@ static void RealApplyBioFeatToAll (Uint2 entityID,
/* Add an Import feature */
else if (afp->type == ADD_IMP) {
- val = GetValue (afp->key);
- if (val <= 1)
+ if (afp->feature_details_data->featdef_choice == FEATDEF_GENE)
{
put_comment_on_gene = TRUE;
}
else
{
- val --;
ifp = ImpFeatNew ();
if (ifp != NULL) {
- if (val > 0) {
- for (i = 1, ap = afp->alist; ap->name != NULL; i++, ap++) {
- if (i == val) {
- ifp->key = StringSave (ap->name);
- }
- }
- } else {
- ifp->key = StringSave ("misc_feature");
- }
+ ifp->key = StringSave (afp->feature_details_data->featdef_name);
sfp = CreateNewFeature (nsep, NULL, SEQFEAT_IMP, NULL);
if (sfp != NULL) {
sfp->data.value.ptrvalue = (Pointer) ifp;
@@ -6861,17 +6996,15 @@ static void RealApplyBioFeatToAll (Uint2 entityID,
setSeqFeatStrand (sfp, Seq_strand_minus);
}
sfp->partial = (afp->noLeft || afp->noRight);
- if (! TextHasNoText (afp->featcomment))
+ if (! StringHasNoText (afp->feature_details_data->featcomment))
{
- sfp->comment =
- SaveStringFromTextAndStripNewlines (afp->featcomment);
+ sfp->comment = StringSave (afp->feature_details_data->featcomment);
}
sfp->qual = DialogToPointer (afp->gbquals);
}
}
}
- GetTitle (afp->geneName, str, sizeof (str));
- if (! StringHasNoText (str))
+ if (! StringHasNoText (afp->feature_details_data->geneName))
{
if (entityID > 0
&& suppressDups
@@ -6879,11 +7012,11 @@ static void RealApplyBioFeatToAll (Uint2 entityID,
{
return;
}
- gene_sfp = ApplyGene (str, afp, nsep, sfp);
+ gene_sfp = ApplyGene (afp->feature_details_data->geneName, afp, nsep, sfp);
- if (gene_sfp != NULL && ! TextHasNoText (afp->featcomment) && put_comment_on_gene)
+ if (gene_sfp != NULL && ! StringHasNoText (afp->feature_details_data->featcomment) && put_comment_on_gene)
{
- gene_sfp->comment = SaveStringFromTextAndStripNewlines (afp->featcomment);
+ gene_sfp->comment = StringSave (afp->feature_details_data->featcomment);
}
}
}
@@ -7024,20 +7157,33 @@ Int2 ApplyAnnotationToAll (Int2 type, SeqEntryPtr sep,
MemSet ((Pointer) (&afd), 0, sizeof (ApplyFormData));
afd.type = type;
- if (ADD_RRNA == type)
- afd.rnatype = 4;
afd.errcount = 0;
afd.ambigList = NULL;
afd.partial5 = partialLft;
afd.partial3 = partialRgt;
afd.noLeft = GetStatus (afd.partial5);
afd.noRight = GetStatus (afd.partial3);
- afd.geneName = geneName;
- afd.protName = protName;
- afd.protDesc = protDesc;
- afd.rnaName = rnaName;
- afd.featcomment = featcomment;
- afd.defline = defline;
+ afd.feature_details_data = BatchApplyFeatureDetailsNew ();
+ if (afd.feature_details_data == NULL)
+ {
+ return 1;
+ }
+
+ if (ADD_RRNA == type)
+ afd.feature_details_data->rnaSubType = 4;
+
+ if (geneName != NULL && ! TextHasNoText (geneName))
+ afd.feature_details_data->geneName = SaveStringFromText (geneName);
+ if (protName != NULL && ! TextHasNoText (protName))
+ afd.feature_details_data->protName = SaveStringFromText (protName);
+ if (protDesc != NULL && ! TextHasNoText (protDesc))
+ afd.feature_details_data->protDesc = SaveStringFromText (protDesc);
+ if (rnaName != NULL && ! TextHasNoText (rnaName))
+ afd.feature_details_data->rnaName = SaveStringFromText (rnaName);
+ if (featcomment != NULL && ! TextHasNoText (featcomment))
+ afd.feature_details_data->featcomment = SaveStringFromText (featcomment);
+ if (defline != NULL && ! TextHasNoText (defline))
+ afd.feature_details_data->defline = SaveStringFromText (defline);
ApplyBioFeatToAll (0, sep, &afd);
if (afd.type == ADD_CDS) {
return afd.errcount;
@@ -7059,7 +7205,6 @@ static void NowReadyToApplyToAll (ApplyFormPtr afp, DialoG gbquals)
SeqEntryPtr sep;
CharPtr tmp;
SeqEntryPtr top;
- UIEnum val;
ValNodePtr vnp;
Char path [PATH_MAX];
FILE *fp;
@@ -7078,12 +7223,7 @@ static void NowReadyToApplyToAll (ApplyFormPtr afp, DialoG gbquals)
if (afp->type == ADD_CDS) {
GetSeqEntryParent (top, &parentptr, &parenttype);
}
- afp->rnatype = 0;
- if (afp->rnaSubType != NULL) {
- if (GetEnumPopup (afp->rnaSubType, rnax_subtype_alist, &val)) {
- afp->rnatype = val;
- }
- }
+
ApplyBioFeatToAll (afp->input_entityID, sep, afp);
ArrowCursor ();
Update ();
@@ -7142,11 +7282,8 @@ static void DoTheApplyToAllProc (ButtoN b)
{
ApplyFormPtr afp;
- EnumFieldAssocPtr ap;
- Int2 i;
CharPtr name;
QualsFormPtr qfp;
- Int2 val;
WindoW w;
afp = GetObjectExtra (b);
@@ -7154,26 +7291,18 @@ static void DoTheApplyToAllProc (ButtoN b)
Remove (ParentWindow (b));
return;
}
+
+ afp->feature_details_data = DialogToPointer (afp->feature_details_dlg);
+
if (afp->type == ADD_IMP) {
- val = GetValue (afp->key);
/* if gene, do not collect quals */
- if (val > 1)
- {
- val--;
+ if (afp->feature_details_data->featdef_choice != FEATDEF_GENE)
+ {
qfp = (QualsFormPtr) MemNew (sizeof (QualsForm));
if (qfp != NULL) {
Hide (afp->form);
Update ();
- name = NULL;
- if (val > 1) {
- for (i = 1, ap = afp->alist; ap->name != NULL; i++, ap++) {
- if (i == val) {
- name = ap->name;
- }
- }
- } else {
- name = "misc_feature";
- }
+ name = afp->feature_details_data->featdef_name;
qfp->afp = afp;
w = FixedWindow (-50, -33, -10, -10, "Qualifiers", StdCloseWindowProc);
SetObjectExtra (w, qfp, StdCleanupFormProc);
@@ -7189,6 +7318,21 @@ static void DoTheApplyToAllProc (ButtoN b)
} else {
NowReadyToApplyToAll (afp, NULL);
}
+ }
+ else if (afp->type == ADD_TITLE)
+ {
+ afp->gsp = GetSampleNew ();
+ afp->type = CHECK_TITLE;
+ NowReadyToApplyToAll (afp, NULL);
+ afp->etp = GetExistingTextHandlerInfo (afp->gsp, FALSE);
+ afp->gsp = GetSampleFree (afp->gsp);
+ afp->type = ADD_TITLE;
+ if (afp->etp == NULL
+ || afp->etp->existing_text_choice != EXISTING_TEXT_CHOICE_CANCEL)
+ {
+ NowReadyToApplyToAll (afp, NULL);
+ }
+ afp->etp = MemFree (afp->etp);
} else {
NowReadyToApplyToAll (afp, NULL);
}
@@ -7269,17 +7413,11 @@ static void ApplyMessageProc (ForM f, Int2 mssg)
static void CleanupApplyToAllForm (GraphiC g, VoidPtr data)
{
- Int2 j;
ApplyFormPtr afp;
afp = (ApplyFormPtr) data;
if (afp != NULL) {
- if (afp->realalist != NULL) {
- for (j = 0; afp->realalist [j].name != NULL; j++) {
- MemFree (afp->realalist [j].name);
- }
- }
- MemFree (afp->realalist);
+ afp->feature_details_data = BatchApplyFeatureDetailsFree (afp->feature_details_data);
ValNodeFreeData (afp->ambigList);
}
StdCleanupFormProc (g, data);
@@ -7291,12 +7429,11 @@ static void CommonApplyToAllProcBfpInfo (Uint2 entityID,
Int2 type)
{
ApplyFormPtr afp;
- EnumFieldAssocPtr ap;
ButtoN b;
GrouP c;
GrouP g = NULL;
GrouP h;
- GrouP r, r2, r3, r4;
+ GrouP r2, r3, r4;
SeqEntryPtr sep;
StdEditorProcsPtr sepp;
WindoW w;
@@ -7304,7 +7441,6 @@ static void CommonApplyToAllProcBfpInfo (Uint2 entityID,
GrouP parts_group = NULL;
GrouP feature_details = NULL;
GrouP indexer_only_group = NULL;
- GrouP text_group = NULL;
sep = GetTopSeqEntryForEntityID (entityID);
if (sep == NULL) return;
@@ -7403,85 +7539,14 @@ static void CommonApplyToAllProcBfpInfo (Uint2 entityID,
afp->use_whole_interval = NULL;
}
- /* codon start controls */
- if (type == ADD_CDS)
- {
- r = HiddenGroup (feature_details, 2, 0, NULL);
- StaticPrompt (r, "Codon Start", 0, dialogTextHeight, programFont, 'l');
- afp->reading_frame = PopupList (r, TRUE, NULL);
- PopupItem (afp->reading_frame, "1");
- PopupItem (afp->reading_frame, "2");
- PopupItem (afp->reading_frame, "3");
- PopupItem (afp->reading_frame, "Best");
- SetValue (afp->reading_frame, 4);
- }
- else if (type == ADD_RRNA)
- {
- r = HiddenGroup (feature_details, 2, 0, NULL);
- StaticPrompt (r, "RNA subtype", 0, dialogTextHeight, programFont, 'l');
- afp->rnaSubType = PopupList (r, TRUE, NULL);
- InitEnumPopup (afp->rnaSubType, rnax_subtype_alist, NULL);
- SetEnumPopup (afp->rnaSubType, rnax_subtype_alist, (UIEnum) 4);
- }
- else
- {
- r = NULL;
- }
-
- if (indexer_only_group == NULL)
- {
- AlignObjects (ALIGN_CENTER, (HANDLE) g,
- (HANDLE) afp->strand_group,
- (HANDLE) r,
- NULL);
- }
- else
- {
- AlignObjects (ALIGN_CENTER, (HANDLE) g,
- (HANDLE) afp->strand_group,
- (HANDLE) indexer_only_group,
- (HANDLE) r,
- NULL);
- }
+ AlignObjects (ALIGN_CENTER, (HANDLE) g,
+ (HANDLE) afp->strand_group,
+ (HANDLE) indexer_only_group,
+ NULL);
}
+ afp->feature_details_dlg = BatchApplyFeatureDetailsDialog (h, type);
+
- text_group = HiddenGroup (h, 0, 2, NULL);
- if (type == ADD_TITLE) {
- StaticPrompt (text_group, "Title", 0, 0, programFont, 'c');
- afp->defline = ScrollText (text_group, 20, 4, programFont, TRUE, NULL);
- } else {
- text_group = HiddenGroup (h, 2, 0, NULL);
- if (type == ADD_CDS) {
- StaticPrompt (text_group, "Gene Symbol", 0, dialogTextHeight, programFont, 'l');
- afp->geneName = DialogText (text_group, "", 20, NULL);
- StaticPrompt (text_group, "Protein Name", 0, dialogTextHeight, programFont, 'l');
- afp->protName = DialogText (text_group, "", 20, NULL);
- StaticPrompt (text_group, "Protein Description", 0, dialogTextHeight, programFont, 'l');
- afp->protDesc = DialogText (text_group, "", 20, NULL);
- } else if (type == ADD_RRNA) {
- StaticPrompt (text_group, "RNA Name", 0, dialogTextHeight, programFont, 'l');
- afp->rnaName = DialogText (text_group, "", 20, NULL);
- StaticPrompt (text_group, "Gene Symbol", 0, dialogTextHeight, programFont, 'l');
- afp->geneName = DialogText (text_group, "", 20, NULL);
- } else if (type == ADD_IMP) {
- ap = import_featdef_alist (FALSE, FALSE, FALSE);
- SortEnumFieldAssocPtrArray (ap, CompareImpFeatEnumFieldAssoc);
- afp->realalist = ap;
- ap++;
- afp->alist = ap;
- StaticPrompt (text_group, "Type", 0, 6 * Nlm_stdLineHeight, programFont, 'l');
- afp->key = SingleList (text_group, 12, 6, NULL);
- ListItem (afp->key, "Gene");
- for (ap = afp->alist; ap->name != NULL; ap++) {
- ListItem (afp->key, ap->name);
- }
- SetValue (afp->key, 1);
- StaticPrompt (text_group, "Gene Symbol", 0, dialogTextHeight, programFont, 'l');
- afp->geneName = DialogText (text_group, "", 20, NULL);
- }
- StaticPrompt (text_group, "Comment", 0, 4 * Nlm_stdLineHeight, programFont, 'l');
- afp->featcomment = ScrollText (text_group, 20, 4, programFont, TRUE, NULL);
- }
afp->gbquals = NULL;
c = HiddenGroup (h, 4, 0, NULL);
@@ -7492,46 +7557,23 @@ static void CommonApplyToAllProcBfpInfo (Uint2 entityID,
if (parts_group == NULL)
{
- if (feature_details == NULL)
- {
- AlignObjects (ALIGN_CENTER, (HANDLE) text_group, (HANDLE) c, NULL);
- }
- else
- {
- AlignObjects (ALIGN_CENTER, (HANDLE) feature_details,
- (HANDLE) text_group,
- (HANDLE) c,
- NULL);
- }
+ AlignObjects (ALIGN_CENTER, (HANDLE) c,
+ (HANDLE) afp->feature_details_dlg,
+ (HANDLE) feature_details,
+ NULL);
}
else
{
- if (feature_details == NULL)
- {
- AlignObjects (ALIGN_CENTER, (HANDLE) parts_group,
- (HANDLE) text_group,
- (HANDLE) c,
- NULL);
- }
- else
- {
- AlignObjects (ALIGN_CENTER, (HANDLE) parts_group,
- (HANDLE) feature_details,
- (HANDLE) text_group,
- (HANDLE) c,
- NULL);
- }
+ AlignObjects (ALIGN_CENTER, (HANDLE) parts_group,
+ (HANDLE) c,
+ (HANDLE) afp->feature_details_dlg,
+ (HANDLE) feature_details,
+ NULL);
}
RealizeWindow (w);
Show (w);
- if (type == ADD_TITLE) {
- Select (afp->defline);
- } else if (type == ADD_RRNA) {
- Select (afp->rnaName);
- } else {
- Select (afp->geneName);
- }
+ SendMessageToDialog (afp->feature_details_dlg, VIB_MSG_ENTER);
Update ();
}
@@ -7581,7 +7623,6 @@ extern void ApplyImpFeat (IteM i)
CommonApplyToAllProcMenuItem (i, ADD_IMP);
}
-
#define SUBMISSION_PAGE 0
#define CONTACT_PAGE 1
#define AUTHOR_PAGE 2
@@ -9927,7 +9968,10 @@ typedef struct addmodlistitem {
static AddModListItem mods_list[] = {
{ TRUE, ORGMOD_authority, "Authority", NULL },
+{ TRUE, ORGMOD_biovar, "Biovar", "bv." },
{ FALSE, SUBSRC_clone, "Clone", NULL },
+{ TRUE, ORGMOD_forma, "Forma", "f." },
+{ TRUE, ORGMOD_forma_specialis, "Forma-specialis", "f. sp." },
{ FALSE, SUBSRC_genotype, "Genotype", NULL },
{ FALSE, SUBSRC_haplotype, "Haplotype", NULL },
{ TRUE, ORGMOD_isolate, "Isolate", NULL },
@@ -10052,14 +10096,42 @@ static void AddModToOrgProc (BioSourcePtr biop, Pointer userdata)
}
}
+static void AddModToOrgFeat (SeqFeatPtr sfp, Pointer userdata, FilterSetPtr fsp)
+{
+ if (sfp == NULL || sfp->data.choice != SEQFEAT_ORG
+ || sfp->data.value.ptrvalue == NULL || userdata == NULL)
+ {
+ return;
+ }
+ else
+ {
+ AddModToOrgProc (sfp->data.value.ptrvalue, userdata);
+ }
+}
+
+static void AddModToOrgDesc (SeqDescrPtr sdp, Pointer userdata, FilterSetPtr fsp)
+{
+ if (sdp == NULL || sdp->choice != Seq_descr_source
+ || sdp->data.ptrvalue == NULL || userdata == NULL)
+ {
+ return;
+ }
+ else
+ {
+ AddModToOrgProc (sdp->data.ptrvalue, userdata);
+ }
+}
+
+
typedef struct addmodformptr {
FEATURE_FORM_BLOCK
- PopuP modifier_to_add;
+ PopuP modifier_to_add;
ButtoN only_sp;
ButtoN only_cf;
ButtoN only_aff;
ButtoN use_abbreviation;
+ DialoG constraint;
} AddModFormData, PNTR AddModFormPtr;
@@ -10067,8 +10139,9 @@ static void DoAddModToOrg (ButtoN b)
{
AddModFormPtr amfp;
AddModInfoPtr ami;
- SeqEntryPtr sep;
- Int4 mod_index;
+ SeqEntryPtr sep;
+ Int4 mod_index;
+ FilterSetPtr fsp;
amfp = GetObjectExtra (b);
if (amfp == NULL) return;
@@ -10095,7 +10168,16 @@ static void DoAddModToOrg (ButtoN b)
{
ami->use_abbreviation = TRUE;
}
- VisitBioSourcesInSep (sep, ami, AddModToOrgProc);
+ fsp = (FilterSetPtr) DialogToPointer (amfp->constraint);
+ OperateOnSeqEntryConstrainedObjects (sep, fsp,
+ AddModToOrgFeat,
+ AddModToOrgDesc,
+ SEQFEAT_ORG,
+ FEATDEF_ORG,
+ Seq_descr_source,
+ ami);
+ fsp = FilterSetFree (fsp);
+
Update ();
ObjMgrSetDirtyFlag (amfp->input_entityID, TRUE);
ObjMgrSendMsg (OM_MSG_UPDATE, amfp->input_entityID, 0, 0);
@@ -10156,8 +10238,7 @@ extern void AddModToOrg (IteM i)
g = HiddenGroup (w, -1, 0, NULL);
SetGroupSpacing (g, 10, 10);
- h = HiddenGroup (g, 1, 0, NULL);
- amfp->modifier_to_add = PopupList (h, TRUE, ChangeModPopup);
+ amfp->modifier_to_add = PopupList (g, TRUE, ChangeModPopup);
for (index=0; index< sizeof (mods_list) / sizeof (AddModListItem); index++)
{
PopupItem (amfp->modifier_to_add, mods_list[index].name);
@@ -10165,22 +10246,24 @@ extern void AddModToOrg (IteM i)
SetObjectExtra (amfp->modifier_to_add, amfp, NULL);
SetValue (amfp->modifier_to_add, 1);
- amfp->only_sp = CheckBox (g, "Only append to sp. organisms", NULL);
- amfp->only_cf = CheckBox (g, "Only append to cf. organisms", NULL);
- amfp->only_aff = CheckBox (g, "Only append to aff. organisms", NULL);
- amfp->use_abbreviation = CheckBox (g, "Use abbreviation (pv. or subsp. or var.)", NULL);
+ h = HiddenGroup (g, 1, 0, NULL);
+ amfp->only_sp = CheckBox (h, "Only append to sp. organisms", NULL);
+ amfp->only_cf = CheckBox (h, "Only append to cf. organisms", NULL);
+ amfp->only_aff = CheckBox (h, "Only append to aff. organisms", NULL);
+ amfp->use_abbreviation = CheckBox (h, "Use abbreviation (pv. or subsp. or var.)", NULL);
SetStatus (amfp->use_abbreviation, TRUE);
Disable (amfp->use_abbreviation);
+
+ amfp->constraint = FilterGroup (g, FALSE, TRUE, FALSE, FALSE, NULL);
c = HiddenGroup (g, 2, 0, NULL);
b = DefaultButton(c, "Accept", DoAddModToOrg);
SetObjectExtra(b, amfp, NULL);
PushButton (c, "Cancel", StdCancelButtonProc);
- AlignObjects (ALIGN_CENTER, (HANDLE) h,
- (HANDLE) amfp->only_sp,
- (HANDLE) amfp->only_cf,
- (HANDLE) amfp->only_aff,
+ AlignObjects (ALIGN_CENTER, (HANDLE) amfp->modifier_to_add,
+ (HANDLE) h,
+ (HANDLE) amfp->constraint,
(HANDLE) c, NULL);
RealizeWindow(w);
Show(w);
diff --git a/sequin/sequin7.c b/sequin/sequin7.c
index b77548c6..707a88b2 100644
--- a/sequin/sequin7.c
+++ b/sequin/sequin7.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/3/98
*
-* $Revision: 6.196 $
+* $Revision: 6.200 $
*
* File Description:
*
@@ -374,6 +374,7 @@ extern ForM CreateStartupForm (Int2 left, Int2 top, CharPtr title,
BtnActnProc readExisting,
BtnActnProc fetchFromNet,
BtnActnProc showHelp,
+ BtnActnProc createSubmissionTemplate,
BtnActnProc quitProgram,
WndActnProc activateForm)
@@ -466,6 +467,11 @@ extern ForM CreateStartupForm (Int2 left, Int2 top, CharPtr title,
}
b = PushButton (c, "Show Help", showHelp);
SetObjectExtra (b, sfp, NULL);
+ if (createSubmissionTemplate != NULL)
+ {
+ b = PushButton (c, "Submission Template", createSubmissionTemplate);
+ SetObjectExtra (b, sfp, NULL);
+ }
b = PushButton (c, "Quit Program", quitProgram);
SetObjectExtra (b, sfp, NULL);
@@ -611,6 +617,22 @@ static Boolean ExportTemplateMenu (ForM f, CharPtr filename)
CharPtr org_name;
Boolean done;
+ if (ANS_NO == Message (MSG_YN, "Do you want to add an organism name and comment before saving the template?"))
+ {
+ bssp = BioseqSetNew ();
+ sep = SeqEntryNew ();
+ sep->choice = 2;
+ sep->data.ptrvalue = bssp;
+
+ done = ExportSubmitterBlockTemplate (sep, NULL);
+ if (!done)
+ {
+ /* if done were TRUE, sep would have been freed as part of the new SeqSubmit */
+ SeqEntryFree (sep);
+ }
+ return done;
+ }
+
w = MovableModalWindow (-20, -13, -10, -10, "Submission Template", NULL);
h = HiddenGroup(w, -1, 0, NULL);
SetGroupSpacing (h, 10, 10);
@@ -676,7 +698,11 @@ static Boolean ExportTemplateMenu (ForM f, CharPtr filename)
}
done = ExportSubmitterBlockTemplate (sep, sdp);
- SeqEntryFree (sep);
+ if (!done)
+ {
+ /* if done were TRUE, sep would have been freed as part of the new SeqSubmit */
+ SeqEntryFree (sep);
+ }
}
}
Remove (w);
@@ -4451,6 +4477,21 @@ static void FindFormMessage (ForM f, Int2 mssg)
}
}
+static void CopyFindReplBtn (ButtoN b)
+{
+ FindFormPtr ffp;
+ CharPtr str;
+
+ ffp = (FindFormPtr) GetObjectExtra (b);
+ if (ffp == NULL)
+ {
+ return;
+ }
+ str = SaveStringFromText (ffp->findTxt);
+ SetTitle (ffp->replaceTxt, str);
+ str = MemFree (str);
+}
+
static ForM CreateFindForm (Int2 left, Int2 top, CharPtr title,
Uint2 entityID, Uint2 itemID, Uint2 itemtype,
Int2 type)
@@ -4491,14 +4532,17 @@ static ForM CreateFindForm (Int2 left, Int2 top, CharPtr title,
j = HiddenGroup (w, -1, 0, NULL);
SetGroupSpacing (j, 10, 10);
- g = HiddenGroup (j, 2, 0, NULL);
+ g = HiddenGroup (j, 3, 0, NULL);
StaticPrompt (g, "Find", 0, dialogTextHeight, programFont, 'l');
ffp->findTxt = DialogText (g, "", 25, FindTextProc);
SetObjectExtra (ffp->findTxt, ffp, NULL);
+ StaticPrompt (g, "", 0, 0, programFont, 'l');
if (type == FIND_ASN) {
StaticPrompt (g, "Replace", 0, dialogTextHeight, programFont, 'l');
ffp->replaceTxt = DialogText (g, "", 25, NULL);
SetObjectExtra (ffp->replaceTxt, ffp, NULL);
+ b = PushButton (g, "Copy", CopyFindReplBtn);
+ SetObjectExtra (b, ffp, NULL);
}
if (type == FIND_ASN || type == FIND_FLAT) {
diff --git a/sequin/sequin8.c b/sequin/sequin8.c
index 9b016a34..1ced1bd4 100644
--- a/sequin/sequin8.c
+++ b/sequin/sequin8.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 2/3/98
*
-* $Revision: 6.294 $
+* $Revision: 6.295 $
*
* File Description:
*
@@ -57,6 +57,7 @@
#include <alignmgr2.h>
#include <spidey.h>
#include <blast.h>
+#include <salpanel.h>
#define DEFLINE_MAX_LEN 380
#define TEXT_MAX_LEN 64
diff --git a/sequin/sequin9.c b/sequin/sequin9.c
index 0829397d..7a33712e 100644
--- a/sequin/sequin9.c
+++ b/sequin/sequin9.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 4/20/99
*
-* $Revision: 6.326 $
+* $Revision: 6.328 $
*
* File Description:
*
@@ -57,6 +57,7 @@
#include <rpsutil.h>
#include "sequin.h"
#include <seqpanel.h>
+#include <salpanel.h>
#include <assert.h>
/*-------------------*/
@@ -7783,23 +7784,6 @@ static void CleanupUpdateSequenceForm (GraphiC g, VoidPtr data)
StdCleanupFormProc (g, data);
}
-#ifdef WIN_MAC
-extern void UpdateSequenceFormActivated (WindoW w);
-
-static void UpdateSequenceFormActivate (WindoW w)
-
-{
- BaseFormPtr bfp;
-
- bfp = (BaseFormPtr) GetObjectExtra (w);
- if (bfp != NULL) {
- if (bfp->activate != NULL) {
- bfp->activate (w);
- }
- }
-}
-#endif
-
static CharPtr txt1 =
"Sequence Relationship displays sequence lengths";
@@ -9455,1394 +9439,6 @@ extern void ExtendSeqAfterDownload
/* NEW FEATURE PROPAGATION SECTION */
-typedef struct fprdata {
- FORM_MESSAGE_BLOCK
- BioseqPtr bsp;
- SeqAlignPtr salp;
- Uint2 selFeatItemID;
- Int4 aln_length;
- Int4 log10_aln_length;
- VieweR details;
- SegmenT dtpict;
- Int4 scaleX;
- GrouP allOrSel;
- GrouP gapSplit;
- DialoG sequence_list_dlg;
- ButtoN stopCDS;
- ButtoN transPast;
- ButtoN fixCDS;
- ButtoN fuseJoints;
- ButtoN accept;
-} FprData, PNTR FprDataPtr;
-
-typedef struct ivalinfo {
- Int4 start1;
- Int4 stop1;
- Int4 start2;
- Int4 stop2;
- struct ivalinfo PNTR next;
-} IvalInfo, PNTR IvalInfoPtr;
-
-static IvalInfoPtr IvalInfoFree (
- IvalInfoPtr ival
-)
-
-{
- IvalInfoPtr next;
-
- while (ival != NULL) {
- next = ival->next;
- MemFree (ival);
- ival = next;
- }
- return NULL;
-}
-
-static IvalInfoPtr GetAlignmentIntervals (SeqAlignPtr sap, Int4 row1, Int4 row2, Int4 from, Int4 to)
-{
- AlnMsg2Ptr amp1;
- AlnMsg2Ptr amp2;
- IvalInfoPtr ival;
- IvalInfoPtr ival_head = NULL;
- IvalInfoPtr ival_prev = NULL;
- Int4 from_aln;
- Int4 start;
- Int4 stop;
- Int4 tmp;
- Int4 to_aln;
- Int4 seg_i, seg_n, seg_start, seg_stop;
-
- if (sap == NULL || sap->saip == NULL)
- return NULL;
- AlnMgr2GetNthSeqRangeInSA(sap, row1, &start, &stop);
- if (from < start)
- from = start;
- if (to > stop)
- to = stop;
- from_aln = AlnMgr2MapBioseqToSeqAlign(sap, from, row1);
- to_aln = AlnMgr2MapBioseqToSeqAlign(sap, to, row1);
- if (from_aln > to_aln)
- {
- tmp = from_aln;
- from_aln = to_aln;
- to_aln = tmp;
- }
- seg_n = AlnMgr2GetNumSegs(sap);
- for (seg_i=1; seg_i<=seg_n; seg_i++) {
- AlnMgr2GetNthSegmentRange(sap, seg_i, &seg_start, &seg_stop);
- if (seg_start > to_aln) continue;
- if (seg_stop < from_aln) continue;
- if (seg_start < from_aln) seg_start = from_aln;
- if (seg_stop > to_aln) seg_stop = to_aln;
-
- amp1 = AlnMsgNew2();
- amp1->from_aln = seg_start;
- amp1->to_aln = seg_stop;
- amp1->row_num = row1;
- amp2 = AlnMsgNew2();
- amp2->from_aln = seg_start;
- amp2->to_aln = seg_stop;
- amp2->row_num = row2;
- AlnMgr2GetNextAlnBit(sap, amp1);
- AlnMgr2GetNextAlnBit(sap, amp2);
- if (amp1->type == AM_SEQ && amp2->type == AM_SEQ) {
- ival = (IvalInfoPtr)MemNew(sizeof(IvalInfo));
- ival->start1 = amp1->from_row;
- ival->stop1 = amp1->to_row;
- ival->start2 = amp2->from_row;
- ival->stop2 = amp2->to_row;
- if (ival_head == NULL)
- ival_head = ival_prev = ival;
- else {
- ival_prev->next = ival;
- ival_prev = ival;
- }
- }
- AlnMsgFree2(amp1);
- AlnMsgFree2(amp2);
- }
- return ival_head;
-}
-
-static IvalInfoPtr MergeAdjacentIntervals (
- IvalInfoPtr list
-)
-
-{
- IvalInfoPtr curr, last, next;
-
- if (list != NULL) {
- curr = list->next;
- last = list;
- while (curr != NULL) {
- next = curr->next;
- if (curr->start2 == last->stop2 + 1) {
- last->stop2 = MAX (curr->stop2, last->stop2);
- MemFree (curr);
- last->next = next;
- } else {
- last = curr;
- }
- curr = next;
- }
- }
- return list;
-}
-
-static SeqLocPtr MergeAdjacentSeqLocIntervals (SeqLocPtr location)
-
-{
- SeqLocPtr head = NULL;
- SeqIntPtr sinp, last_sinp;
- SeqLocPtr slp;
- SeqPntPtr spp, last_spp;
- SeqLocPtr last_slp = NULL;
- Int4 last_from = -1, last_to = -1;
- Uint1 last_strand = 0;
- SeqIdPtr last_id = NULL;
-
- head = NULL;
- slp = SeqLocFindNext (location, NULL);
- while (slp != NULL) {
- switch (slp->choice) {
- case SEQLOC_INT :
- sinp = (SeqIntPtr) slp->data.ptrvalue;
- if (sinp != NULL) {
- if (last_slp != NULL && last_strand == sinp->strand && last_id != NULL
- && SeqIdComp (sinp->id, last_id) == SIC_YES
- && ((last_from <= sinp->from + 1 && last_to >= sinp->from - 1)
- || (last_from <= sinp->to + 1 && last_to >= sinp->to - 1)
- || (last_from >= sinp->from - 1 && last_to <= sinp->to + 1)
- || (last_from <= sinp->from + 1 && last_to >= sinp->to - 1)))
- {
- /* intervals are adjacent, so expand previous interval */
- if (last_slp->choice == SEQLOC_INT) {
- last_sinp = last_slp->data.ptrvalue;
- if (last_sinp != NULL) {
- last_from = MIN (sinp->from, last_sinp->from);
- last_sinp->from = last_from;
- last_to = MAX (sinp->to, last_sinp->to);
- last_sinp->to = last_to;
- }
- } else if (last_slp->choice == SEQLOC_PNT) {
- /* change previous entry from point to interval that includes point */
- spp = (SeqPntPtr)last_slp->data.ptrvalue;
- if (spp != NULL) {
- last_sinp = SeqIntNew ();
- last_from = MIN (spp->point, sinp->from);
- last_sinp->from = last_from;
- last_to = MAX (sinp->to, spp->point);
- last_sinp->to = last_to;
- last_sinp->strand = sinp->strand;
- last_sinp->id = SeqIdDup (sinp->id);
- last_slp->choice = SEQLOC_INT;
- last_slp->data.ptrvalue = last_sinp;
- SeqPntFree (spp);
- }
- }
- } else {
- /* add new interval */
- last_sinp = SeqIntNew ();
- last_sinp->from = sinp->from;
- last_from = sinp->from;
- last_sinp->to = sinp->to;
- last_to = sinp->to;
- last_sinp->strand = sinp->strand;
- last_strand = sinp->strand;
- last_sinp->id = SeqIdDup (sinp->id);
- last_id = last_sinp->id;
- last_slp = ValNodeAddPointer (&head, SEQLOC_INT, (Pointer) last_sinp);
- }
- }
- break;
- case SEQLOC_PNT:
- spp = (SeqPntPtr)slp->data.ptrvalue;
- if (spp != NULL) {
- if (last_slp != NULL && last_strand == spp->strand && last_id != NULL
- && SeqIdComp (spp->id, last_id) == SIC_YES
- && last_to >= spp->point - 1)
- {
- /* intervals are adjacent, so expand previous interval */
- if (last_slp->choice == SEQLOC_INT) {
- last_sinp = last_slp->data.ptrvalue;
- if (last_sinp != NULL) {
- last_to = MAX (spp->point, last_sinp->to);
- last_sinp->to = last_to;
- last_from = MIN (spp->point, last_sinp->from);
- last_sinp->from = last_from;
- }
- } else if (last_slp->choice == SEQLOC_PNT) {
- /* change previous entry from point to interval that includes point */
- last_spp = (SeqPntPtr)last_slp->data.ptrvalue;
- if (last_spp != NULL) {
- last_sinp = SeqIntNew ();
- last_from = MIN (spp->point, last_spp->point);
- last_sinp->from = last_from;
- last_to = MAX (last_spp->point, spp->point);
- last_sinp->to = last_to;
- last_sinp->strand = spp->strand;
- last_sinp->id = SeqIdDup (spp->id);
- last_slp->choice = SEQLOC_INT;
- last_slp->data.ptrvalue = last_sinp;
- SeqPntFree (spp);
- }
- }
- } else {
- /* add new point */
- last_spp = SeqPntNew ();
- last_spp->point = spp->point;
- last_to = spp->point;
- last_from = spp->point;
- last_spp->strand = spp->strand;
- last_strand = spp->strand;
- last_spp->id = SeqIdDup (spp->id);
- last_slp = ValNodeAddPointer (&head, SEQLOC_PNT, (Pointer) last_spp);
- }
- }
- break;
- default:
- break;
- }
- slp = SeqLocFindNext (location, slp);
- }
-
- if (head == NULL) return NULL;
- if (head->next == NULL) return head;
-
- slp = ValNodeNew (NULL);
- slp->choice = SEQLOC_MIX;
- slp->data.ptrvalue = (Pointer) head;
- slp->next = NULL;
-
- return slp;
-}
-
-/* We need to be able to propagate features with locations on multiple segments
- * whose IDs may be found in separate alignments.
- * To do this, we will take the location of the master feature and for each sublocation,
- * we will find the sequence ID of the sublocation. We will find the alignment that
- * contains the master feature sublocation sequence ID and construct a propagated
- * sublocation for each sequence in the same alignment as the master feature sublocation
- * sequence ID and add this to a list.
- * Once we have created all of the propagated sublocations, we will reconstitute the
- * total locations for the propagated features by associating each propagated sublocation
- * with other propagated sublocations with the same sequence ID or having a sequence ID
- * that belongs to the same segmented set.
- * We can then use the list of total locations to construct the propagated features.
- */
-
-static SeqLocPtr MapSubLoc
-(SeqLocPtr master_subloc,
- SeqAlignPtr salp,
- Int4 master_row,
- Int4 prop_row,
- Boolean gapSplit)
-{
- SeqLocPtr prop_loc = NULL;
- SeqIdPtr prop_sip;
- SeqIntPtr sinp;
- IvalInfoPtr ival_head, ival;
- SeqPntPtr spp;
- Uint1 strand;
-
- if (master_subloc == NULL || salp == NULL || master_row < 1 || prop_row < 1)
- {
- return NULL;
- }
-
- prop_sip = AlnMgr2GetNthSeqIdPtr (salp, prop_row);
- if (prop_sip == NULL) return NULL;
-
- switch (master_subloc->choice) {
- case SEQLOC_INT :
- sinp = (SeqIntPtr) master_subloc->data.ptrvalue;
- if (sinp != NULL) {
- strand = sinp->strand;
- ival_head = GetAlignmentIntervals (salp, master_row, prop_row, sinp->from, sinp->to);
- ival_head = MergeAdjacentIntervals (ival_head);
- if (ival_head != NULL) {
-
- /* what if one or the other interval maps into a gap? */
-
- if (gapSplit) {
- for (ival = ival_head; ival != NULL; ival = ival->next) {
- sinp = SeqIntNew ();
- sinp->from = ival->start2;
- sinp->to = ival->stop2;
- sinp->strand = strand;
- sinp->id = SeqIdDup (prop_sip);
- ValNodeAddPointer (&prop_loc, SEQLOC_INT, (Pointer) sinp);
- }
- } else {
- sinp = SeqIntNew ();
- sinp->from = ival_head->start2;
- for (ival = ival_head; ival->next != NULL; ival = ival->next) continue;
- sinp->to = ival->stop2;
- sinp->strand = strand;
- sinp->id = SeqIdDup (prop_sip);
- ValNodeAddPointer (&prop_loc, SEQLOC_INT, (Pointer) sinp);
- }
-
- }
- IvalInfoFree (ival_head);
- }
- break;
- case SEQLOC_PNT :
- spp = (SeqPntPtr) master_subloc->data.ptrvalue;
- if (spp != NULL) {
- strand = spp->strand;
- ival_head = GetAlignmentIntervals (salp, master_row, prop_row, spp->point, spp->point);
- if (ival_head != NULL) {
-
- spp = SeqPntNew ();
- spp->point = ival_head->start2;
- spp->strand = strand;
- spp->id = SeqIdDup (prop_sip);
- ValNodeAddPointer (&prop_loc, SEQLOC_PNT, (Pointer) spp);
-
- }
- IvalInfoFree (ival_head);
- }
- break;
- case SEQLOC_PACKED_PNT :
- /* not yet implemented */
- break;
- default :
- break;
- }
- if (prop_loc == NULL)
- {
- prop_sip = SeqIdFree (prop_sip);
- }
- return prop_loc;
-}
-
-typedef struct loclist
-{
- SeqIdPtr sip_list;
- SeqLocPtr slp;
-} LocListData, PNTR LocListPtr;
-
-static LocListPtr FindLocListForSeqId (ValNodePtr loc_list, SeqIdPtr sip)
-{
- SeqIdPtr search_sip, find_sip;
- LocListPtr llp;
- ValNodePtr vnp;
-
- for (vnp = loc_list; vnp != NULL; vnp = vnp->next)
- {
- llp = (LocListPtr) vnp->data.ptrvalue;
- if (llp != NULL && llp->slp != NULL)
- {
- for (search_sip = llp->sip_list; search_sip != NULL; search_sip = search_sip->next)
- {
- for (find_sip = sip; find_sip != NULL; find_sip = find_sip->next)
- {
- if (SeqIdComp (find_sip, search_sip) == SIC_YES)
- {
- return llp;
- }
- }
- }
- }
- }
- return NULL;
-}
-
-/* Compare the Sequence ID of this location with the sequence IDs of other locations in the
- * list. If the sequence ID matches that of another loclist, add to that loclist,
- * otherwise add a new loclist entry with the sequence ID of this sequence and the sequence IDs
- * of other sequences in the same segset if the segset flag is set.
- */
-static ValNodePtr AssociatePropagatedSubloc (ValNodePtr subloc_list, SeqLocPtr prop_loc, Boolean segset)
-{
- ValNodePtr vnp;
- LocListPtr llp = NULL;
- SeqIdPtr prop_sip;
- BioseqPtr prop_bsp;
- BioseqSetPtr parent_set;
- SeqEntryPtr sep;
-
- if (prop_loc == NULL) return subloc_list;
- prop_sip = SeqLocId (prop_loc);
- if (prop_sip == NULL)
- {
- SeqLocFree (prop_loc);
- return subloc_list;
- }
-
- llp = FindLocListForSeqId (subloc_list, prop_sip);
- if (llp != NULL)
- {
- ValNodeAddPointer (&(llp->slp), prop_loc->choice, prop_loc->data.ptrvalue);
- prop_loc = ValNodeFree (prop_loc);
- }
- else
- {
- llp = (LocListPtr) MemNew (sizeof (LocListData));
- if (llp != NULL)
- {
- llp->sip_list = SeqIdDup (prop_sip);
- llp->slp = prop_loc;
- if (segset)
- {
- prop_bsp = BioseqFind (prop_sip);
- if (prop_bsp != NULL && prop_bsp->idx.parenttype == OBJ_BIOSEQSET)
- {
- parent_set = prop_bsp->idx.parentptr;
- if (parent_set != NULL && parent_set->_class == BioseqseqSet_class_parts)
- {
- /* add other IDs from set to list */
- for (sep = parent_set->seq_set; sep != NULL; sep = sep->next)
- {
- if (IS_Bioseq (sep))
- {
- prop_bsp = (BioseqPtr) sep->data.ptrvalue;
- prop_sip = SeqIdDup (prop_bsp->id);
- ValNodeAddPointer (&(llp->sip_list), prop_sip->choice, prop_sip->data.ptrvalue);
- prop_sip = ValNodeFree (prop_sip);
- }
- }
- }
- }
- }
- vnp = ValNodeAddPointer (&subloc_list, 0, llp);
- }
- }
- return subloc_list;
-}
-
-static ValNodePtr FreeLocList (ValNodePtr loc_list)
-{
- LocListPtr llp;
-
- if (loc_list == NULL) return NULL;
- loc_list->next = FreeLocList (loc_list->next);
- llp = loc_list->data.ptrvalue;
- if (llp != NULL)
- {
- SeqIdFree (llp->sip_list);
- SeqLocFree (llp->slp);
- MemFree (llp);
- }
- ValNodeFree (loc_list);
- return NULL;
-}
-
-static Int4 GetMasterRow (SeqAlignPtr salp, SeqIdPtr sip)
-{
- Int4 master_row = -1;
- SeqIdPtr sip_next;
-
- if (salp == NULL || sip == NULL)
- {
- return -1;
- }
-
- while (sip != NULL && master_row == -1)
- {
- sip_next = sip->next;
- sip->next = NULL;
- master_row = AlnMgr2GetFirstNForSip (salp, sip);
- sip->next = sip_next;
- sip = sip_next;
- }
- return master_row;
-}
-
-static Boolean
-NthAlignmentSequenceInSeqPropList
-(SeqAlignPtr salp,
- Int4 n,
- ValNodePtr seq_for_prop)
-{
- SeqIdPtr sip;
- ValNodePtr seq_vnp;
- BioseqPtr bsp;
- SeqEntryPtr sep;
- BioseqSetPtr bssp;
-
- if (salp == NULL || seq_for_prop == NULL)
- {
- return FALSE;
- }
-
- sip = AlnMgr2GetNthSeqIdPtr(salp, n);
- for (seq_vnp = seq_for_prop; seq_vnp != NULL; seq_vnp = seq_vnp->next)
- {
- if (SeqIdIn (sip, (SeqIdPtr) seq_vnp->data.ptrvalue))
- {
- return TRUE;
- }
- /* check for segments */
- bsp = BioseqFind (seq_vnp->data.ptrvalue);
- if (bsp != NULL && bsp->repr == Seq_repr_seg)
- {
- sep = SeqMgrGetSeqEntryForData (bsp);
- sep = sep->next; /* parts should be next */
- if (sep != NULL && IS_Bioseq_set (sep))
- {
- bssp = (BioseqSetPtr) sep->data.ptrvalue;
- if (bssp != NULL && bssp->_class == BioseqseqSet_class_parts)
- {
- for (sep = bssp->seq_set; sep != NULL; sep = sep->next)
- {
- if (IS_Bioseq (sep))
- {
- bsp = (BioseqPtr) sep->data.ptrvalue;
- if (bsp != NULL && SeqIdIn (sip, bsp->id))
- {
- return TRUE;
- }
- }
- }
- }
- }
- }
- }
-
-
- return FALSE;
-}
-
-static ValNodePtr GetPropagatedSublocations
-(SeqLocPtr master_location,
- Boolean gap_split,
- ValNodePtr prop_loc_list,
- ValNodePtr seq_for_prop,
- BoolPtr warned_about_master)
-{
- SeqLocPtr master_subloc;
- SeqIdPtr master_subloc_id;
- BioseqPtr master_subloc_bsp;
- SeqLocPtr tmp_loc;
- SeqAlignPtr salp;
- Int4 master_row, num_rows, prop_row;
- SeqLocPtr prop_loc;
-
- if (master_location == NULL) return prop_loc_list;
-
- master_subloc = SeqLocFindNext (master_location, NULL);
- while (master_subloc != NULL)
- {
- master_subloc_id = SeqLocId (master_subloc);
- master_subloc_bsp = BioseqFind (master_subloc_id);
- master_subloc_id = master_subloc_bsp->id;
- if (master_subloc_bsp != NULL)
- {
- if (master_subloc_bsp->repr == Seq_repr_seg)
- {
- if (warned_about_master != NULL && ! *warned_about_master)
- {
- Message (MSG_OK, "Warning - you are propagating a feature that "
- "contains locations on the master sequence. These locations"
- " will be mapped to the segments in the propagated features.");
- *warned_about_master = TRUE;
- }
- /* this is a location on the master segment */
- tmp_loc = SegLocToParts (master_subloc_bsp, master_subloc);
- prop_loc_list = GetPropagatedSublocations (tmp_loc, gap_split, prop_loc_list,
- seq_for_prop, warned_about_master);
- tmp_loc = SeqLocFree (tmp_loc);
- }
- else
- {
- salp = FindAlignmentsForBioseq (master_subloc_bsp);
- while (salp != NULL)
- {
- master_row = GetMasterRow (salp, master_subloc_id);
- num_rows = AlnMgr2GetNumRows (salp);
- for (prop_row = 1; prop_row <= num_rows; prop_row++)
- {
- if (prop_row == master_row) continue;
- if (! NthAlignmentSequenceInSeqPropList (salp, prop_row, seq_for_prop))
- {
- continue;
- }
-
- prop_loc = MapSubLoc (master_subloc, salp, master_row, prop_row, gap_split);
- prop_loc_list = AssociatePropagatedSubloc (prop_loc_list, prop_loc, TRUE);
- }
- salp = salp->next;
- }
- }
- }
- master_subloc = SeqLocFindNext (master_location, master_subloc);
- }
- return prop_loc_list;
-}
-
-static ValNodePtr MapLocForProp
-(SeqLocPtr master_location,
- Boolean gapSplit,
- ValNodePtr seq_for_prop,
- BoolPtr warned_about_master)
-{
- ValNodePtr prop_loc_list = NULL, vnp;
- LocListPtr llp;
- SeqLocPtr slp;
-
- if (master_location == NULL)
- {
- return NULL;
- }
-
- prop_loc_list = GetPropagatedSublocations (master_location, gapSplit, prop_loc_list,
- seq_for_prop, warned_about_master);
-
- /* now fix locations in prop_loc_list (add SEQLOC_MIX header to the locations that
- * are mixed)
- */
- for (vnp = prop_loc_list; vnp != NULL; vnp = vnp->next)
- {
- llp = (LocListPtr) vnp->data.ptrvalue;
- if (llp != NULL)
- {
- if (llp->slp != NULL)
- {
- if (llp->slp->next != NULL)
- {
- slp = ValNodeNew (NULL);
- slp->choice = SEQLOC_MIX;
- slp->data.ptrvalue = llp->slp;
- llp->slp = slp;
- }
- }
- }
- }
- return prop_loc_list;
-}
-
-
-static SeqIdPtr GetSegIdList (BioseqPtr master_seg)
-{
- SeqIdPtr sip_list = NULL, sip_last = NULL, sip;
- SeqLocPtr slp;
- if (master_seg == NULL)
- {
- return NULL;
- }
- if (master_seg->repr != Seq_repr_seg)
- {
- sip_list = SeqIdDup (master_seg->id);
- }
- else
- {
- for (slp = master_seg->seq_ext; slp != NULL; slp = slp->next)
- {
- sip = SeqIdDup (SeqLocId (slp));
- if (sip_last == NULL)
- {
- sip_list = sip;
- }
- else
- {
- sip_last->next = sip;
- }
- sip_last = sip;
- }
- }
- return sip_list;
-}
-
-static void PropagateCodeBreaks
-(CdRegionPtr crp,
- SeqIdPtr sip,
- ValNodePtr codebreak_location_list,
- ValNodePtr codebreak_choice_list)
-{
- CodeBreakPtr cbp, last_cbp = NULL;
- ValNodePtr choice_vnp, cbp_vnp;
- LocListPtr llp;
- BioseqPtr cds_bsp;
- SeqIdPtr sip_list;
-
- if (crp == NULL || codebreak_location_list == NULL || crp->code_break == NULL)
- {
- return;
- }
-
- crp->code_break = CodeBreakFree (crp->code_break);
-
- cds_bsp = BioseqFind (sip);
- if (cds_bsp == NULL)
- {
- return;
- }
-
- sip_list = GetSegIdList (cds_bsp);
-
- for (cbp_vnp = codebreak_location_list, choice_vnp = codebreak_choice_list;
- cbp_vnp != NULL && choice_vnp != NULL;
- cbp_vnp = cbp_vnp->next, choice_vnp = choice_vnp->next)
- {
- llp = FindLocListForSeqId (cbp_vnp->data.ptrvalue, sip_list);
- if (llp != NULL)
- {
- cbp = CodeBreakNew ();
- if (cbp != NULL)
- {
- cbp->loc = llp->slp;
- llp->slp = NULL;
- MemCpy (&(cbp->aa), choice_vnp->data.ptrvalue, sizeof (cbp->aa));
- if (last_cbp == NULL)
- {
- crp->code_break = cbp;
- }
- else
- {
- last_cbp->next = cbp;
- }
- }
- }
- }
- SeqIdFree (sip_list);
-}
-
-static void PropagateAnticodons
-(tRNAPtr trp,
- SeqIdPtr sip,
- ValNodePtr anticodon_location_list)
-{
- LocListPtr llp;
- BioseqPtr trna_bsp;
- SeqIdPtr sip_list;
-
- if (trp == NULL || anticodon_location_list == NULL || trp->anticodon == NULL)
- {
- return;
- }
-
- trp->anticodon = SeqLocFree (trp->anticodon);
-
- trna_bsp = BioseqFind (sip);
- if (trna_bsp == NULL)
- {
- return;
- }
- sip_list = GetSegIdList (trna_bsp);
-
- llp = FindLocListForSeqId (anticodon_location_list, sip_list);
- if (llp != NULL)
- {
- trp->anticodon = llp->slp;
- llp->slp = NULL;
- }
-
- SeqIdFree (sip_list);
-}
-
-
-static void ExtendLocToEnd (
- SeqLocPtr location,
- BioseqPtr bsp,
- Uint1 strand
-)
-
-{
- SeqIntPtr sinp;
- SeqLocPtr slp, last = NULL;
-
- slp = SeqLocFindNext (location, NULL);
- while (slp != NULL) {
- last = slp;
- slp = SeqLocFindNext (location, slp);
- }
- if (last == NULL) return;
-
- switch (last->choice) {
- case SEQLOC_INT :
- sinp = (SeqIntPtr) last->data.ptrvalue;
- if (sinp != NULL) {
- if (strand == Seq_strand_minus) {
- sinp->from = 0;
- } else {
- sinp->to = bsp->length - 1;
- }
- }
- case SEQLOC_PNT :
- /* not yet implemented */
- break;
- case SEQLOC_PACKED_PNT :
- /* not yet implemented */
- break;
- default :
- break;
- }
-}
-
-static void TruncateCDS (
- SeqFeatPtr sfp,
- Uint1 frame,
- BioseqPtr pbsp
-)
-
-{
- Int4 len;
- SeqIntPtr sinp;
- SeqLocPtr slp;
- Int4 total = 0;
-
- if (frame > 0) {
- frame--;
- }
- slp = SeqLocFindNext (sfp->location, NULL);
- while (slp != NULL) {
- len = SeqLocLen (slp);
-
- if (len + total - frame <= (pbsp->length + 1) * 3) {
- total += len;
- } else {
- if (slp->choice == SEQLOC_INT) {
- sinp = (SeqIntPtr) slp->data.ptrvalue;
- if (sinp != NULL) {
- len = (pbsp->length + 1) * 3 - total;
- if (sinp->strand == Seq_strand_minus) {
- sinp->from = sinp->to - len + 1;
- } else {
- sinp->to = sinp->from + len - 1;
- }
- }
- }
- return;
- }
-
- slp = SeqLocFindNext (sfp->location, slp);
- }
-}
-
-/*------------------------------------------------------------------*/
-/* */
-/* PropagateCDS () - Called from DoFeatProp() for CDS-specific */
-/* feature propagation. */
-/* */
-/*------------------------------------------------------------------*/
-
-static void PropagateCDS (SeqFeatPtr dup,
- ProtRefPtr prp,
- BioseqPtr newbsp,
- Boolean stopCDS,
- Boolean transPast,
- Boolean cds3end,
- Uint1 frame,
- Uint1 strand)
-{
- Uint2 entityID;
- MolInfoPtr mip;
- Boolean partial3;
- Boolean partial5;
- BioseqPtr pbsp;
- SeqDescrPtr sdp;
- SeqIdPtr sip;
- SeqFeatXrefPtr xref;
- Boolean xtend;
-
- /* Check parameters */
-
- if (dup == NULL || dup->data.choice != SEQFEAT_CDREGION || prp == NULL)
- return;
-
- /* Extend the location to the end if that was checked */
-
- if (transPast && cds3end)
- ExtendLocToEnd (dup->location, newbsp, strand);
-
- /**/
-
- prp = AsnIoMemCopy ((Pointer) prp,
- (AsnReadFunc) ProtRefAsnRead,
- (AsnWriteFunc) ProtRefAsnWrite);
-
- xref = SeqFeatXrefNew ();
- if (xref == NULL)
- return;
- xref->data.choice = SEQFEAT_PROT;
- xref->data.value.ptrvalue = (Pointer) prp;
- xref->next = dup->xref;
- dup->xref = xref;
-
- entityID = ObjMgrGetEntityIDForPointer (newbsp);
- PromoteXrefsEx (dup, newbsp, entityID, (Boolean) (! stopCDS), FALSE, FALSE);
-
- /* Truncate new CDS based on new protein length */
-
- sip = SeqLocId (dup->product);
- if (sip == NULL)
- return;
-
- pbsp = BioseqFindCore (sip);
- if (pbsp == NULL)
- return;
-
- TruncateCDS (dup, frame, pbsp);
-
- /**/
-
- CheckSeqLocForPartial (dup->location, &partial5, &partial3);
- if (cds3end) {
- xtend = FALSE;
- if (strand == Seq_strand_minus) {
- if (SeqLocStop (dup->location) == 0) {
- xtend = TRUE;
- }
- } else {
- if (SeqLocStop (dup->location) == newbsp->length - 1) {
- xtend = TRUE;
- }
- }
- if (xtend) {
- partial3 = TRUE;
- SetSeqLocPartial (dup->location, partial5, partial3);
- for (sdp = pbsp->descr; sdp != NULL; sdp = sdp->next) {
- if (sdp->choice != Seq_descr_molinfo) continue;
- mip = (MolInfoPtr) sdp->data.ptrvalue;
- if (mip == NULL) continue;
- if (partial5 && partial3) {
- mip->completeness = 5;
- } else if (partial5) {
- mip->completeness = 3;
- } else if (partial3) {
- mip->completeness = 4;
- }
- }
- }
- }
-
- /* Set partial flag */
-
- dup->partial = (Boolean) (partial5 || partial3);
-}
-
-/*------------------------------------------------------------------*/
-/* */
-/* CalculateReadingFrame () -- Calculates a sequence's reading */
-/* frame by seeing which frame */
-/* generates the most amino acids */
-/* when converted to a protein. */
-/* */
-/*------------------------------------------------------------------*/
-
-static Int2 CalculateReadingFrame (SeqFeatPtr sfp, Boolean partial3)
-{
- ByteStorePtr bs;
- CdRegionPtr crp;
- Int4 len;
- Int4 max;
- Uint1 frame;
- Int2 i;
- CharPtr protstr;
-
- crp = (CdRegionPtr) sfp->data.value.ptrvalue;
-
- max = 0;
- frame = 0;
-
- if (! partial3 && crp->frame != 0)
- {
- bs = ProteinFromCdRegionEx (sfp, TRUE, FALSE);
- if (bs != NULL)
- {
- protstr = BSMerge (bs, NULL);
- BSFree (bs);
- if (protstr != NULL) {
- len = StringLen (protstr);
- if (len > 0 && protstr [len - 1] == '*') {
- MemFree (protstr);
- return crp->frame;
- }
- MemFree (protstr);
- }
- }
- }
- for (i = 1; i <= 3; i++) {
- crp->frame = (Uint1) i;
- bs = ProteinFromCdRegionEx (sfp, FALSE, FALSE);
- len = BSLen (bs);
- BSFree (bs);
- if (len > max) {
- max = len;
- frame = (Uint1) i;
- }
- }
-
- return frame;
-}
-
-/* we don't want to propagate Prot features if the target
- * sequence already has one.
- */
-static Boolean OkToPropagate(SeqFeatPtr sfp, BioseqPtr bsp)
-{
- SeqMgrFeatContext fcontext;
-
- if (sfp == NULL || bsp == NULL) return FALSE;
- /* never ok if a gap */
- if (sfp->idx.subtype == FEATDEF_gap) return FALSE;
- /* always ok if not a Prot feature */
- if (sfp->idx.subtype != FEATDEF_PROT) return TRUE;
- /* always ok if not a protein sequence */
- if (ISA_na (bsp->mol)) return TRUE;
- sfp = SeqMgrGetNextFeature (bsp, NULL, 0, FEATDEF_PROT, &fcontext);
- if (sfp == NULL)
- return TRUE;
- else
- return FALSE;
-}
-
-
-static SeqIdPtr GetSegSetId (SeqLocPtr slp)
-{
- SeqLocPtr sub_slp;
- SeqIdPtr master_sip, part_sip;
- BioseqPtr seg_bsp;
- BioseqSetPtr parent_set;
- BioseqSetPtr last_parent_set = NULL;
- SeqEntryPtr sep;
- BioseqPtr parent_bsp;
-
- if (slp == NULL) return NULL;
- master_sip = SeqLocId (slp);
- if (master_sip != NULL || slp->choice != SEQLOC_MIX)
- {
- return master_sip;
- }
- /* make sure all parts are from the same segmented set */
- for (sub_slp = slp->data.ptrvalue; sub_slp != NULL; sub_slp = sub_slp->next)
- {
- part_sip = SeqLocId (sub_slp);
- seg_bsp = BioseqFind (part_sip);
- if (seg_bsp == NULL || seg_bsp->idx.parenttype != OBJ_BIOSEQSET
- || seg_bsp->idx.parentptr == NULL)
- {
- return NULL;
- }
- parent_set = (BioseqSetPtr) seg_bsp->idx.parentptr;
- if (parent_set->_class != BioseqseqSet_class_parts
- || parent_set->idx.parenttype != OBJ_BIOSEQSET
- || parent_set->idx.parentptr == NULL)
- {
- return NULL;
- }
- if (last_parent_set == NULL)
- {
- last_parent_set = parent_set;
- }
- else if (last_parent_set != parent_set)
- {
- return NULL;
- }
- }
- if (last_parent_set == NULL)
- {
- return NULL;
- }
- parent_set = (BioseqSetPtr) last_parent_set->idx.parentptr;
- if (parent_set->_class != BioseqseqSet_class_segset)
- {
- return NULL;
- }
- for (sep = parent_set->seq_set; sep != NULL && ! IS_Bioseq (sep); sep = sep->next)
- {
- }
- if (sep == NULL) return NULL;
- parent_bsp = sep->data.ptrvalue;
- if (parent_bsp == NULL) return NULL;
- master_sip = parent_bsp->id;
- return master_sip;
-}
-
-/* for each feature, find all propagated locations and create features using
- * those locations.
- */
-static void
-PropagateOneFeat
-(SeqFeatPtr sfp,
- Boolean gapSplit,
- Boolean fuse_joints,
- Boolean stopCDS,
- Boolean transPast,
- Boolean cds3end,
- ValNodePtr seq_for_prop,
- BoolPtr warned_about_master)
-{
- ValNodePtr feature_location_list, vnp;
- ValNodePtr codebreak_location_list = NULL;
- ValNodePtr codebreak_choice_list = NULL;
- ValNodePtr anticodon_location_list = NULL;
- CodeBreakPtr cbp;
- CdRegionPtr crp;
- SeqFeatPtr dup;
- Uint1 frame = 0;
- BioseqPtr newbsp;
- SeqLocPtr newloc, mergedloc;
- Boolean partial5;
- Boolean partial3;
- RnaRefPtr rrp;
- SeqEntryPtr sep;
- SeqIdPtr sip;
- tRNAPtr trp;
- LocListPtr llp;
- Uint2 strand;
- ProtRefPtr prp = NULL;
- BioseqPtr pbsp;
- SeqFeatPtr prot;
-
- if (sfp == NULL || sfp->location == NULL) return;
-
- feature_location_list = MapLocForProp (sfp->location, gapSplit,
- seq_for_prop, warned_about_master);
- if (feature_location_list == NULL) return;
-
- CheckSeqLocForPartial (sfp->location, &partial5, &partial3);
-
- /* also need to propagate locations for CDS code breaks and tRNA anticodons */
- if (sfp->data.choice == SEQFEAT_CDREGION)
- {
- crp = (CdRegionPtr) sfp->data.value.ptrvalue;
- if (crp != NULL)
- {
- for (cbp = crp->code_break; cbp != NULL; cbp = cbp->next)
- {
- vnp = MapLocForProp (cbp->loc, gapSplit, seq_for_prop, warned_about_master);
- ValNodeAddPointer (&codebreak_location_list, 0, vnp);
- ValNodeAddPointer (&codebreak_choice_list, 0, &(cbp->aa));
- }
- }
- sip = SeqLocId (sfp->product);
- if (sip != NULL)
- {
- pbsp = BioseqFindCore (sip);
- if (pbsp != NULL)
- {
- prot = SeqMgrGetBestProteinFeature (pbsp, NULL);
- if (prot != NULL && prot->data.choice == SEQFEAT_PROT)
- {
- prp = (ProtRefPtr) prot->data.value.ptrvalue;
- }
- }
- }
- }
- else if (sfp->data.choice == SEQFEAT_RNA)
- {
- rrp = (RnaRefPtr) sfp->data.value.ptrvalue;
- if (rrp != NULL && rrp->ext.choice == 2)
- {
- trp = (tRNAPtr) rrp->ext.value.ptrvalue;
- if (trp != NULL && trp->anticodon != NULL)
- {
- anticodon_location_list = MapLocForProp (trp->anticodon, gapSplit,
- seq_for_prop, warned_about_master);
- }
- }
- }
-
- for (vnp = feature_location_list; vnp != NULL; vnp = vnp->next)
- {
- llp = (LocListPtr) vnp->data.ptrvalue;
- if (llp == NULL)
- {
- continue;
- }
- newloc = llp->slp;
- llp->slp = NULL;
- if (newloc == NULL)
- {
- continue;
- }
-
- mergedloc = NULL;
- if (fuse_joints)
- {
- mergedloc = MergeAdjacentSeqLocIntervals (newloc);
- if (mergedloc != NULL)
- {
- SeqLocFree (newloc);
- newloc = mergedloc;
- }
- }
-
- /* if we have a mixed location with multiple sequences, SeqLocId will
- * return NULL.
- * We should check to see if we are trying to create a feature for
- * a segset, in which case we'll want the Bioseq for the master segment.
- */
- sip = GetSegSetId (newloc);
-
- dup = AsnIoMemCopy ((Pointer) sfp,
- (AsnReadFunc) SeqFeatAsnRead,
- (AsnWriteFunc) SeqFeatAsnWrite);
- SeqLocFree (dup->location);
- dup->location = newloc;
- SetSeqLocPartial (dup->location, partial5, partial3);
-
- /* clean up product before we look for (and maybe don't find) the newbsp */
- if (dup->product != NULL)
- dup->product = SeqLocFree (dup->product);
-
- switch (dup->data.choice) {
- case SEQFEAT_CDREGION :
- crp = (CdRegionPtr) dup->data.value.ptrvalue;
- if (crp != NULL) {
- crp->frame = CalculateReadingFrame (dup, partial3);
- frame = crp->frame;
-
- PropagateCodeBreaks (crp, sip,
- codebreak_location_list,
- codebreak_choice_list);
- }
- break;
- case SEQFEAT_RNA :
- rrp = (RnaRefPtr) dup->data.value.ptrvalue;
- if (rrp != NULL && rrp->ext.choice == 2) {
- trp = (tRNAPtr) rrp->ext.value.ptrvalue;
- if (trp != NULL && trp->anticodon != NULL)
- {
- PropagateAnticodons (trp, sip, anticodon_location_list);
- }
- }
- break;
- default :
- break;
- }
-
- newbsp = BioseqFindCore (sip);
- if (newbsp == NULL)
- return;
-
- /* need to call OkToPropagate with sfp instead of dup
- * because dup has not been indexed yet, so subtype isn't set.
- */
- if (OkToPropagate(sfp, newbsp))
- {
- sep = SeqMgrGetSeqEntryForData (newbsp);
- if (sep == NULL)
- return;
- CreateNewFeature (sep, NULL, dup->data.choice, dup);
-
- /* If we're doing a CDS propagation, then */
- /* do the extra stuff related to that. */
-
- if (SEQFEAT_CDREGION == dup->data.choice)
- {
- strand = SeqLocStrand (dup->location);
-
- PropagateCDS (dup, prp, newbsp, stopCDS, transPast, cds3end, frame, strand);
- }
- }
- else
- {
- SeqFeatFree (dup);
- }
- }
-
- feature_location_list = FreeLocList (feature_location_list);
- anticodon_location_list = FreeLocList (anticodon_location_list);
- for (vnp = codebreak_location_list; vnp != NULL; vnp = vnp->next)
- {
- vnp->data.ptrvalue = FreeLocList (vnp->data.ptrvalue);
- }
- codebreak_location_list = ValNodeFree (codebreak_location_list);
- codebreak_choice_list = ValNodeFree (codebreak_choice_list);
-
-}
-
-
-static Boolean CDSgoesToEnd (
- BioseqPtr bsp,
- SeqMgrFeatContext PNTR fcontext
-)
-
-{
- if (fcontext->strand == Seq_strand_minus) {
- if (fcontext->left == 0 && fcontext->partialR) return TRUE;
- } else {
- if (fcontext->right == bsp->length - 1 && fcontext->partialR) return TRUE;
- }
- return FALSE;
-}
-
-static void DoFixCDS (
- SeqFeatPtr sfp,
- Pointer userdata
-)
-
-{
- BaseFormPtr bfp;
- ByteStorePtr bs;
- BioseqPtr bsp;
- Boolean change_partials = FALSE;
- SeqMgrFeatContext context;
- CdRegionPtr crp;
- size_t len;
- Boolean partial5;
- Boolean partial3;
- SeqIntPtr sintp;
- SeqLocPtr slp;
- CharPtr str;
-
- if (sfp == NULL || sfp->data.choice != SEQFEAT_CDREGION) return;
- bfp = (BaseFormPtr) userdata;
- if (SeqMgrGetDesiredFeature (bfp->input_entityID, NULL,
- 0, 0, sfp, &context) != sfp) return;
- bsp = context.bsp;
- if (bsp == NULL) return;
-
- CheckSeqLocForPartial (sfp->location, &partial5, &partial3);
- crp = (CdRegionPtr) sfp->data.value.ptrvalue;
- if (crp->frame > 1) {
- if (context.strand == Seq_strand_minus) {
- if (context.right == bsp->length - 1) {
- partial5 = TRUE;
- change_partials = TRUE;
- }
- } else {
- if (context.left == 0) {
- partial5 = TRUE;
- change_partials = TRUE;
- }
- }
- }
- bs = ProteinFromCdRegion (sfp, TRUE);
- if (bs != NULL) {
- str = BSMerge (bs, NULL);
- BSFree (bs);
- if (str != NULL) {
- if (*str == '-') {
- if (! partial5) {
- partial5 = TRUE;
- change_partials = TRUE;
- }
- }
- len = StringLen (str);
- if (len > 0 && str [len - 1] != '*') {
- if (context.strand == Seq_strand_minus) {
- } else {
- if (bsp->length - context.right < 3) {
- slp = SeqLocFindNext (sfp->location, NULL);
- while (slp != NULL) {
- if (slp->choice == SEQLOC_INT) {
- sintp = (SeqIntPtr) slp->data.ptrvalue;
- if (sintp != NULL) {
- if (sintp->to == context.right) {
- sintp->to = bsp->length - 1;
- }
- }
- }
- slp = SeqLocFindNext (sfp->location, slp);
- }
- }
- partial3 = TRUE;
- change_partials = TRUE;
- }
- }
- MemFree (str);
- }
- }
- if (change_partials) {
- SetSeqLocPartial (sfp->location, partial5, partial3);
- ResynchCDSPartials (sfp, NULL);
- }
-}
extern void FixCdsAfterPropagate (
IteM i
@@ -10867,339 +9463,6 @@ extern void FixCdsAfterPropagate (
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
}
-static SeqFeatPtr
-GetNextFeatureOnSegOrMaster
-(BioseqPtr bsp, SeqFeatPtr sfp, Uint4 itemID, Uint4 index, SeqMgrFeatContextPtr fcontext)
-{
- BioseqSetPtr bssp;
- SeqEntryPtr sep;
- BioseqPtr master_bsp = NULL;
- SeqFeatPtr next_sfp;
- SeqLocPtr slp;
- SeqIdPtr loc_id;
- Boolean on_this_segment = FALSE;
-
- if (bsp == NULL)
- {
- return NULL;
- }
- if (bsp->idx.parenttype != OBJ_BIOSEQSET || bsp->idx.parentptr == NULL)
- {
- return SeqMgrGetNextFeature (bsp, sfp, itemID, index, fcontext);
- }
-
- bssp = (BioseqSetPtr) bsp->idx.parentptr;
- if (bssp == NULL || bssp->_class != BioseqseqSet_class_parts
- || bssp->idx.parenttype != OBJ_BIOSEQSET || bsp->idx.parentptr == NULL)
- {
- return SeqMgrGetNextFeature (bsp, sfp, itemID, index, fcontext);
- }
-
- bssp = bssp->idx.parentptr;
- if (bssp->_class != BioseqseqSet_class_segset)
- {
- return SeqMgrGetNextFeature (bsp, sfp, itemID, index, fcontext);
- }
-
- for (sep = bssp->seq_set; sep != NULL && master_bsp == NULL; sep = sep->next)
- {
- if (IS_Bioseq (sep))
- {
- master_bsp = sep->data.ptrvalue;
- if (master_bsp != NULL && master_bsp->repr != Seq_repr_seg)
- {
- master_bsp = NULL;
- }
- }
- }
-
- if (master_bsp == NULL)
- {
- return SeqMgrGetNextFeature (bsp, sfp, itemID, index, fcontext);
- }
-
- next_sfp = SeqMgrGetNextFeature (master_bsp, sfp, itemID, index, fcontext);
- if (next_sfp == NULL) return NULL;
-
- while (next_sfp != NULL && !on_this_segment)
- {
- for (slp = SeqLocFindNext (next_sfp->location, NULL);
- slp != NULL && ! on_this_segment; slp = SeqLocFindNext (next_sfp->location, slp))
- {
- loc_id = SeqLocId (slp);
- if (SeqIdIn (loc_id, bsp->id))
- {
- on_this_segment = TRUE;
- }
- }
- if (!on_this_segment)
- {
- next_sfp = SeqMgrGetNextFeature (master_bsp, next_sfp, itemID, index, fcontext);
- }
- }
-
- return next_sfp;
-}
-
-
-static void AcceptFeatProp (
- ButtoN b
-)
-
-{
- BioseqPtr bsp;
- Boolean cds3end;
- DenseSegPtr dsp;
- Uint2 entityID;
- SeqMgrFeatContext fcontext;
- FprDataPtr fdp;
- Boolean fixCDS;
- Boolean gapSplit;
- SeqAlignPtr salp;
- SeqEntryPtr sep;
- SeqFeatPtr sfp;
- SeqIdPtr sip;
- SeqIdPtr sip_head;
- SeqIdPtr sip_new;
- SeqIdPtr sip_prev;
- SeqIdPtr sip_tmp;
- Boolean stopCDS;
- Boolean transPast;
- Boolean fuse_joints = FALSE;
- Boolean warned_about_master = FALSE;
- ValNodePtr seq_for_prop = NULL;
-
- fdp = (FprDataPtr) GetObjectExtra (b);
- if (fdp == NULL) return;
- SafeHide (fdp->form);
-
- bsp = fdp->bsp;
- salp = fdp->salp;
- if (bsp == NULL || salp == NULL) {
- Remove (fdp->form);
- return;
- }
-
- if (GetValue (fdp->allOrSel) == 1) {
- fdp->selFeatItemID = 0;
- }
- if (GetValue (fdp->gapSplit) == 1) {
- gapSplit = FALSE;
- } else {
- gapSplit= TRUE;
- }
- if (GetStatus (fdp->stopCDS)) {
- stopCDS = TRUE;
- } else {
- stopCDS = FALSE;
- }
- if (GetStatus (fdp->transPast)) {
- transPast = TRUE;
- } else {
- transPast = FALSE;
- }
- if (GetStatus (fdp->fixCDS)) {
- fixCDS = TRUE;
- } else {
- fixCDS = FALSE;
- }
- if (GetStatus (fdp->fuseJoints)) {
- fuse_joints = TRUE;
- } else {
- fuse_joints = FALSE;
- }
-
- seq_for_prop = DialogToPointer (fdp->sequence_list_dlg);
-
- SeqEntrySetScope (NULL);
-
- /* need to find alignment for each feature and row within that alignment for the feature */
-
- dsp = (DenseSegPtr)(salp->segs);
- sip = SeqIdFindBest (bsp->id, 0);
- sip_tmp = dsp->ids;
- sip_head = sip_prev = NULL;
- while (sip_tmp != NULL)
- {
- if (SeqIdComp(sip_tmp, bsp->id) == SIC_YES)
- sip_new = SeqIdDup(sip);
- else
- sip_new = SeqIdDup(sip_tmp);
- if (sip_head != NULL)
- {
- sip_prev->next = sip_new;
- sip_prev = sip_new;
- } else
- sip_head = sip_prev = sip_new;
- sip_tmp = sip_tmp->next;
- }
- dsp->ids = sip_head;
-
- if (fdp->selFeatItemID != 0) {
-
- /* propagate single selected feature */
-
- sfp = SeqMgrGetDesiredFeature (0, bsp, fdp->selFeatItemID, 0, NULL, &fcontext);
- if (sfp != NULL) {
- cds3end = CDSgoesToEnd (bsp, &fcontext);
- PropagateOneFeat (sfp, gapSplit, fuse_joints, stopCDS, transPast,
- cds3end, seq_for_prop, &warned_about_master);
- }
- } else {
-
- /* propagate all features on bioseq */
-
- sfp = GetNextFeatureOnSegOrMaster (bsp, NULL, 0, 0, &fcontext);
- while (sfp != NULL) {
- cds3end = CDSgoesToEnd (bsp, &fcontext);
- PropagateOneFeat (sfp, gapSplit, fuse_joints, stopCDS, transPast,
- cds3end, seq_for_prop, &warned_about_master);
-
- sfp = GetNextFeatureOnSegOrMaster (bsp, sfp, 0, 0, &fcontext);
- }
- }
-
- seq_for_prop = ValNodeFree (seq_for_prop);
- if (fixCDS) {
- entityID = ObjMgrGetEntityIDForPointer (bsp);
- sep = GetTopSeqEntryForEntityID (entityID);
- fdp->input_entityID = entityID;
- /* reindex before calling DoFixCDS */
- SeqMgrIndexFeatures (entityID, NULL);
- VisitFeaturesInSep (sep, fdp, DoFixCDS);
- }
-
- entityID = ObjMgrGetEntityIDForPointer (bsp);
- ObjMgrSetDirtyFlag (entityID, TRUE);
- ObjMgrSendMsg (OM_MSG_UPDATE, entityID, 0, 0);
-
- Remove (fdp->form);
-}
-
-static void SetFeaturePropagateAccept (Pointer userdata)
-{
- FprDataPtr fdp;
- ValNodePtr err_list;
-
- fdp = (FprDataPtr) userdata;
- if (fdp == NULL)
- {
- return;
- }
- err_list = TestDialog (fdp->sequence_list_dlg);
- if (err_list == NULL)
- {
- Enable (fdp->accept);
- }
- else
- {
- Disable (fdp->accept);
- }
- ValNodeFree (err_list);
-}
-
-static ForM FeaturePropagateForm (
- BioseqPtr bsp,
- SeqAlignPtr salp,
- Uint2 selFeatItemID
-)
-
-{
- ButtoN b;
- GrouP c;
- GrouP seq_choice_grp;
- FprDataPtr fdp;
- GrouP g;
- PrompT ppt;
- SeqIdPtr sip;
- Char strid [MAX_ID_LEN];
- Char txt [128];
- WindoW w;
- Uint2 entityID;
-
- if (bsp == NULL) return NULL;
- fdp = (FprDataPtr) MemNew (sizeof (FprData));
- if (fdp == NULL) return NULL;
- w = FixedWindow (-50, -33, -10, -10, "Feature Propagate", NULL);
- if (w == NULL) return NULL;
-
- SetObjectExtra (w, (Pointer) fdp, StdCleanupFormProc);
- fdp->form = (ForM) w;
- fdp->formmessage = UpdateSequenceFormMessage;
-
-#ifdef WIN_MAC
- fdp->activate = UpdateSequenceFormActivated;
- SetActivate (w, UpdateSequenceFormActivate);
-#endif
-
- fdp->bsp = bsp;
- fdp->salp = salp;
- fdp->selFeatItemID = selFeatItemID;
-
- sip = SeqIdFindWorst (bsp->id);
- SeqIdWrite (sip, strid, PRINTID_REPORT, sizeof (strid) - 1);
- if (ISA_na (bsp->mol)) {
- sprintf (txt, "Propagate from %s to", strid);
- } else {
- sprintf (txt, "Propagate from %s to", strid);
- }
-
- g = HiddenGroup (w, -1, 0, NULL);
- SetGroupSpacing (g, 5, 5);
-
- seq_choice_grp = HiddenGroup (g, 0, 2, NULL);
- ppt = StaticPrompt (seq_choice_grp, txt, 0, 0, programFont, 'c');
- entityID = ObjMgrGetEntityIDForPointer (bsp);
- fdp->sequence_list_dlg = SequenceSelectionDialog (seq_choice_grp,
- SetFeaturePropagateAccept,
- fdp,
- TRUE,
- ISA_na (bsp->mol),
- ISA_aa (bsp->mol),
- entityID);
-
- fdp->allOrSel = HiddenGroup (g, 2, 0, NULL);
- RadioButton (fdp->allOrSel, "All Features");
- b = RadioButton (fdp->allOrSel, "Selected Feature");
- if (selFeatItemID > 0) {
- SetValue (fdp->allOrSel, 2);
- } else {
- Disable (b);
- SetValue (fdp->allOrSel, 1);
- }
-
- fdp->gapSplit = HiddenGroup (g, 2, 0, NULL);
- RadioButton (fdp->gapSplit, "Extend over gaps");
- RadioButton (fdp->gapSplit, "Split at gaps");
- SetValue (fdp->gapSplit, 1);
-
- fdp->stopCDS = CheckBox (g, "Stop CDS translation at internal stop codon", NULL);
- SetStatus (fdp->stopCDS, FALSE);
-
- fdp->transPast = CheckBox (g, "Translate CDS after partial 3' boundary", NULL);
-
- fdp->fixCDS = CheckBox (g, "Cleanup CDS partials after propagation", NULL);
- SetStatus (fdp->fixCDS, TRUE);
-
- fdp->fuseJoints = CheckBox (g, "Fuse adjacent propagated intervals", NULL);
- SetStatus (fdp->fuseJoints, FALSE);
-
- c = HiddenGroup (w, 4, 0, NULL);
- fdp->accept = DefaultButton (c, "Accept", AcceptFeatProp);
- SetObjectExtra (fdp->accept, (Pointer) fdp, NULL);
- PushButton (c, "Cancel", StdCancelButtonProc);
-
- AlignObjects (ALIGN_CENTER, (HANDLE) seq_choice_grp, (HANDLE) fdp->allOrSel,
- (HANDLE) fdp->gapSplit, (HANDLE) fdp->stopCDS,
- (HANDLE) fdp->transPast, (HANDLE) fdp->fixCDS,
- (HANDLE) fdp->fuseJoints,
- (HANDLE) c, NULL);
- RealizeWindow (w);
- SendMessageToDialog (fdp->sequence_list_dlg, NUM_VIB_MSG + 1);
-
-
- return (ForM) w;
-}
extern void NewFeaturePropagate (
IteM i