1202
1432
extern void RetranslateCdRegionsNoStop (IteM i)
1205
RetranslateCdRegions (i, FALSE);
1435
RetranslateCdRegions (i, FALSE, FALSE);
1208
1438
extern void RetranslateCdRegionsDoStop (IteM i)
1211
RetranslateCdRegions (i, TRUE);
1441
RetranslateCdRegions (i, TRUE, FALSE);
1444
extern void RetranslateCdRegionsNoStopExceptEndCompleteCDS (IteM i)
1446
RetranslateCdRegions (i, TRUE, TRUE);
1450
static void DoReprocessPeptides (SeqFeatPtr sfp, Pointer userdata)
1453
SeqFeatPtr bestprot;
1467
if (sfp->data.choice != SEQFEAT_PROT) return;
1468
if (sfp->product == NULL) return;
1469
prp = (ProtRefPtr) sfp->data.value.ptrvalue;
1470
if (prp == NULL) return;
1471
if (prp->processed < 1 || prp->processed > 4) return;
1472
CheckSeqLocForPartial (sfp->location, &partial5, &partial3);
1473
sip = SeqLocId (sfp->product);
1474
if (sip == NULL) return;
1475
bsp = BioseqFind (sip);
1476
if (bsp != NULL && ISA_aa (bsp->mol) && bsp->repr == Seq_repr_raw) {
1477
bestprot = FindBestProtein (sfp->idx.entityID, sfp->product);
1478
prot = GetSequenceByFeature (sfp);
1479
if (prot == NULL) return;
1482
while (ch != '\0') {
1483
*ptr = TO_UPPER (ch);
1490
BSWrite (bs, (VoidPtr) ptr, (Int4) StringLen (ptr));
1492
bsp->repr = Seq_repr_raw;
1493
bsp->mol = Seq_mol_aa;
1494
bsp->seq_data_type = Seq_code_ncbieaa;
1495
bsp->seq_data = BSFree (bsp->seq_data);
1497
bsp->length = BSLen (bs);
1498
sep = SeqMgrGetSeqEntryForData (bsp);
1499
if (sep == NULL) return;
1500
if (bestprot != NULL) {
1501
bestprot->location = SeqLocFree (bestprot->location);
1502
bestprot->location = CreateWholeInterval (sep);
1503
SetSeqLocPartial (bestprot->location, partial5, partial3);
1504
bestprot->partial = (partial5 || partial3);
1506
vnp = SeqEntryGetSeqDescr (sep, Seq_descr_molinfo, NULL);
1508
vnp = CreateNewDescriptor (sep, Seq_descr_molinfo);
1510
mip = MolInfoNew ();
1511
vnp->data.ptrvalue = (Pointer) mip;
1519
mip = (MolInfoPtr) vnp->data.ptrvalue;
1521
if (partial5 && partial3) {
1522
mip->completeness = 5;
1523
} else if (partial5) {
1524
mip->completeness = 3;
1525
} else if (partial3) {
1526
mip->completeness = 4;
1528
} else if (partial) {
1529
mip->completeness = 2;
1532
mip->completeness = 0;
1539
extern void ReprocessPeptideProducts (IteM i);
1540
extern void ReprocessPeptideProducts (IteM i)
1547
bfp = currentFormDataPtr;
1549
bfp = GetObjectExtra (i);
1551
if (bfp == NULL) return;
1552
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
1553
if (sep == NULL) return;
1554
VisitFeaturesInSep (sep, NULL, DoReprocessPeptides);
1556
ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
1557
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
1560
static void DoReprocessMrnas (SeqFeatPtr sfp, Pointer userdata)
1576
if (sfp->data.choice != SEQFEAT_RNA) return;
1577
if (sfp->product == NULL) return;
1578
rrp = (RnaRefPtr) sfp->data.value.ptrvalue;
1579
if (rrp == NULL) return;
1580
if (rrp->type != 2) return;
1581
CheckSeqLocForPartial (sfp->location, &partial5, &partial3);
1582
sip = SeqLocId (sfp->product);
1583
if (sip == NULL) return;
1584
bsp = BioseqFind (sip);
1585
if (bsp != NULL && ISA_na (bsp->mol) && bsp->repr == Seq_repr_raw) {
1586
prot = GetSequenceByFeature (sfp);
1587
if (prot == NULL) return;
1590
while (ch != '\0') {
1591
*ptr = TO_UPPER (ch);
1598
BSWrite (bs, (VoidPtr) ptr, (Int4) StringLen (ptr));
1600
bsp->repr = Seq_repr_raw;
1601
bsp->mol = Seq_mol_na;
1602
bsp->seq_data_type = Seq_code_iupacna;
1603
bsp->seq_data = BSFree (bsp->seq_data);
1605
bsp->length = BSLen (bs);
1606
sep = SeqMgrGetSeqEntryForData (bsp);
1607
if (sep == NULL) return;
1608
vnp = SeqEntryGetSeqDescr (sep, Seq_descr_molinfo, NULL);
1610
vnp = CreateNewDescriptor (sep, Seq_descr_molinfo);
1612
mip = MolInfoNew ();
1613
vnp->data.ptrvalue = (Pointer) mip;
1621
mip = (MolInfoPtr) vnp->data.ptrvalue;
1623
if (partial5 && partial3) {
1624
mip->completeness = 5;
1625
} else if (partial5) {
1626
mip->completeness = 3;
1627
} else if (partial3) {
1628
mip->completeness = 4;
1630
} else if (partial) {
1631
mip->completeness = 2;
1634
mip->completeness = 0;
1641
extern void ReprocessmRNAProducts (IteM i);
1642
extern void ReprocessmRNAProducts (IteM i)
1649
bfp = currentFormDataPtr;
1651
bfp = GetObjectExtra (i);
1653
if (bfp == NULL) return;
1654
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
1655
if (sep == NULL) return;
1656
VisitFeaturesInSep (sep, NULL, DoReprocessMrnas);
1658
ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
1659
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
1663
* ApplyCodeBreakToCDS
1666
static Boolean ApplyCodeBreakToCDS (SeqFeatPtr sfp, CharPtr codonStr, Int2 aaNum)
1678
CodeBreakPtr lastCbp;
1679
SeqCodeTablePtr sctp;
1681
Boolean added_code_breaks = FALSE;
1683
if (sfp == NULL || codonStr == NULL)
1688
/* Get the nucleotide sequence */
1690
dnaLen = SeqLocLen (sfp->location);
1694
crp = (CdRegionPtr) sfp->data.value.ptrvalue;
1696
bases = ReadCodingRegionBases (sfp->location, dnaLen, crp->frame, &total);
1698
/* Search for the selected codon in the */
1699
/* nucleotide sequence. If found, add */
1700
/* it as a codebreak. */
1704
while (basePtr[0] != '\0') {
1705
if (StringNCmp (basePtr, codonStr, 3) == 0) {
1707
/* Create a new seq point object with the aa location */
1709
aaSpp = SeqPntNew ();
1710
aaSpp->point = aaPosition;
1711
aaSpp->strand = Seq_strand_plus;
1712
aaSpp->id = SeqLocId (sfp->product);
1715
/* Make a SeqLoc using the seq point */
1717
aaSlp = (SeqLocPtr) ValNodeNew (NULL);
1718
aaSlp->choice = SEQLOC_PNT;
1719
aaSlp->data.ptrvalue = (Pointer) aaSpp;
1721
/* Convert the seqloc to a DNA location */
1723
dnaSlp = aaLoc_to_dnaLoc (sfp, aaSlp);
1725
/* Create the code break using the DNA location */
1727
cbp = CodeBreakNew ();
1729
sctp = SeqCodeTableFind (Seq_code_ncbieaa);
1730
aaChar = (Uint1) GetSymbolForResidue (sctp, aaNum);
1731
cbp->aa.value.intvalue = aaChar;
1732
cbp->aa.choice = 1; /* ncbieaa */
1734
/* Insert the code break into the CDS's */
1735
/* existing list of code breaks. */
1737
lastCbp = crp->code_break;
1738
if (lastCbp == NULL)
1740
crp->code_break = cbp;
1744
while (lastCbp->next != NULL)
1746
lastCbp = lastCbp->next;
1748
lastCbp->next = cbp;
1752
added_code_breaks = TRUE;
1758
return added_code_breaks;
1761
/*---------------------------------------------------------------------*/
1763
/* ApplyCodeBreak_FeatureCallback () -- Called for each CDS feature in */
1764
/* a Bioseq. Checks for any */
1765
/* nucleotide triplets that match */
1766
/* the one in the given code */
1767
/* break and sets a code break */
1768
/* for each one that is found. */
1770
/*---------------------------------------------------------------------*/
1772
static Boolean LIBCALLBACK ApplyCodeBreak_FeatureCallback (SeqFeatPtr sfp,
1773
SeqMgrFeatContextPtr fcontext)
1776
CodeBreakFormPtr cbfp;
1780
cbfp = (CodeBreakFormPtr) fcontext->userdata;
1783
/* Get the selected Amino Acid and codon triplet */
1785
GetTitle (cbfp->codonText, codonStr, sizeof (codonStr));
1786
for (i = 0; i < 3; i++)
1787
codonStr [i] = TO_UPPER (codonStr [i]);
1789
aaNum = GetValue (cbfp->aminoAcidPopup);
1801
if (ApplyCodeBreakToCDS (sfp, codonStr, aaNum))
1803
/* Retranslate the CDS */
1805
RetranslateOneCDS (sfp, fcontext->entityID, TRUE, FALSE);
1809
/* Return TRUE to continue on to the next CDS feature */
1814
/*---------------------------------------------------------------------*/
1816
/* ApplyCodeBreak_BioseqCallback () -- Called by SeqMgrExploreBioseqs */
1817
/* for each Bioseq. Searches the */
1818
/* Bioseq for CDS features and adds*/
1819
/* the given code break to any */
1822
/*---------------------------------------------------------------------*/
1824
static Boolean LIBCALLBACK ApplyCodeBreak_BioseqCallback (BioseqPtr bsp,
1825
SeqMgrBioseqContextPtr bcontext)
1827
Boolean featureFilterArray [SEQFEAT_MAX];
1829
/* Set up to explore only CDS features */
1831
MemSet ((Pointer) (featureFilterArray),
1835
featureFilterArray[SEQFEAT_CDREGION] = TRUE;
1837
/* Explore the Bioseq's CDS features, marking the */
1838
/* ones with internal stop codons as pseudo. */
1840
SeqMgrExploreFeatures (bsp, bcontext->userdata,
1841
ApplyCodeBreak_FeatureCallback, NULL,
1842
featureFilterArray, NULL);
1844
/* Return TRUE to continue on to the next Bioseq */
1849
/*---------------------------------------------------------------------*/
1851
/* DoAddCodeBreak_Callback () -- Called when the 'Apply' button is */
1852
/* pressed in the "Add Code Break" */
1853
/* window. Adds the entered code break */
1854
/* to all CDS features. */
1856
/*---------------------------------------------------------------------*/
1858
static void DoAddCodeBreak_Callback (ButtoN b)
1860
CodeBreakFormPtr cbfp;
1862
cbfp = (CodeBreakFormPtr) GetObjectExtra (b);
1864
/* Change to the "working" cursor */
1870
/* Visit all the Bioseqs, where we will */
1871
/* then explore their CDS features. */
1873
SeqMgrExploreBioseqs (cbfp->input_entityID, NULL, (Pointer) cbfp,
1874
ApplyCodeBreak_BioseqCallback, TRUE, FALSE, TRUE);
1876
/* Restore the cursor and force an update */
1880
ObjMgrSetDirtyFlag (cbfp->input_entityID, TRUE);
1881
ObjMgrSendMsg (OM_MSG_UPDATE, cbfp->input_entityID, 0, 0);
1882
Remove (cbfp->form);
1885
/*---------------------------------------------------------------------*/
1887
/* PopulateAAPopup () -- Creates a popup list of amino acids. */
1889
/* NOTE : This function is identical to (and identically named as) */
1890
/* a function in cdrgn.c */
1892
/*---------------------------------------------------------------------*/
1894
static void PopulateAAPopup (PopuP AAitem)
1902
SeqCodeTablePtr sctp;
1905
sctp = SeqCodeTableFind (Seq_code_ncbieaa);
1906
first = FirstResidueInCode (sctp);
1907
last = LastResidueInCode (sctp);
1908
PopupItem (AAitem, " ");
1909
for (i = 65; i <= last; i++) {
1910
if (i == 74 || i == 79) {
1913
ch = GetSymbolForResidue (sctp, i);
1914
str = (CharPtr) GetNameForResidue (sctp, i);
1915
sprintf (item, "%c %s", ch, str);
1916
PopupItem (AAitem, item);
1918
SetValue (AAitem, 1);
1921
/*---------------------------------------------------------------------*/
1923
/* IsLegalCodon () - Determines if a three base string is a legal */
1926
/*---------------------------------------------------------------------*/
1928
static Boolean IsLegalCodon (CharPtr codonStr)
1933
/* Only allow three characters */
1935
if (StringLen (codonStr) > 3)
1938
/* Allow only the character A,C,G,T,U and */
1939
/* convert the U to a T. */
1944
if (codonStr [i] == '\0')
1947
baseChar = codonStr [i];
1949
if (StringChr ("acgtuACGTU", baseChar) == NULL)
1951
if ('U' == baseChar)
1953
else if ('u' == baseChar)
1959
/* If we made it this far, it's a valid codon */
1964
/*---------------------------------------------------------------------*/
1966
/* CodonText_Callback () -- Called whenever a keystoke is entered in */
1967
/* Codon text field. Validates to see if the */
1968
/* keystroke should be allowed. */
1970
/*---------------------------------------------------------------------*/
1972
static void CodonText_Callback (TexT codonText)
1975
CodeBreakFormPtr cbfp;
1977
Char newCodonStr [5];
1979
/* Get the currect code break data */
1981
cbfp = (CodeBreakFormPtr) GetObjectExtra (codonText);
1985
/* If the new codon string is not legal */
1986
/* then reset to the previous text. */
1988
GetTitle (codonText, newCodonStr, sizeof (newCodonStr));
1990
if (!IsLegalCodon (newCodonStr))
1991
StringCpy (newCodonStr, cbfp->currentCodonStr);
1993
StringCpy (cbfp->currentCodonStr, newCodonStr);
1995
SafeSetTitle (cbfp->codonText, newCodonStr);
1997
/* Only enable the accept button if */
1998
/* we have a full codon. */
2000
if (StringLen (newCodonStr) != 3) {
2001
SafeDisable (cbfp->acceptButton);
2005
/* See if an amino acid has been selected yet */
2007
aaNum = GetValue (cbfp->aminoAcidPopup);
2009
SafeDisable (cbfp->acceptButton);
2013
/* If we made it this far then we have both a codon and */
2014
/* an amino acid, so enable the accept button. */
2016
SafeEnable (cbfp->acceptButton);
2019
/*---------------------------------------------------------------------*/
2021
/* SelectAminoAcid_Callback () -- Called whenever a new amino acid is */
2022
/* selected in the Amino Acid Popup. */
2023
/* Toggles 'Accept' button base on */
2024
/* current state. */
2026
/*---------------------------------------------------------------------*/
2028
static void SelectAminoAcid_Callback (PopuP p)
2030
CodeBreakFormPtr cbfp;
2034
/* Get the currect code break data */
2036
cbfp = (CodeBreakFormPtr) GetObjectExtra (p);
2040
/* Only enable the accept button if */
2041
/* we have a full codon. */
2043
GetTitle (cbfp->codonText, codonStr, sizeof (codonStr));
2044
if (StringLen (codonStr) != 3) {
2045
SafeDisable (cbfp->acceptButton);
2049
/* Get the newly selected amino acid */
2051
aaNum = GetValue (cbfp->aminoAcidPopup);
2053
/* If an amino acid is selected then */
2054
/* enable the accept button. */
2057
SafeEnable (cbfp->acceptButton);
2059
SafeDisable (cbfp->acceptButton);
2062
/*---------------------------------------------------------------------*/
2064
/* AddGlobalCodeBreak () -- Gets a nucleotide triplet and an amino */
2065
/* acid from the user and adds them as */
2066
/* codebreaks for all CDS features. */
2068
/*---------------------------------------------------------------------*/
2070
extern void AddGlobalCodeBreak (IteM i);
2071
extern void AddGlobalCodeBreak (IteM i)
2078
CodeBreakFormPtr cbfp;
2080
/* Get the current state of things */
2083
bfp = currentFormDataPtr;
2085
bfp = GetObjectExtra (i);
2090
cbfp = (CodeBreakFormPtr) MemNew (sizeof (EvidenceFormData));
2092
/* Create a window to get the codon and */
2093
/* the Amino acid from the user. */
2095
breakWin = FixedWindow (-50, -33, -10, -10,
2096
"Add Code Break", StdCloseWindowProc);
2097
SetObjectExtra (breakWin, cbfp, StdCleanupFormProc);
2098
cbfp->form = (ForM) breakWin;
2099
cbfp->formmessage = NULL;
2100
cbfp->input_entityID = bfp->input_entityID;
2102
mainGroup = HiddenGroup (breakWin, -2, 0, NULL);
2104
/* Create a text entry box for the nucl. codon */
2106
StaticPrompt (mainGroup, "Triplet Codon", 0, popupMenuHeight,
2108
cbfp->codonText = DialogText (mainGroup, "", 3, CodonText_Callback);
2109
SetObjectExtra (cbfp->codonText, cbfp, NULL);
2110
cbfp->currentCodonStr [0] = '\0';
2112
/* Add a Popup list of Amino Acids */
2114
StaticPrompt (mainGroup, "Amino Acid", 0, popupMenuHeight,
2116
cbfp->aminoAcidPopup = PopupList (mainGroup, TRUE,
2117
SelectAminoAcid_Callback);
2118
PopulateAAPopup (cbfp->aminoAcidPopup);
2119
SetObjectExtra (cbfp->aminoAcidPopup, cbfp, NULL);
2121
/* Add Accept and Cancel buttons */
2123
buttGroup = HiddenGroup (breakWin, 2, 0, NULL);
2124
cbfp->acceptButton = DefaultButton (buttGroup, "Accept",
2125
DoAddCodeBreak_Callback);
2126
SetObjectExtra (cbfp->acceptButton, cbfp, NULL);
2127
SafeDisable (cbfp->acceptButton);
2128
PushButton (buttGroup, "Cancel", StdCancelButtonProc);
2130
/* Line things up and display the window */
2132
AlignObjects (ALIGN_CENTER, (HANDLE) mainGroup, (HANDLE) buttGroup, NULL);
2133
RealizeWindow (breakWin);
2139
static void ParseCodonQualToCodeBreakCallback (SeqFeatPtr sfp, Pointer userdata)
2141
SeqCodeTablePtr sctp;
2142
GBQualPtr gqual, prev_qual = NULL, next_qual;
2145
Char symbol_text [4];
2148
Boolean converted_qual;
2150
if (sfp == NULL || sfp->data.choice != SEQFEAT_CDREGION || userdata == NULL)
2155
sctp = (SeqCodeTablePtr) userdata;
2157
for (gqual = sfp->qual; gqual != NULL; gqual = next_qual)
2159
next_qual = gqual->next;
2160
converted_qual = FALSE;
2161
if (StringCmp (gqual->qual, "codon") == 0)
2163
cp = StringSearch (gqual->val, "seq:\"");
2167
StringNCpy (codon_text, cp, 3);
2169
for (i = 0; i < 3; i++)
2170
codon_text [i] = TO_UPPER (codon_text [i]);
2172
cp = StrChr (cp, ':');
2176
StringNCpy (symbol_text, cp, 3);
2177
symbol_text [3] = 0;
2178
aaNum = FindResidueByName (symbol_text, sctp);
2179
if (ApplyCodeBreakToCDS (sfp, codon_text, aaNum))
2181
/* Retranslate the CDS */
2183
RetranslateOneCDS (sfp, sfp->idx.entityID, TRUE, FALSE);
2185
/* remove the codon qual */
2186
if (prev_qual == NULL)
2188
sfp->qual = gqual->next;
2192
prev_qual->next = gqual->next;
2196
converted_qual = TRUE;
2201
if (!converted_qual)
2208
extern void ParseCodonQualToCodeBreak (IteM i)
2212
SeqCodeTablePtr sctp;
2215
bfp = currentFormDataPtr;
2217
bfp = GetObjectExtra (i);
2219
if (bfp == NULL) return;
2221
sep = GetTopSeqEntryForEntityID (bfp->input_entityID);
2222
if (sep == NULL) return;
2227
sctp = SeqCodeTableFind (Seq_code_ncbieaa);
2229
VisitFeaturesInSep (sep, sctp, ParseCodonQualToCodeBreakCallback);
2230
ObjMgrSetDirtyFlag (bfp->input_entityID, TRUE);
2231
ObjMgrSendMsg (OM_MSG_UPDATE, bfp->input_entityID, 0, 0);
1214
2236
static Boolean CorrectGenCodeCallback (GatherContextPtr gcp)
1808
2830
Boolean is_feature;
1811
2835
Uint2 itemtype;
1815
2837
ValNodePtr head;
1816
2838
Boolean stringfound;
1817
2839
Char findStr [128];
2840
Boolean take_action_when_string_present;
2841
GrouP string_constraint_type;
2842
ButtoN case_insensitive;
1818
2845
ValNodePtr bsplist;
1819
2846
ValNodePtr bssplist;
1820
2847
} RemoveFormData, PNTR RemoveFormPtr;
1822
static void LIBCALLBACK AsnWriteRemoveForDCallBack (AsnExpOptStructPtr pAEOS)
1829
rfp = (RemoveFormPtr) pAEOS->data;
1830
if (ISA_STRINGTYPE (AsnFindBaseIsa (pAEOS->atp))) {
1831
pchSource = (CharPtr) pAEOS->dvp->ptrvalue;
1832
pchFind = rfp->findStr;
1833
if (StringSearch (pchSource, pchFind) != NULL) {
1834
rfp->stringfound = TRUE;
1839
static Boolean ObjectHasSubstring (ObjMgrTypePtr omtp, AsnIoPtr aip, Pointer ptr, RemoveFormPtr rfp)
1842
rfp->stringfound = FALSE;
1843
(omtp->asnwrite) (ptr, aip, NULL);
1844
return rfp->stringfound;
1847
static void RemoveFeatureCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 indent)
1854
SeqAnnotPtr nextsap;
1858
Pointer PNTR prevsap;
1859
Pointer PNTR prevsfp;
1860
BioseqPtr productbsp;
1861
BioseqPtr productcdna;
1862
BioseqSetPtr productnps;
1869
if (mydata == NULL) return;
1870
if (sep == NULL || sep->data.ptrvalue == NULL) return;
1871
rfp = (RemoveFormPtr) mydata;
1872
if (rfp == NULL) return;
1874
if (omtp == NULL || omtp->subtypefunc == NULL) return;
1875
if (IS_Bioseq (sep)) {
1876
bsp = (BioseqPtr) sep->data.ptrvalue;
1878
prevsap = (Pointer PNTR) &(bsp->annot);
1879
} else if (IS_Bioseq_set (sep)) {
1880
bssp = (BioseqSetPtr) sep->data.ptrvalue;
1882
prevsap = (Pointer PNTR) &(bssp->annot);
1884
GetTitle (rfp->findthis, rfp->findStr, sizeof (rfp->findStr) - 1);
1885
notext = StringHasNoText (rfp->findStr);
1886
aip = AsnIoNullOpen ();
1887
aeop = AsnExpOptNew (aip, NULL, NULL, AsnWriteRemoveForDCallBack);
1889
aeop->user_data = (Pointer) rfp;
1891
while (sap != NULL) {
1892
nextsap = sap->next;
1893
if (sap->type == 1) {
1894
sfp = (SeqFeatPtr) sap->data;
1895
prevsfp = (Pointer PNTR) &(sap->data);
1896
while (sfp != NULL) {
1897
nextsfp = sfp->next;
1898
subtype = (*(omtp->subtypefunc)) ((Pointer) sfp);
1899
if (subtype == rfp->subtype ||
1900
(rfp->subtype == FEATDEF_IMP &&
1901
subtype >= FEATDEF_allele && subtype <= FEATDEF_site_ref)) {
1902
if (notext || ObjectHasSubstring (omtp, aip, (Pointer) sfp, rfp)) {
1903
if (sfp->data.choice == SEQFEAT_CDREGION) {
1904
if (sfp->product != NULL) {
1905
sip = SeqLocId (sfp->product);
1907
productbsp = BioseqFind (sip);
1908
if (productbsp != NULL) {
1909
ValNodeAddPointer (&(rfp->bsplist), 0, (Pointer) productbsp);
1913
} else if (sfp->data.choice == SEQFEAT_RNA) {
1914
if (sfp->product != NULL) {
1915
sip = SeqLocId (sfp->product);
1917
productcdna = BioseqFind (sip);
1918
if (productcdna != NULL && productcdna->idx.parenttype == OBJ_BIOSEQSET) {
1919
productnps = (BioseqSetPtr) productcdna->idx.parentptr;
1920
if (productnps != NULL && productnps->_class == BioseqseqSet_class_nuc_prot) {
1921
ValNodeAddPointer (&(rfp->bssplist), 0, (Pointer) productnps);
1927
*(prevsfp) = sfp->next;
1931
prevsfp = (Pointer PNTR) &(sfp->next);
1934
prevsfp = (Pointer PNTR) &(sfp->next);
1939
if (sap->data == NULL) {
1940
*(prevsap) = sap->next;
1944
prevsap = (Pointer PNTR) &(sap->next);
1951
static void RemoveDescriptorCallback (SeqEntryPtr sep, Pointer mydata, Int4 index, Int2 indent)
1961
Pointer PNTR prevsdp;
1966
if (mydata == NULL) return;
1967
if (sep == NULL || sep->data.ptrvalue == NULL) return;
1968
rfp = (RemoveFormPtr) mydata;
1969
if (rfp == NULL) return;
1971
if (omtp == NULL || omtp->subtypefunc == NULL) return;
1972
if (IS_Bioseq (sep)) {
1973
bsp = (BioseqPtr) sep->data.ptrvalue;
1975
prevsdp = (Pointer PNTR) &(bsp->descr);
1976
} else if (IS_Bioseq_set (sep)) {
1977
bssp = (BioseqSetPtr) sep->data.ptrvalue;
1979
prevsdp = (Pointer PNTR) &(bssp->descr);
1981
GetTitle (rfp->findthis, rfp->findStr, sizeof (rfp->findStr) - 1);
1982
notext = StringHasNoText (rfp->findStr);
1983
aip = AsnIoNullOpen ();
1984
aeop = AsnExpOptNew (aip, NULL, NULL, AsnWriteRemoveForDCallBack);
1986
aeop->user_data = (Pointer) rfp;
1988
while (sdp != NULL) {
1989
nextsdp = sdp->next;
1990
subtype = (*(omtp->subtypefunc)) ((Pointer) sdp);
1991
if (subtype == rfp->subtype) {
1992
if (notext || ObjectHasSubstring (omtp, aip, (Pointer) sdp, rfp)) {
1993
*(prevsdp) = sdp->next;
1997
prevsdp = (Pointer PNTR) &(sdp->next);
2000
prevsdp = (Pointer PNTR) &(sdp->next);
2849
static Boolean ObjectInRange (SeqFeatPtr sfp, Int4 from, Int4 to)
2852
SeqMgrFeatContext context;
2854
if (sfp == NULL || from < 0 || to < 0) return TRUE;
2855
if (SeqMgrGetDesiredFeature (sfp->idx.entityID, NULL, 0, 0, sfp, &context) == sfp) {
2856
if (context.left > to) return FALSE;
2857
if (context.right < from) return FALSE;
2863
static void RemoveFeatureCallback (SeqFeatPtr sfp, Pointer userdata)
2867
BioseqPtr productbsp, productcdna;
2868
BioseqSetPtr productnps;
2870
if (sfp == NULL || userdata == NULL) return;
2872
rfp = (RemoveFormPtr) userdata;
2873
if (rfp == NULL) return;
2874
if (sfp->idx.subtype == rfp->subtype ||
2875
(rfp->subtype == FEATDEF_IMP && IsRealImpFeat (sfp->idx.subtype)) ||
2876
rfp->subtype == ALL_FEATURES)
2878
if ((rfp->from == -1 && rfp->to == -1) || ObjectInRange (sfp, rfp->from, rfp->to))
2880
if (sfp->data.choice == SEQFEAT_CDREGION)
2882
if (sfp->product != NULL)
2884
sip = SeqLocId (sfp->product);
2887
productbsp = BioseqFind (sip);
2888
if (productbsp != NULL)
2890
ValNodeAddPointer (&(rfp->bsplist), 0, (Pointer) productbsp);
2895
else if (sfp->data.choice == SEQFEAT_RNA)
2897
if (sfp->product != NULL)
2899
sip = SeqLocId (sfp->product);
2902
productcdna = BioseqFind (sip);
2903
if (productcdna != NULL && productcdna->idx.parenttype == OBJ_BIOSEQSET)
2905
productnps = (BioseqSetPtr) productcdna->idx.parentptr;
2906
if (productnps != NULL && productnps->_class == BioseqseqSet_class_nuc_prot)
2908
ValNodeAddPointer (&(rfp->bssplist), 0, (Pointer) productnps);
2914
sfp->idx.deleteme = TRUE;
2919
static void RemoveFeatures (SeqEntryPtr sep, RemoveFormPtr rfp)
2921
FeaturesWithTextData fd;
2926
GetTitle (rfp->findthis, rfp->findStr, sizeof (rfp->findStr) - 1);
2927
fd.search_text = rfp->findStr;
2928
fd.no_text = StringHasNoText (rfp->findStr);
2929
fd.seqFeatChoice = 0;
2930
fd.featDefChoice = 0;
2931
fd.case_insensitive = GetStatus (rfp->case_insensitive);
2932
fd.act_when_string_not_present = ! rfp->take_action_when_string_present;
2934
fd.callback = RemoveFeatureCallback;
2935
GetTitle (rfp->fromTxt, str, sizeof (str) - 1);
2936
if ((! StringHasNoText (str)) && sscanf (str, "%ld", &val) == 1 && val >= 0) {
2937
rfp->from = (Int4) val;
2941
GetTitle (rfp->toTxt, str, sizeof (str) - 1);
2942
if ((! StringHasNoText (str)) && sscanf (str, "%ld", &val) == 1 && val >= 0) {
2943
rfp->to = (Int4) val;
2947
if (rfp->from > rfp->to) {
2949
rfp->from = rfp->to;
2952
OperateOnSeqEntryFeaturesWithText (sep, &fd);
2953
DeleteMarkedObjects (rfp->input_entityID, OBJ_SEQENTRY, (Pointer) sep);
2956
static void RemoveDescriptorCallback (SeqDescrPtr sdp, Pointer userdata)
2961
if (sdp == NULL || userdata == NULL || sdp->extended == 0) return;
2962
rfp = (RemoveFormPtr) userdata;
2963
if (rfp == NULL) return;
2965
ovp = (ObjValNodePtr) sdp;
2967
if (sdp->choice == rfp->subtype)
2969
ovp->idx.deleteme = TRUE;
2973
static void RemoveDescriptors (SeqEntryPtr sep, RemoveFormPtr rfp)
2975
DescriptorsWithTextData dd;
2980
GetTitle (rfp->findthis, rfp->findStr, sizeof (rfp->findStr) - 1);
2981
dd.search_text = rfp->findStr;
2982
dd.no_text = StringHasNoText (rfp->findStr);
2983
dd.case_insensitive = GetStatus (rfp->case_insensitive);
2984
dd.act_when_string_not_present = ! rfp->take_action_when_string_present;
2986
dd.callback = RemoveDescriptorCallback;
2987
GetTitle (rfp->fromTxt, str, sizeof (str) - 1);
2988
if ((! StringHasNoText (str)) && sscanf (str, "%ld", &val) == 1 && val >= 0) {
2989
rfp->from = (Int4) val;
2993
GetTitle (rfp->toTxt, str, sizeof (str) - 1);
2994
if ((! StringHasNoText (str)) && sscanf (str, "%ld", &val) == 1 && val >= 0) {
2995
rfp->to = (Int4) val;
2999
if (rfp->from > rfp->to) {
3001
rfp->from = rfp->to;
3004
OperateOnSeqEntryDescriptorsWithText (sep, &dd);
3005
DeleteMarkedObjects (rfp->input_entityID, OBJ_SEQENTRY, (Pointer) sep);
2007
3008
static void DoRemoveAsnObject (ButtoN b)
4941
static void FinishAutoDefProc (Uint2 entityID, SeqEntryPtr sep,
4942
ValNodePtr head, BioseqPtr target,
4943
SeqEntryPtr nsep, MolInfoPtr mip,
4944
ValNodePtr strings, BioSourcePtr biop,
4945
Int2 mitochloroflag)
7383
/*---------------------------------------------------------------------*/
7385
/* AutoDef_AddProtein () -- Add a protein feature to a defline. */
7387
/*---------------------------------------------------------------------*/
7389
static void AutoDef_AddProtein (DefFeatsPtr dfp,
7397
/* If we're suppressing the prefix then */
7398
/* skip all the rest. */
7400
if (dfp->suppressprefix) {
7402
if (dfp->sfp->partial)
7403
StringCat (str, "partial cds");
7405
StringCat (str, "complete cds");
7407
if (dfp->altSplices > 1)
7408
StringCat (str, ", alternatively spliced");
7413
/* If we have no protein name, we're done */
7415
if (dfp->protname == NULL)
7418
/* Add the protein name and, if there */
7419
/* is one, the gene name. */
7421
if (StringICmp (dfp->protname, "unknown") == 0 &&
7422
!(StringHasNoText (dfp->genename))) {
7423
StringNCpy_0 (text, dfp->genename, DEFLINE_MAX_GENENAME_LEN);
7424
StringCat (str, text);
7427
StringNCpy_0 (str, dfp->protname, DEFLINE_MAX_LEN - 100);
7428
if (dfp->genename != NULL) {
7429
StringNCpy_0 (text, dfp->genename, DEFLINE_MAX_GENENAME_LEN);
7430
if (! StringHasNoText (text)) {
7431
StringCat (str, " (");
7432
StringCat (str, text);
7433
StringCat (str, ")");
7438
if (dfp->lastInGroup || dfp->lastInType) {
7441
ptr = StringISearch (str, "precursor");
7442
if (ptr != NULL && StringICmp (ptr, "precursor") == 0) {
7443
StringCat (str, ",");
7445
if (mip->biomol == MOLECULE_TYPE_MRNA) {
7446
StringCat (str, " mRNA");
7447
} else if (mip->biomol == MOLECULE_TYPE_PRE_MRNA) {
7448
StringCat (str, " precursor RNA");
7450
StringCat (str, " gene");
7455
StringCat (str, "s");
7456
else if (! StringHasNoText (dfp->allelename)) {
7457
StringNCpy_0 (text, dfp->allelename, TEXT_MAX_LEN);
7458
StringCat (str, ", ");
7459
StringCat (str, text);
7460
StringCat (str, " allele");
7463
if (!dfp->isAlleleGroup)
7465
if (dfp->sfp->partial)
7466
StringCat (str, ", partial cds");
7468
StringCat (str, ", complete cds");
7471
if (dfp->altSplices > 1)
7472
StringCat (str, ", alternatively spliced");
7478
/*---------------------------------------------------------------------*/
7480
/* AutoDef_AddGene () -- Add a Gene feature to a defline. */
7482
/*---------------------------------------------------------------------*/
7484
static void AutoDef_AddGene (DefFeatsPtr dfp,
7490
if (dfp->genename != NULL)
7491
StringNCpy_0 (str, dfp->genename, DEFLINE_MAX_GENENAME_LEN);
7492
if (dfp->lastInGroup || dfp->lastInType) {
7494
if (mip->biomol == MOLECULE_TYPE_MRNA)
7495
StringCat (str, " mRNA");
7496
else if (mip->biomol == MOLECULE_TYPE_PRE_MRNA)
7497
StringCat (str, " precursor RNA");
7499
StringCat (str, " gene");
7502
StringCat (str, " gene");
7504
StringCat (str, "s");
7505
if (featNum < 2 && (! StringHasNoText (dfp->allelename))) {
7506
StringNCpy_0 (text, dfp->allelename, TEXT_MAX_LEN);
7507
StringCat (str, ", ");
7508
StringCat (str, text);
7509
StringCat (str, " allele");
7511
if (dfp->sfp->partial)
7512
StringCat (str, ", partial sequence");
7514
StringCat (str, ", complete sequence");
7518
/*---------------------------------------------------------------------*/
7520
/* AutoDef_AddRRNAandOtherRNA () -- Add an rRNA or other RNA feature */
7523
/*---------------------------------------------------------------------*/
7525
static void AutoDef_AddRRNAandOtherRNA (DefFeatsPtr dfp,
7534
rrp = (RnaRefPtr) dfp->sfp->data.value.ptrvalue;
7536
if (rrp->ext.choice == 1) {
7537
StringNCpy_0 (str, (CharPtr) rrp->ext.value.ptrvalue,
7538
DEFLINE_MAX_LEN - 50);
7539
if (dfp->subtype == FEATDEF_rRNA) {
7540
ptr = StringISearch (str, " rRNA");
7543
ptr = StringISearch (str, " ribosomal RNA");
7546
if (! StringHasNoText (str))
7547
StringCat (str, " ribosomal RNA");
7549
else if (dfp->subtype == FEATDEF_otherRNA) {
7551
if (dfp->genename != NULL) {
7552
StringNCpy_0 (text, dfp->genename, DEFLINE_MAX_GENENAME_LEN);
7553
if (! StringHasNoText (text)) {
7554
StringCat (str, " (");
7555
StringCat (str, text);
7556
StringCat (str, ")");
7559
if (dfp->lastInString || dfp->lastInGroup || dfp->lastInType) {
7560
if (dfp->subtype == FEATDEF_rRNA &&
7561
mip->biomol == MOLECULE_TYPE_GENOMIC) {
7562
StringCat (str, " gene");
7564
StringCat (str, "s");
7567
if (dfp->lastInGroup || dfp->lastInType) {
7568
if (dfp->sfp->partial)
7569
StringCat (str, ", partial sequence");
7571
StringCat (str, ", complete sequence");
7577
/*---------------------------------------------------------------------*/
7579
/* AutoDef_AddtRNA () -- Add a tRNA feature to a defline. */
7581
/*---------------------------------------------------------------------*/
7583
static void AutoDef_AddtRNA (DefFeatsPtr dfp,
7591
rrp = (RnaRefPtr) dfp->sfp->data.value.ptrvalue;
7593
if (rrp->ext.choice == 2) {
7594
trna = rrp->ext.value.ptrvalue;
7596
if (FeatDefLabel (dfp->sfp, str, DEFLINE_MAX_LEN - 2,
7597
OM_LABEL_CONTENT) > 0) {
7598
if (dfp->genename != NULL) {
7599
StringNCpy_0 (text, dfp->genename,
7600
DEFLINE_MAX_GENENAME_LEN);
7601
if (! StringHasNoText (text)) {
7602
StringCat (str, " (");
7603
StringCat (str, text);
7604
StringCat (str, ")");
7607
if (dfp->lastInGroup || dfp->lastInType) {
7608
StringCat (str, " gene");
7610
StringCat (str, "s");
7611
if (dfp->sfp->partial)
7612
StringCat (str, ", partial sequence");
7614
StringCat (str, ", complete sequence");
7622
/*---------------------------------------------------------------------*/
7624
/* AutoDef_AddsnRNA () -- Add a snRNA feature to a defline. */
7626
/*---------------------------------------------------------------------*/
7628
static void AutoDef_AddsnRNA (DefFeatsPtr dfp,
7636
rrp = (RnaRefPtr) dfp->sfp->data.value.ptrvalue;
7638
if (rrp->ext.choice == 1) {
7639
StringNCpy_0 (str, (CharPtr) rrp->ext.value.ptrvalue, DEFLINE_MAX_LEN);
7640
if (! StringHasNoText (str)) {
7641
if (dfp->genename != NULL) {
7642
StringNCpy_0 (text, dfp->genename,
7643
DEFLINE_MAX_GENENAME_LEN);
7644
if (! StringHasNoText (text)) {
7645
StringCat (str, " (");
7646
StringCat (str, text);
7647
StringCat (str, ")");
7650
if (dfp->lastInGroup || dfp->lastInType) {
7651
if (mip == NULL || mip->biomol != MOLECULE_TYPE_SNRNA) {
7652
StringCat (str, " gene");
7654
StringCat (str, "s");
7656
if (dfp->sfp->partial)
7657
StringCat (str, ", partial sequence");
7659
StringCat (str, ", complete sequence");
7666
/*---------------------------------------------------------------------*/
7668
/* AutoDef_AddsnoRNA () -- Add a snoRNA feature to a defline. */
7670
/*---------------------------------------------------------------------*/
7672
static void AutoDef_AddsnoRNA (DefFeatsPtr dfp,
7680
rrp = (RnaRefPtr) dfp->sfp->data.value.ptrvalue;
7682
if (rrp->ext.choice == 1) {
7683
StringNCpy_0 (str, (CharPtr) rrp->ext.value.ptrvalue, DEFLINE_MAX_LEN);
7684
if (! StringHasNoText (str)) {
7685
if (dfp->genename != NULL) {
7686
StringNCpy_0 (text, dfp->genename,
7687
DEFLINE_MAX_GENENAME_LEN);
7688
if (! StringHasNoText (text)) {
7689
StringCat (str, " (");
7690
StringCat (str, text);
7691
StringCat (str, ")");
7694
if (dfp->lastInGroup || dfp->lastInType) {
7695
if (mip == NULL || mip->biomol != MOLECULE_TYPE_SNORNA) {
7696
StringCat (str, " gene");
7698
StringCat (str, "s");
7700
if (dfp->sfp->partial)
7701
StringCat (str, ", partial sequence");
7703
StringCat (str, ", complete sequence");
7710
/*---------------------------------------------------------------------*/
7712
/* AutoDef_AddmRNA () -- Add an mRNA feature to a defline. */
7714
/*---------------------------------------------------------------------*/
7716
static void AutoDef_AddmRNA (DefFeatsPtr dfp,
7724
StringNCpy_0 (str, dfp->genename, DEFLINE_MAX_GENENAME_LEN);
7725
if (dfp->lastInGroup || dfp->lastInType) {
7727
ptr = StringISearch (str, "precursor");
7728
if (ptr != NULL && StringICmp (ptr, "precursor") == 0)
7729
StringCat (str, ",");
7730
if (mip->biomol == MOLECULE_TYPE_MRNA)
7731
StringCat (str, " mRNA");
7732
else if (mip->biomol == MOLECULE_TYPE_PRE_MRNA)
7733
StringCat (str, " precursor RNA");
7735
StringCat (str, " gene");
7738
StringCat (str, "s");
7739
if (featNum < 2 && (! StringHasNoText (dfp->allelename))) {
7740
StringNCpy_0 (text, dfp->allelename, TEXT_MAX_LEN);
7741
StringCat (str, ", ");
7742
StringCat (str, text);
7743
StringCat (str, " allele");
7745
if (dfp->sfp->partial)
7746
StringCat (str, ", partial cds");
7748
StringCat (str, ", complete cds");
7752
/*---------------------------------------------------------------------*/
7754
/* AutoDef_AddPseudoGene () -- Add a pseudogene feature to a defline. */
7756
/*---------------------------------------------------------------------*/
7758
static void AutoDef_AddPseudoGene (DefFeatsPtr dfp,
7763
if (dfp->genename != NULL)
7764
StringNCpy_0 (str, dfp->genename, DEFLINE_MAX_GENENAME_LEN);
7766
if (dfp->lastInGroup || dfp->lastInType) {
7767
StringCat (str, " pseudogene");
7769
StringCat (str, "s");
7771
if (featNum < 2 && (! StringHasNoText (dfp->allelename))) {
7772
StringNCpy_0 (text, dfp->allelename, TEXT_MAX_LEN);
7773
StringCat (str, ", ");
7774
StringCat (str, text);
7775
StringCat (str, " allele");
7777
if (dfp->sfp->partial) {
7778
StringCat (str, ", partial sequence");
7780
StringCat (str, ", complete sequence");
7785
/*---------------------------------------------------------------------*/
7787
/* AutoDef_AddUnknown () -- Add an unknown feature to a defline. */
7789
/*---------------------------------------------------------------------*/
7791
static void AutoDef_AddUnknown (DefFeatsPtr dfp,
7795
if (mip != NULL && mip->biomol == MOLECULE_TYPE_MRNA)
7796
StringCat (str, "unknown mRNA");
7797
else if (mip->biomol == MOLECULE_TYPE_PRE_MRNA)
7798
StringCat (str, " unknown precursor RNA");
7800
StringCat (str, "unknown gene");
7801
if (dfp->numUnknown > 1) {
7802
StringCat (str, "s");
7806
/*---------------------------------------------------------------------*/
7808
/* AutoDef_AddLTR () -- Add a Long Terminal Repeat feature to */
7811
/*---------------------------------------------------------------------*/
7813
static void AutoDef_AddLTR (DefFeatsPtr dfp,
7819
if (! StringHasNoText (sfp->comment)) {
7820
StringNCpy_0 (str, sfp->comment, DEFLINE_MAX_LEN);
7821
ptr = StringISearch (str, " long terminal repeat");
7824
ptr = StringISearch (str, " long terminal repeat");
7827
if (! StringHasNoText (str))
7828
StringCat (str, " long terminal repeat");
7831
StringCpy (str, "long terminal repeat");
7833
if (dfp->lastInGroup || dfp->lastInType) {
7834
if (dfp->sfp->partial)
7835
StringCat (str, ", partial sequence");
7837
StringCat (str, ", complete sequence");
7841
/*---------------------------------------------------------------------*/
7843
/* AutoDef_AddExon () -- Add an exon feature to a defline. */
7845
/*---------------------------------------------------------------------*/
7847
static void AutoDef_AddExon (DefFeatsPtr dfp,
7856
/* If there is a protein name then use it*/
7858
if (dfp->protname != NULL) {
7861
/* Add the protein name and, if there */
7862
/* is one, the gene name. */
7864
if (! dfp->suppressprefix) {
7865
StringNCpy_0 (str, dfp->protname, DEFLINE_MAX_LEN - 100);
7866
if (dfp->genename != NULL) {
7867
StringNCpy_0 (text, dfp->genename, DEFLINE_MAX_GENENAME_LEN);
7868
if (! StringHasNoText (text)) {
7869
StringCat (str, " (");
7870
StringCat (str, text);
7871
StringCat (str, ") gene,");
7872
if (! StringHasNoText (dfp->allelename)) {
7873
StringNCpy_0 (text, dfp->allelename, TEXT_MAX_LEN);
7874
StringCat (str, " ");
7875
StringCat (str, text);
7876
StringCat (str, " allele,");
7880
else if (MOLECULE_TYPE_GENOMIC == mip->biomol)
7881
StringCat (str, " gene,");
7884
/* Add the exon number */
7886
if ((! StringHasNoText (str)) || dfp->suppressprefix) {
7887
exonnumber = GetExonNumber (sfp->qual);
7888
if (! dfp->suppressprefix) {
7889
if (exonnumber == NULL) {
7890
if (StringStr (sfp->comment, "exon") != NULL &&
7891
(! NextIsExon (vnp))) {
7893
StringCat (str, " exon");
7894
if (NextIsExon (vnp)) {
7895
StringCat (str, "s");
7899
StringCat (str, " exon");
7900
if (NextIsExon (vnp)) {
7901
StringCat (str, "s");
7905
if (exonnumber != NULL) {
7906
if (! dfp->suppressprefix) {
7907
StringCat (str, " ");
7909
StringCat (str, exonnumber);
7911
if (! StringHasNoText (sfp->comment)) {
7912
if (! dfp->suppressprefix) {
7913
StringCat (str, " ");
7915
StringCat (str, sfp->comment);
7921
/* Else use the gene name if there is one */
7923
else if (dfp->genename != NULL) {
7926
/* Add the gene name */
7928
if (! dfp->suppressprefix) {
7929
StringNCpy_0 (str, dfp->genename, DEFLINE_MAX_GENENAME_LEN);
7930
StringCat (str, " gene,");
7933
/* Add the exon number */
7935
if ((! StringHasNoText (str)) || dfp->suppressprefix) {
7936
exonnumber = GetExonNumber (sfp->qual);
7937
if (! dfp->suppressprefix) {
7938
if (exonnumber == NULL) {
7939
if (StringStr (sfp->comment, "exon") != NULL &&
7940
(! NextIsExon (vnp))) {
7942
StringCat (str, " exon");
7943
if (NextIsExon (vnp)) {
7944
StringCat (str, "s");
7948
StringCat (str, " exon");
7949
if (NextIsExon (vnp)) {
7950
StringCat (str, "s");
7954
if (exonnumber != NULL) {
7955
if (! dfp->suppressprefix) {
7956
StringCat (str, " ");
7958
StringCat (str, exonnumber);
7960
if (! StringHasNoText (sfp->comment)) {
7961
if (! dfp->suppressprefix) {
7962
StringCat (str, " ");
7964
StringCat (str, sfp->comment);
7970
/* Otherwise, label it as uncharacterized */
7973
StringCpy (str, "uncharacterized exon");
7977
/*---------------------------------------------------------------------*/
7979
/* AutoDef_AddSeparator () -- Add a separator before two features. */
7981
/*---------------------------------------------------------------------*/
7983
static void AutoDef_AddSeparator (DefFeatsPtr dfp,
7988
DefFeatsPtr nextdfp;
7990
nextdfp = (DefFeatsPtr) vnp->data.ptrvalue;
7991
if (dfp->lastInPenultimate) {
7992
if ((dfp->subtype == FEATDEF_rRNA &&
7993
nextdfp->subtype == FEATDEF_otherRNA &&
7994
dfp->sfp->partial == nextdfp->sfp->partial) ||
7995
(dfp->subtype == FEATDEF_otherRNA &&
7996
nextdfp->subtype == FEATDEF_rRNA &&
7997
dfp->sfp->partial == nextdfp->sfp->partial))
7998
StringCat (str, ", and");
7999
else if (dfp->subtype == FEATDEF_exon &&
8000
nextdfp->subtype == FEATDEF_exon)
8001
StringCat (str, ",");
8003
StringCat (str, "; and");
8005
else if (dfp->lastInType || dfp->lastInGroup)
8006
StringCat (str, ";");
8007
else if (nextdfp->lastInType || nextdfp->lastInGroup) {
8009
StringCat (str, ", and");
8011
StringCat (str, " and");
8014
StringCat (str, ",");
8016
/*---------------------------------------------------------------------*/
8018
/* AutoDef_AddPenultSeparator () -- Add a separator before the last */
8021
/*---------------------------------------------------------------------*/
8023
static void AutoDef_AddPenultSeparator (DefFeatsPtr dfp,
8028
DefFeatsPtr nextdfp;
8030
nextdfp = (DefFeatsPtr) vnp->data.ptrvalue;
8031
if (dfp->lastInPenultimate) {
8032
if ((dfp->subtype == FEATDEF_rRNA &&
8033
nextdfp->subtype == FEATDEF_otherRNA &&
8034
dfp->sfp->partial == nextdfp->sfp->partial) ||
8035
(dfp->subtype == FEATDEF_otherRNA &&
8036
nextdfp->subtype == FEATDEF_rRNA &&
8037
dfp->sfp->partial == nextdfp->sfp->partial))
8038
StringCat (str, ", and");
8039
else if (dfp->subtype == FEATDEF_exon &&
8040
nextdfp->subtype == FEATDEF_exon)
8041
StringCat (str, " and");
8043
StringCat (str, "; and");
8045
else if (dfp->lastInType || dfp->lastInGroup) {
8047
StringCat (str, ", and");
8049
StringCat (str, " and");
8051
else if (nextdfp->lastInType || nextdfp->lastInGroup) {
8053
StringCat (str, ", and");
8055
StringCat (str, " and");
8059
StringCat (str, ", and");
8061
StringCat (str, " and");
8065
/*---------------------------------------------------------------------*/
8067
/* AutoDef_AddEnding () -- Add an ending on to the definition line */
8068
/* after the last feature. */
8070
/*---------------------------------------------------------------------*/
8072
static void AutoDef_AddEnding (CharPtr str,
8075
Int2 mitochloroflag)
8080
orgnelle [0] = '\0';
8081
switch (biop->genome) {
8082
case GENOME_apicoplast :
8083
case GENOME_chloroplast :
8084
case GENOME_chromoplast :
8085
case GENOME_kinetoplast :
8086
case GENOME_mitochondrion :
8087
case GENOME_plastid :
8088
case GENOME_cyanelle :
8089
case GENOME_leucoplast :
8090
case GENOME_proplastid :
8092
sprintf (orgnelle, "; %s genes for %s products",
8093
organelleByGenome [biop->genome],
8094
organelleByGenome [biop->genome]);
8096
sprintf (orgnelle, "; %s gene for %s product",
8097
organelleByGenome [biop->genome],
8098
organelleByGenome [biop->genome]);
8099
StringCat (str, orgnelle);
8102
if (mitochloroflag > 0) {
8103
if (mitochloroflag > 10) {
8106
else if (mitochloroflag == 10)
8107
StringCat (str, "; alternatively spliced");
8110
sprintf (orgnelle, "; nuclear genes for %s products",
8111
organelleByPopup [mitochloroflag]);
8113
sprintf (orgnelle, "; nuclear gene for %s product",
8114
organelleByPopup [mitochloroflag]);
8115
StringCat (str, orgnelle);
8121
StringCat (str, ".");
8124
/*---------------------------------------------------------------------*/
8126
/* FinishAutoDefProc () -- Finish the automatic generation of a */
8127
/* definition line that was started in */
8128
/* AutoDefProc (). */
8130
/*---------------------------------------------------------------------*/
8132
static void FinishAutoDefProc (Uint2 entityID,
8140
Int2 mitochloroflag)
4949
8144
Boolean ddbjstyle = FALSE;
4950
8145
DefFeatsPtr dfp;
4952
8146
Int2 mitocount;
4953
DefFeatsPtr nextdfp;
4956
8148
SeqFeatPtr sfp;
8149
Char str [DEFLINE_MAX_LEN];
4959
8150
ValNodePtr ttl;
8151
Char text [TEXT_MAX_LEN];
4962
8152
ValNodePtr vnp;
4964
if (GetAppParam ("SEQUIN", "PREFERENCES", "DATABASE", NULL, str, sizeof (str))) {
4965
if (StringICmp (str, "DDBJ") == 0) {
8154
/* Check configuration parameters to */
8155
/* see if we are using DDBJ style. */
8157
if (GetAppParam ("SEQUIN", "PREFERENCES", "DATABASE", NULL,
8158
str, DEFLINE_MAX_LEN)) {
8159
if (StringICmp (str, "DDBJ") == 0)
4966
8160
ddbjstyle = TRUE;
8163
/* Loop through all the features, building a */
8164
/* defline from the info gathered on them. */
4972
8169
while (vnp != NULL) {
4973
8170
str [0] = '\0';
4974
8171
dfp = (DefFeatsPtr) vnp->data.ptrvalue;
8173
/* Create a string for the feature */
4975
8175
if (dfp != NULL) {
4976
8176
sfp = dfp->sfp;
4977
8177
if (sfp != NULL || dfp->numUnknown > 0) {
4980
/* FindGeneAndProtForCDS (entityID, sfp, &(dfp->gene), &(dfp->prot)); */
4981
/* StringCpy (str, "unknown"); */
4982
8180
text [0] = '\0';
4983
if (dfp->subtype == FEATDEF_CDS && dfp->prot != NULL) {
4984
if (dfp->suppressprefix) {
4986
if (dfp->sfp->partial) {
4987
StringCat (str, "partial cds");
4989
StringCat (str, "complete cds");
4991
if (dfp->altSplices > 1) {
4992
StringCat (str, ", alternatively spliced");
4994
} else if (dfp->protname != NULL) {
4995
if (StringICmp (dfp->protname, "unknown") == 0 && (! StringHasNoText (dfp->genename))) {
4996
StringNCpy_0 (text, dfp->genename, sizeof (text));
4997
/* StringCat (str, "("); */
4998
StringCat (str, text);
4999
/* StringCat (str, ")"); */
5001
StringNCpy_0 (str, dfp->protname, sizeof (str) - 100);
5002
if (dfp->genename != NULL) {
5003
StringNCpy_0 (text, dfp->genename, sizeof (text));
5004
if (! StringHasNoText (text)) {
5005
StringCat (str, " (");
5006
StringCat (str, text);
5007
StringCat (str, ")");
5011
if (dfp->lastInGroup || dfp->lastInType) {
5013
ptr = StringISearch (str, "precursor");
5014
if (ptr != NULL && StringICmp (ptr, "precursor") == 0) {
5015
StringCat (str, ",");
5017
if (mip->biomol == MOLECULE_TYPE_MRNA) {
5018
StringCat (str, " mRNA");
5019
} else if (mip->biomol == MOLECULE_TYPE_PRE_MRNA) {
5020
StringCat (str, " precursor RNA");
5022
StringCat (str, " gene");
5026
StringCat (str, "s");
5028
if (count < 2 && /* dfp->altSplices < 2 && */ (! StringHasNoText (dfp->allelename))) {
5029
StringNCpy_0 (text, dfp->allelename, sizeof (text));
5030
StringCat (str, ", ");
5031
StringCat (str, text);
5032
StringCat (str, " allele");
5034
if (dfp->sfp->partial) {
5035
StringCat (str, ", partial cds");
5037
StringCat (str, ", complete cds");
5039
if (dfp->altSplices > 1) {
5040
StringCat (str, ", alternatively spliced");
5044
} else if (dfp->subtype == FEATDEF_CDS && dfp->pseudo) {
5045
if (dfp->genename != NULL) {
5046
StringNCpy_0 (str, dfp->genename, sizeof (str) - 50);
5048
if (dfp->lastInGroup || dfp->lastInType) {
5049
StringCat (str, " pseudogene");
5051
StringCat (str, "s");
5053
if (count < 2 && (! StringHasNoText (dfp->allelename))) {
5054
StringNCpy_0 (text, dfp->allelename, sizeof (text));
5055
StringCat (str, ", ");
5056
StringCat (str, text);
5057
StringCat (str, " allele");
5059
if (dfp->sfp->partial) {
5060
StringCat (str, ", partial sequence");
5062
StringCat (str, ", complete sequence");
5065
} else if (dfp->subtype == FEATDEF_CDS && dfp->prot == NULL && dfp->genename != NULL) {
5066
StringNCpy_0 (str, dfp->genename, sizeof (str) - 50);
5067
if (dfp->lastInGroup || dfp->lastInType) {
5069
ptr = StringISearch (str, "precursor");
5070
if (ptr != NULL && StringICmp (ptr, "precursor") == 0) {
5071
StringCat (str, ",");
5073
if (mip->biomol == MOLECULE_TYPE_MRNA) {
5074
StringCat (str, " mRNA");
5075
} else if (mip->biomol == MOLECULE_TYPE_PRE_MRNA) {
5076
StringCat (str, " precursor RNA");
5078
StringCat (str, " gene");
5082
StringCat (str, "s");
5084
if (count < 2 && (! StringHasNoText (dfp->allelename))) {
5085
StringNCpy_0 (text, dfp->allelename, sizeof (text));
5086
StringCat (str, ", ");
5087
StringCat (str, text);
5088
StringCat (str, " allele");
5090
if (dfp->sfp->partial) {
5091
StringCat (str, ", partial cds");
5093
StringCat (str, ", complete cds");
5096
} else if (dfp->subtype == FEATDEF_GENE) {
5097
if (dfp->genename != NULL) {
5098
StringNCpy_0 (str, dfp->genename, sizeof (str) - 50);
5100
if (dfp->lastInGroup || dfp->lastInType) {
5102
if (mip->biomol == MOLECULE_TYPE_MRNA) {
5103
StringCat (str, " mRNA");
5104
} else if (mip->biomol == MOLECULE_TYPE_PRE_MRNA) {
5105
StringCat (str, " precursor RNA");
5107
StringCat (str, " gene");
5110
StringCat (str, " gene");
5113
StringCat (str, "s");
5115
if (count < 2 && (! StringHasNoText (dfp->allelename))) {
5116
StringNCpy_0 (text, dfp->allelename, sizeof (text));
5117
StringCat (str, ", ");
5118
StringCat (str, text);
5119
StringCat (str, " allele");
5121
if (dfp->sfp->partial) {
5122
StringCat (str, ", partial sequence");
5124
StringCat (str, ", complete sequence");
5127
} else if (dfp->subtype == FEATDEF_rRNA || dfp->subtype == FEATDEF_otherRNA) {
5128
rrp = (RnaRefPtr) dfp->sfp->data.value.ptrvalue;
5130
if (rrp->ext.choice == 1) {
5131
StringNCpy_0 (str, (CharPtr) rrp->ext.value.ptrvalue, sizeof (str) - 50);
5132
if (dfp->subtype == FEATDEF_rRNA) {
5133
ptr = StringISearch (str, " rRNA");
5137
ptr = StringISearch (str, " ribosomal RNA");
5141
if (! StringHasNoText (str)) {
5142
StringCat (str, " ribosomal RNA");
5144
} else if (dfp->subtype == FEATDEF_otherRNA) {
5146
if (dfp->genename != NULL) {
5147
StringNCpy_0 (text, dfp->genename, sizeof (text));
5148
if (! StringHasNoText (text)) {
5149
StringCat (str, " (");
5150
StringCat (str, text);
5151
StringCat (str, ")");
5154
if (dfp->lastInString || dfp->lastInGroup || dfp->lastInType) {
5155
if (dfp->subtype == FEATDEF_rRNA && mip->biomol == MOLECULE_TYPE_GENOMIC) {
5156
StringCat (str, " gene");
5158
StringCat (str, "s");
5162
if (dfp->lastInGroup || dfp->lastInType) {
5163
if (dfp->sfp->partial) {
5164
StringCat (str, ", partial sequence");
5166
StringCat (str, ", complete sequence");
5171
} else if (dfp->subtype == FEATDEF_tRNA) {
5172
rrp = (RnaRefPtr) dfp->sfp->data.value.ptrvalue;
5174
if (rrp->ext.choice == 2) {
5175
trna = rrp->ext.value.ptrvalue;
5177
if (FeatDefLabel (dfp->sfp, str, sizeof (str) - 2, OM_LABEL_CONTENT) > 0) {
5178
if (dfp->genename != NULL) {
5179
StringNCpy_0 (text, dfp->genename, sizeof (text));
5180
if (! StringHasNoText (text)) {
5181
StringCat (str, " (");
5182
StringCat (str, text);
5183
StringCat (str, ")");
5186
if (dfp->lastInGroup || dfp->lastInType) {
5187
StringCat (str, " gene");
5189
StringCat (str, "s");
5191
if (dfp->sfp->partial) {
5192
StringCat (str, ", partial sequence");
5194
StringCat (str, ", complete sequence");
5201
} else if (dfp->subtype == FEATDEF_LTR) {
5202
if (! StringHasNoText (sfp->comment)) {
5203
StringNCpy_0 (str, sfp->comment, sizeof (str));
5204
ptr = StringISearch (str, " long terminal repeat");
5208
ptr = StringISearch (str, " long terminal repeat");
5212
if (! StringHasNoText (str)) {
5213
StringCat (str, " long terminal repeat");
5216
/* StringCpy (str, "uncharacterized"); */
5217
StringCpy (str, "long terminal repeat");
5219
if (dfp->lastInGroup || dfp->lastInType) {
5220
if (dfp->sfp->partial) {
5221
StringCat (str, ", partial sequence");
5223
StringCat (str, ", complete sequence");
5226
} else if (dfp->subtype == FEATDEF_exon && target != NULL) {
5227
if (dfp->protname != NULL) {
5229
if (! dfp->suppressprefix) {
5230
StringNCpy_0 (str, dfp->protname, sizeof (str) - 100);
5231
if (dfp->genename != NULL) {
5232
StringNCpy_0 (text, dfp->genename, sizeof (text));
5233
if (! StringHasNoText (text)) {
5234
StringCat (str, " (");
5235
StringCat (str, text);
5236
StringCat (str, ") gene,");
5237
if (/* count < 2 && */ /* dfp->altSplices < 2 && */ (! StringHasNoText (dfp->allelename))) {
5238
StringNCpy_0 (text, dfp->allelename, sizeof (text));
5239
StringCat (str, " ");
5240
StringCat (str, text);
5241
StringCat (str, " allele,");
5246
if ((! StringHasNoText (str)) || dfp->suppressprefix) {
5247
exonnumber = GetExonNumber (sfp->qual);
5248
if (! dfp->suppressprefix) {
5249
if (exonnumber == NULL) {
5250
if (StringStr (sfp->comment, "exon") != NULL && (! NextIsExon (vnp))) {
5252
StringCat (str, " exon");
5253
if (NextIsExon (vnp)) {
5254
StringCat (str, "s");
5258
StringCat (str, " exon");
5259
if (NextIsExon (vnp)) {
5260
StringCat (str, "s");
5264
if (exonnumber != NULL) {
5265
if (! dfp->suppressprefix) {
5266
StringCat (str, " ");
5268
StringCat (str, exonnumber);
5270
if (! StringHasNoText (sfp->comment)) {
5271
if (! dfp->suppressprefix) {
5272
StringCat (str, " ");
5274
StringCat (str, sfp->comment);
5278
} else if (dfp->genename != NULL) {
5280
if (! dfp->suppressprefix) {
5281
StringNCpy_0 (str, dfp->genename, sizeof (str));
5282
StringCat (str, " gene,");
5284
if ((! StringHasNoText (str)) || dfp->suppressprefix) {
5285
exonnumber = GetExonNumber (sfp->qual);
5286
if (! dfp->suppressprefix) {
5287
if (exonnumber == NULL) {
5288
if (StringStr (sfp->comment, "exon") != NULL && (! NextIsExon (vnp))) {
5290
StringCat (str, " exon");
5291
if (NextIsExon (vnp)) {
5292
StringCat (str, "s");
5296
StringCat (str, " exon");
5297
if (NextIsExon (vnp)) {
5298
StringCat (str, "s");
5302
if (exonnumber != NULL) {
5303
if (! dfp->suppressprefix) {
5304
StringCat (str, " ");
5306
StringCat (str, exonnumber);
5308
if (! StringHasNoText (sfp->comment)) {
5309
if (! dfp->suppressprefix) {
5310
StringCat (str, " ");
5312
StringCat (str, sfp->comment);
5317
StringCpy (str, "uncharacterized exon");
5320
if (dfp->lastInGroup || dfp->lastInType) {
5321
if (dfp->sfp->partial) {
5322
StringCat (str, ", partial sequence");
5324
StringCat (str, ", complete sequence");
5328
} else if (dfp->numUnknown > 0) {
5329
if (mip != NULL && mip->biomol == MOLECULE_TYPE_MRNA) {
5330
StringCat (str, "unknown mRNA");
5331
} else if (mip->biomol == MOLECULE_TYPE_PRE_MRNA) {
5332
StringCat (str, " unknown precursor RNA");
5334
StringCat (str, "unknown gene");
5336
if (dfp->numUnknown > 1) {
5337
StringCat (str, "s");
8181
if (dfp->subtype == FEATDEF_CDS && dfp->prot != NULL)
8182
AutoDef_AddProtein (dfp, mip, str, featNum);
8183
else if (dfp->subtype == FEATDEF_CDS && dfp->pseudo)
8184
AutoDef_AddPseudoGene (dfp, str, featNum, text);
8185
else if (dfp->subtype == FEATDEF_CDS &&
8186
dfp->prot == NULL && dfp->genename != NULL)
8187
AutoDef_AddmRNA (dfp, str, featNum, text, mip);
8188
else if (dfp->subtype == FEATDEF_GENE)
8189
AutoDef_AddGene (dfp, str, featNum, text, mip);
8190
else if (dfp->subtype == FEATDEF_rRNA ||
8191
dfp->subtype == FEATDEF_otherRNA)
8192
AutoDef_AddRRNAandOtherRNA (dfp, str, featNum, text, mip);
8193
else if (dfp->subtype == FEATDEF_tRNA)
8194
AutoDef_AddtRNA (dfp, str, featNum, text);
8195
else if (dfp->subtype == FEATDEF_snoRNA)
8196
AutoDef_AddsnoRNA (dfp, str, featNum, text, mip);
8197
else if (dfp->subtype == FEATDEF_snRNA)
8198
AutoDef_AddsnRNA (dfp, str, featNum, text, mip);
8199
else if (dfp->subtype == FEATDEF_LTR)
8200
AutoDef_AddLTR (dfp, str, sfp);
8201
else if (dfp->subtype == FEATDEF_exon)
8202
AutoDef_AddExon (dfp, str, text, vnp, sfp, mip);
8203
else if (dfp->numUnknown > 0)
8204
AutoDef_AddUnknown (dfp, str, mip);
8208
/* Add a separator, or a terminator if */
8209
/* it's the last feature. */
5342
8211
vnp = vnp->next;
5343
8212
if (! StringHasNoText (str)) {
5346
orgnelle [0] = '\0';
5347
switch (biop->genome) {
5348
case GENOME_chloroplast :
5349
case GENOME_chromoplast :
5350
case GENOME_kinetoplast :
5351
case GENOME_mitochondrion :
5352
case GENOME_plastid :
5353
case GENOME_cyanelle :
5354
case GENOME_apicoplast :
5355
case GENOME_leucoplast :
5356
case GENOME_proplastid :
5357
if (mitocount > 1) {
5358
sprintf (orgnelle, "; %s genes for %s products", organelleByGenome [biop->genome], organelleByGenome [biop->genome]);
5360
sprintf (orgnelle, "; %s gene for %s product", organelleByGenome [biop->genome], organelleByGenome [biop->genome]);
5362
StringCat (str, orgnelle);
5365
if (mitochloroflag > 0) {
5366
if (mitochloroflag > 10) {
5368
} else if (mitochloroflag == 10) {
5369
StringCat (str, "; alternatively spliced");
5371
if (mitocount > 1) {
5372
sprintf (orgnelle, "; nuclear genes for %s products", organelleByPopup [mitochloroflag]);
5374
sprintf (orgnelle, "; nuclear gene for %s product", organelleByPopup [mitochloroflag]);
5376
StringCat (str, orgnelle);
5382
if (biop->genome == GENOME_mitochondrion) {
5383
if (mitocount > 1) {
5384
StringCat (str, "; mitochondrial genes for mitochondrial products");
5386
StringCat (str, "; mitochondrial gene for mitochondrial product");
5388
} else if (biop->genome == GENOME_chloroplast) {
5389
if (mitocount > 1) {
5390
StringCat (str, "; chloroplast genes for chloroplast products");
5392
StringCat (str, "; chloroplast gene for chloroplast product");
5394
} else if (mitochloroflag > 0) {
5395
switch (mitochloroflag) {
5397
if (mitocount > 1) {
5398
StringCat (str, "; nuclear genes for mitochondrial products");
5400
StringCat (str, "; nuclear gene for mitochondrial product");
5404
if (mitocount > 1) {
5405
StringCat (str, "; nuclear genes for chloroplast products");
5407
StringCat (str, "; nuclear gene for chloroplast product");
5411
if (mitocount > 1) {
5412
StringCat (str, "; mitochondrial genes for mitochondrial products");
5414
StringCat (str, "; mitochondrial gene for mitochondrial product");
5418
if (mitocount > 1) {
5419
StringCat (str, "; chloroplast genes for chloroplast products");
5421
StringCat (str, "; chloroplast gene for chloroplast product");
5430
StringCat (str, ".");
5431
} else if (vnp->next == NULL) {
5432
nextdfp = (DefFeatsPtr) vnp->data.ptrvalue;
5433
if (dfp->lastInPenultimate) {
5434
if ((dfp->subtype == FEATDEF_rRNA && nextdfp->subtype == FEATDEF_otherRNA &&
5435
dfp->sfp->partial == nextdfp->sfp->partial) ||
5436
(dfp->subtype == FEATDEF_otherRNA && nextdfp->subtype == FEATDEF_rRNA &&
5437
dfp->sfp->partial == nextdfp->sfp->partial)) {
5438
StringCat (str, ", and");
5439
} else if (dfp->subtype == FEATDEF_exon && nextdfp->subtype == FEATDEF_exon /* &&
5440
dfp->sfp->partial == nextdfp->sfp->partial */) {
5441
StringCat (str, " and");
5443
StringCat (str, "; and");
5445
} else if (dfp->lastInType || dfp->lastInGroup) {
5447
StringCat (str, ", and");
5449
StringCat (str, " and");
5451
} else if (nextdfp->lastInType || nextdfp->lastInGroup) {
5453
StringCat (str, ", and");
5455
StringCat (str, " and");
5459
StringCat (str, ", and");
5461
StringCat (str, " and");
5465
nextdfp = (DefFeatsPtr) vnp->data.ptrvalue;
5466
if (dfp->lastInPenultimate) {
5467
if ((dfp->subtype == FEATDEF_rRNA && nextdfp->subtype == FEATDEF_otherRNA &&
5468
dfp->sfp->partial == nextdfp->sfp->partial) ||
5469
(dfp->subtype == FEATDEF_otherRNA && nextdfp->subtype == FEATDEF_rRNA &&
5470
dfp->sfp->partial == nextdfp->sfp->partial)) {
5471
StringCat (str, ", and");
5472
} else if (dfp->subtype == FEATDEF_exon && nextdfp->subtype == FEATDEF_exon /* &&
5473
dfp->sfp->partial == nextdfp->sfp->partial */) {
5474
StringCat (str, ",");
5476
StringCat (str, "; and");
5478
} else if (dfp->lastInType || dfp->lastInGroup) {
5479
StringCat (str, ";");
5480
} else if (nextdfp->lastInType || nextdfp->lastInGroup) {
5482
StringCat (str, ", and");
5484
StringCat (str, " and");
5487
StringCat (str, ",");
8214
AutoDef_AddEnding (str, biop, mitocount, mitochloroflag);
8215
else if (vnp->next == NULL)
8216
AutoDef_AddPenultSeparator (dfp, str, vnp, featNum);
8218
AutoDef_AddSeparator (dfp, str, vnp, featNum);
8221
/* Add the feature's string to the */
8222
/* valnode list of strings. */
8224
if (! StringHasNoText (str))
5490
8225
ValNodeCopyStr (&strings, 0, str);
5492
if (dfp->lastInString || dfp->lastInGroup || dfp->lastInType) {
8227
/* Clear the counter if last in a group */
8229
if (dfp->lastInString || dfp->lastInGroup || dfp->lastInType)
8233
/* Merge all the strings into one */
5497
8235
ptr = MergeValNodeStrings (strings, FALSE);
8237
/* Add the new defline to the descriptor */
5498
8239
if (nsep != NULL) {
5499
8240
ttl = SeqEntryGetSeqDescr (nsep, Seq_descr_title, NULL);
5501
8242
ttl = SeqEntryGetSeqDescr (sep, Seq_descr_title, NULL);
5504
8244
ttl = CreateNewDescriptor (nsep, Seq_descr_title);
5506
8245
if (ttl != NULL) {
5507
8246
MemFree (ttl->data.ptrvalue);
5508
8247
ttl->data.ptrvalue = ptr;
8252
/* Clean up defore exiting */
5513
8255
ValNodeFreeData (strings);
5514
8256
ValNodeFreeData (head);
5645
static void AutoDefProc (Uint2 entityID, SeqEntryPtr sep, Boolean addMods,
5646
Boolean labelMods, Int2 maxMods, Boolean leaveInParen,
5647
BioseqPtr target, BioseqPtr seg, ValNodePtr nonUniqueOrgs,
5648
Int2 mitochloroflag, Boolean suppressAltSplice, BioseqPtr parent)
5652
BioseqContextPtr bcp;
5662
SeqMgrFeatContext fcontext;
5674
DefFeatsPtr nextdfp;
5681
ValNodePtr PNTR prevvnp;
5695
SeqFeatXrefPtr xref;
5697
if (sep == NULL) return;
8387
/*---------------------------------------------------------------------*/
8389
/* AutoDef_SetGroupingFlags () -- Loop through all the features and */
8390
/* set flags if they are the last in */
8391
/* a group, string, or type. */
8393
/*---------------------------------------------------------------------*/
8395
static void AutoDef_SetGroupingFlags (ValNodePtr vnp)
8400
DefFeatsPtr nextdfp;
8406
/* Loop through all the features, comparing */
8407
/* the current feature to the next one. */
8409
while (vnp != NULL) {
8410
dfp = (DefFeatsPtr) vnp->data.ptrvalue;
8411
vnp->choice = (Uint1) group;
8414
/* If there is a next feat, compare */
8415
/* it with the current one. */
8419
nextdfp = (DefFeatsPtr) vnp->data.ptrvalue;
8421
if ((dfp->subtype == FEATDEF_rRNA &&
8422
nextdfp->subtype == FEATDEF_otherRNA) ||
8423
(dfp->subtype == FEATDEF_otherRNA &&
8424
nextdfp->subtype == FEATDEF_rRNA)) {
8425
dfp->lastInString = TRUE;
8426
if (dfp->sfp->partial != nextdfp->sfp->partial) {
8427
dfp->lastInGroup = TRUE;
8432
else if (dfp->subtype != nextdfp->subtype) {
8433
if (dfp->subtype == FEATDEF_exon &&
8434
nextdfp->subtype == FEATDEF_CDS &&
8435
nextdfp->suppressprefix) {
8436
/* no separator between exons and appropriate cds */
8438
dfp->lastInType = TRUE;
8443
/* If partial state is different, mark it */
8444
/* as a new group, except for exons. */
8446
else if (dfp->sfp->partial != nextdfp->sfp->partial) {
8447
if (!(dfp->subtype == FEATDEF_exon &&
8448
nextdfp->subtype == FEATDEF_exon)) {
8449
dfp->lastInGroup = TRUE;
8454
else if (dfp->pseudo != nextdfp->pseudo) {
8455
dfp->lastInGroup = TRUE;
8459
else if ((dfp->allelename != NULL) || (nextdfp->allelename != NULL)) {
8460
dfp->lastInGroup = TRUE;
8461
dfp->isAlleleGroup = TRUE;
8462
if (dfp->sfp->partial != nextdfp->sfp->partial) {
8463
dfp->lastInString = TRUE;
8468
else if (dfp->altSplices > 1 || nextdfp->altSplices > 1) {
8469
dfp->lastInGroup = TRUE;
8479
/* Since the next feature is NULL, we're on the */
8480
/* last feature so all the last flags are TRUE. */
8483
dfp->lastInString = TRUE;
8484
dfp->lastInGroup = TRUE;
8485
dfp->lastInType = TRUE;
8490
if (penult != NULL) {
8491
penult->lastInPenultimate = TRUE;
8496
/*---------------------------------------------------------------------*/
8498
/* GetExonProtNameFromCDS () -- Gets a protein name for an Exon by */
8499
/* checking for overlap with a CDS feat. */
8501
/* Returns : The protein name in the dfp->protname field. NULL if */
8504
/*---------------------------------------------------------------------*/
8506
static void GetExonProtNameFromCDS (DefFeatsPtr dfp)
8510
SeqMgrFeatContext fcontext;
8513
/* Use the mRNA feature to check for overlap because the */
8514
/* CDS doesn't completely overlap all the exons. */
8516
mrnaSfp = SeqMgrGetOverlappingmRNA (dfp->sfp->location, &fcontext);
8517
if (NULL == mrnaSfp)
8520
/* If it overlaps the CDS also, then use that */
8522
cdsSfp = SeqMgrGetOverlappingFeature (dfp->sfp->location,
8529
if (cdsSfp != NULL) {
8530
if (dfp->protname == NULL) {
8531
dfp->protname = fcontext.label; /* points to stable str */
8533
df.protname = fcontext.label;
8534
CombineProteinNames (dfp, &df);
8542
/*---------------------------------------------------------------------*/
8544
/* GetProtNameForExons () -- Get a protein for a given exon feature */
8545
/* to use in the defline. */
8547
/*---------------------------------------------------------------------*/
8549
static void GetProtNameForExons (ValNodePtr head,
8556
SeqMgrFeatContext fcontext;
8561
Boolean found_protein;
8563
/* Loop through all the features that we've gathered data for */
8564
/* and add a protein name to any that are exon features. */
8566
for (vnp = head; vnp != NULL; vnp = vnp->next) {
8567
found_protein = FALSE;
8569
dfp = (DefFeatsPtr) vnp->data.ptrvalue;
8571
/* If not an exon then skip */
8573
if ((dfp == NULL) || (dfp->subtype != FEATDEF_exon))
8576
/* If the exon has a gene, then use */
8577
/* that to get the protein name. */
8579
if (dfp->gene != NULL) {
8580
gene = SeqMgrGetDesiredFeature (entityID, NULL, 0, 0,
8581
dfp->gene, &fcontext);
8582
if (gene == dfp->gene && (! gene->pseudo)) {
8583
left = fcontext.left;
8584
right = fcontext.right;
8585
cdsSfp = SeqMgrGetNextFeature (parent, NULL, SEQFEAT_CDREGION,
8587
while (cdsSfp != NULL) {
8588
if (fcontext.left >= left &&
8589
fcontext.right <= right &&
8590
(! cdsSfp->pseudo)) {
8591
if (dfp->protname == NULL) {
8592
dfp->protname = fcontext.label; /* points to stable str */
8594
df.protname = fcontext.label;
8595
CombineProteinNames (dfp, &df);
8597
found_protein = TRUE;
8599
cdsSfp = SeqMgrGetNextFeature (parent, cdsSfp, SEQFEAT_CDREGION,
8605
/* Otherwise, try to get a protein name */
8606
/* from an overlapping CDS. */
8608
if (!found_protein) {
8609
GetExonProtNameFromCDS (dfp);
8614
static SeqFeatPtr FindGeneForFeature(SeqFeatPtr sfp, BioseqPtr geneBsp)
8619
SeqMgrFeatContext geneContext;
8621
/* select the gene for this feature */
8622
grp = SeqMgrGetGeneXref (sfp);
8623
if (SeqMgrGeneIsSuppressed (grp))
8625
/* if the gene is suppressed, then don't select a gene */
8628
else if (sfp->data.choice == SEQFEAT_GENE)
8630
/* If this feature is a gene, then the gene this feature should
8631
be associated with is itself */
8634
else if (grp != NULL)
8636
gene = SeqMgrGetFeatureByLabel (geneBsp, grp->locus, SEQFEAT_GENE, 0, &geneContext);
8638
gene = SeqMgrGetFeatureByLabel (geneBsp, grp->locus_tag, SEQFEAT_GENE, 0, &geneContext);
8640
gene = SeqMgrGetFeatureByLabel (geneBsp, grp->desc, SEQFEAT_GENE, 0, &geneContext);
8641
for (syn = grp->syn; gene == NULL && syn != NULL; syn = syn->next)
8643
gene = SeqMgrGetFeatureByLabel (geneBsp, syn->data.ptrvalue, SEQFEAT_GENE, 0, &geneContext);
8646
gene = SeqMgrGetOverlappingGene (sfp->location, NULL);
8650
gene = SeqMgrGetOverlappingGene (sfp->location, NULL);
8655
/*---------------------------------------------------------------------*/
8657
/* AutoDefProc () -- Create a defline from scratch. */
8659
/*---------------------------------------------------------------------*/
8661
static void AutoDefProc (Uint2 entityID,
8666
Boolean leaveInParen,
8669
ValNodePtr nonUniqueOrgs,
8670
Int2 mitochloroflag,
8671
Boolean suppressAltSplice,
8672
Boolean excludeSpOrgs,
8677
BioseqContextPtr bcp;
8688
Boolean is_transgenic;
8693
DefFeatsPtr nextdfp;
8699
ValNodePtr PNTR prevvnp;
8714
SeqFeatXrefPtr xref;
8717
/* Check parameters */
5698
8722
if (target == NULL && seg == NULL) {
8724
/* If we have a Bioseq Set then recurse */
8725
/* until we get a Bioseq. */
5699
8727
if (IS_Bioseq_set (sep)) {
5700
8728
bssp = (BioseqSetPtr) sep->data.ptrvalue;
5701
if (bssp == NULL) return;
5702
8731
if (bssp->_class == 7 ||
5703
(bssp->_class >= 13 && bssp->_class <= 16)) {
5704
for (sep = bssp->seq_set; sep != NULL; sep = sep->next) {
5705
AutoDefProc (entityID, sep, addMods, labelMods, maxMods, leaveInParen, NULL, NULL, nonUniqueOrgs, mitochloroflag, suppressAltSplice, NULL);
8732
(IsPopPhyEtcSet (bssp->_class))) {
8733
for (sep = bssp->seq_set; sep != NULL; sep = sep->next)
8734
AutoDefProc (entityID, sep, addMods, labelMods, maxMods,
8735
leaveInParen, NULL, NULL, nonUniqueOrgs,
8736
mitochloroflag, suppressAltSplice, excludeSpOrgs,
8742
/* If we have a segmented bioseq then recursively */
8743
/* call this function on each segment. */
5711
8745
nsep = FindNucSeqEntry (sep);
5712
8746
if (nsep != NULL) {
5713
8747
bsp = (BioseqPtr) nsep->data.ptrvalue;
5714
if (bsp != NULL && bsp->repr == Seq_repr_seg && bsp->seq_ext != NULL && bsp->seq_ext_type == 1) {
8748
if (bsp != NULL && bsp->repr == Seq_repr_seg &&
8749
bsp->seq_ext != NULL && bsp->seq_ext_type == 1) {
5715
8750
vn.choice = SEQLOC_MIX;
5716
8751
vn.next = NULL;
5717
8752
vn.data.ptrvalue = bsp->seq_ext;