1957
static Int4 AccessionToGi (CharPtr string)
1964
str = MemNew (StringLen (string) + 10);
1965
sprintf (str, "\"%s\" [ACCN]", string);
1966
lsp = EntrezTLEvalString (str, TYP_NT, -1, NULL, NULL);
1968
if (lsp == NULL) return 0;
1969
if (lsp->num <= 0) {
1980
sip = SeqIdFromAccessionDotVersion (string);
1981
if (sip == NULL) return 0;
1982
gi = GetGIForSeqId (sip);
1987
static void SetGeneAndProtFields (CdRgnFormPtr cfp, CharPtr title);
1989
static BioseqPtr GetProteinFromSep (SeqEntryPtr sep)
1991
BioseqPtr query_bsp;
1994
SeqEntryExplore(sep, &query_bsp, FindProt);
1998
typedef struct proteinimportformdata {
2003
ButtoN DownloadProtein;
2004
} ProteinImportFormData, PNTR ProteinImportFormPtr;
2006
static void AddProteinToCDSDialog (
2016
PointerToDialog (cfp->protseq, bsp);
2017
SetProteinLengthDisplay (cfp->protlen, bsp->length);
2018
SeqIdWrite (bsp->id, str, PRINTID_REPORT, sizeof (str));
2019
SafeSetTitle (cfp->protSeqIdTxt, str);
2020
if (bsp->descr != NULL) {
2021
vnp = ValNodeFindNext (bsp->descr, NULL, Seq_descr_title);
2022
if (vnp != NULL && vnp->data.ptrvalue != NULL) {
2023
vnpstr = (CharPtr) vnp->data.ptrvalue;
2024
SetGeneAndProtFields (cfp, vnpstr);
2027
slp = DialogToPointer (cfp->location);
2028
if (slp == NULL || (! cfp->locvisited)) {
2029
DoPredictCdRegion (cfp);
2034
static void DownloadProteinFromEntrez (ButtoN b)
2041
ProteinImportFormPtr pif;
2043
pif = (ProteinImportFormPtr) GetObjectExtra (b);
2044
if (pif == NULL) return;
2046
if (cfp == NULL) return;
2047
GetTitle (pif->accession, str, sizeof (str));
2048
if (StringHasNoText (str))
2053
if (GetValue (pif->accntype) == 1) {
2054
uid = AccessionToGi (str);
2056
if (! StrToLong (str, &uid)) {
2062
sep = PubSeqSynchronousQuery (uid, 0, -1);
2064
Message (MSG_OK, "Unable to find this record in the database.");
2067
if (IS_Bioseq (sep)) {
2068
} else if (IS_Bioseq_set (sep)) {
2070
Message (MSG_OK, "Unable to find this record in the database.");
2074
bsp = GetProteinFromSep (sep);
2077
Message (MSG_ERROR, "No protein in record!");
2081
AddProteinToCDSDialog (bsp, cfp);
2089
static void FetchTextProc (TexT t)
2094
ProteinImportFormPtr pif;
2098
pif = (ProteinImportFormPtr) GetObjectExtra (t);
2099
if (pif == NULL) return;
2100
GetTitle (t, str, sizeof (str));
2101
if (StringHasNoText (str)) {
2102
SafeDisable (pif->DownloadProtein);
2104
SafeEnable (pif->DownloadProtein);
2105
TrimSpacesAroundString (str);
2109
while (ch != '\0') {
2110
if (! IS_DIGIT (ch)) {
2117
SafeSetValue (pif->accntype, 2);
2119
SafeSetValue (pif->accntype, 1);
2124
static void LoadFASTAProteinFromFile (ButtoN b)
2131
Char path [PATH_MAX];
2132
ProteinImportFormPtr pif;
2134
pif = (ProteinImportFormPtr) GetObjectExtra (b);
2135
if (pif == NULL) return;
2137
if (cfp == NULL) return;
2140
extension = GetAppProperty ("FastaProtExtension");
2141
if (GetInputFileName (path, sizeof (path), extension, "TEXT"))
2143
fp = FileOpen (path, "r");
2145
sep = FastaToSeqEntry (fp, FALSE);
2146
if (sep != NULL && sep->choice == 1 && sep->data.ptrvalue != NULL) {
2147
bsp = (BioseqPtr) sep->data.ptrvalue;
2148
AddProteinToCDSDialog (bsp, cfp);
2157
static void ShowImportProteinDialog ( CdRgnFormPtr cfp)
2162
ProteinImportFormPtr pif;
2164
pif = (ProteinImportFormPtr) MemNew ( sizeof (ProteinImportFormData));
2165
if (pif == NULL) return;
2167
w = FixedWindow (-50, -33, -10, -10, "Import Protein", StdCloseWindowProc);
2169
SetObjectExtra (w, pif, NULL);
2171
h = HiddenGroup (w, -1, 0, NULL);
2172
SetGroupSpacing (h, 10, 10);
2174
g = HiddenGroup (h, 4, 0, NULL);
2176
pif->accntype = HiddenGroup (g, 4, 0, NULL);
2177
RadioButton (pif->accntype, "Accession");
2178
RadioButton (pif->accntype, "GI");
2179
SetValue (pif->accntype, 1);
2180
pif->accession = DialogText (g, "", 6, FetchTextProc);
2181
SetObjectExtra (pif->accession, pif, NULL);
2182
pif->DownloadProtein = PushButton (g, "Download Protein From Entrez",
2183
DownloadProteinFromEntrez);
2184
SetObjectExtra (pif->DownloadProtein, pif, NULL);
2185
Disable (pif->DownloadProtein);
2187
f = HiddenGroup (h, 4, 0, NULL);
2188
b = PushButton (f, "Load FASTA Protein From File", LoadFASTAProteinFromFile);
2189
SetObjectExtra (b, pif, NULL);
2191
c = HiddenGroup (w, 2, 0, NULL);
2192
PushButton (c, "Cancel", StdCancelButtonProc);
2193
AlignObjects (ALIGN_CENTER, (HANDLE) g, (HANDLE) f, (HANDLE) c, NULL);
1927
2200
static DialoG CreateCdRgnDialog (GrouP h, CharPtr title, Int2 genCode,
1928
2201
SeqFeatPtr sfp, CdRgnFormPtr cfp)
2027
2300
x = HiddenGroup (cfp->protTextGrp, 2, 0, NULL);
2028
2301
SetGroupSpacing (x, 3, 5);
2029
2302
StaticPrompt (x, "Name", 0, dialogTextHeight, programFont, 'l');
2030
cfp->protNameText = DialogText (x, "", 15, NULL);
2303
cfp->protNameText = DialogText (x, "", 25, NULL);
2031
2304
StaticPrompt (x, "Description", 0, dialogTextHeight, programFont, 'l');
2032
cfp->protDescText = DialogText (x, "", 15, NULL);
2305
cfp->protDescText = DialogText (x, "", 25, NULL);
2033
2306
cfp->protPromptGrp = HiddenGroup (f, -1, 0, NULL);
2034
2307
StaticPrompt (cfp->protPromptGrp,
2035
2308
"Press Edit Protein Feature to change protein name",
2254
2518
if (cfp != NULL) {
2255
2519
switch (cfp->currentPage) {
2256
2520
case CODING_REGION_PAGE :
2257
extension = GetAppProperty ("FastaProtExtension");
2258
if (path [0] != '\0' || GetInputFileName (path, sizeof (path), extension, "TEXT")) {
2259
fp = FileOpen (path, "r");
2261
sep = FastaToSeqEntry (fp, FALSE);
2262
if (sep != NULL && sep->choice == 1 && sep->data.ptrvalue != NULL) {
2263
bsp = (BioseqPtr) sep->data.ptrvalue;
2264
PointerToDialog (cfp->protseq, bsp);
2265
SetProteinLengthDisplay (cfp->protlen, bsp->length);
2266
SeqIdWrite (bsp->id, str, PRINTID_REPORT, sizeof (str));
2267
SafeSetTitle (cfp->protSeqIdTxt, str);
2268
if (bsp->descr != NULL) {
2269
vnp = ValNodeFindNext (bsp->descr, NULL, Seq_descr_title);
2270
if (vnp != NULL && vnp->data.ptrvalue != NULL) {
2271
vnpstr = (CharPtr) vnp->data.ptrvalue;
2272
SetGeneAndProtFields (cfp, vnpstr);
2275
slp = DialogToPointer (cfp->location);
2276
if (slp == NULL || (! cfp->locvisited)) {
2277
DoPredictCdRegion (cfp);
2521
ShowImportProteinDialog ( cfp);
2286
2523
case COMMON_PAGE :
2490
2740
if (cfp->autoRetranslate) {
2491
2741
DoTranslateProtein (cfp);
2493
2744
pseudo = FALSE;
2494
qual = (GBQualPtr) DialogToPointer (cfp->gbquals);
2496
while (gbq != NULL) {
2497
if (StringICmp (gbq->qual, "pseudo") == 0) {
2503
bsp = (BioseqPtr) DialogToPointer (cfp->protseq);
2745
if (GetStatus (cfp->pseudo))
2751
qual = (GBQualPtr) DialogToPointer (cfp->gbquals);
2753
while (gbq != NULL) {
2754
if (StringICmp (gbq->qual, "pseudo") == 0) {
2764
/* remove old product, if there is one */
2765
prod_slp = DialogToPointer (cfp->product);
2766
if (prod_slp != NULL)
2768
bsp = BioseqFind (SeqLocId (prod_slp));
2770
bsp->idx.deleteme = TRUE;
2771
delete_old_product = TRUE;
2773
prod_slp = SeqLocFree (prod_slp);
2775
/* do not create new product */
2776
PointerToDialog (cfp->product, NULL);
2777
PointerToDialog (cfp->protseq, NULL);
2779
/* if the protein name is set, move it to a note */
2780
GetTitle (cfp->protNameText, str, sizeof (str) - 1);
2781
if (! StringHasNoText (str))
2783
SetComment (str, w);
2784
SetTitle (cfp->protNameText, "");
2789
bsp = (BioseqPtr) DialogToPointer (cfp->protseq);
2506
2792
ans = Message (MSG_OKC, "The coding region has no peptide sequence. Are you sure?");
2508
} else if (pseudo) {
2509
/* ask about deleting the product bioseq? */
2512
if (ans == ANS_OK) {
2799
bsp = BioseqFree (bsp);
2515
2802
if (Visible (cfp->protSeqIdGrp)) {
3971
4297
ppp->protGrp [0] = HiddenGroup (k, -1, 0, NULL);
3972
4298
g = HiddenGroup (ppp->protGrp [0], 0, 10, NULL);
3973
4299
StaticPrompt (g, "Protein Names", 0, 0, programFont, 'c');
3974
ppp->name = CreateVisibleStringDialog (g, 3, -1, 15);
4300
ppp->name = CreateVisibleStringDialog (g, 3, -1, 25);
3976
4302
f = HiddenGroup (ppp->protGrp [0], 0, 4, NULL);
3977
4303
StaticPrompt (f, "Description", 0, dialogTextHeight, programFont, 'c');
3978
ppp->desc = DialogText (f, "", 20, NULL);
4304
ppp->desc = DialogText (f, "", 25, NULL);
3980
4306
r = HiddenGroup (ppp->protGrp [0], 2, 0, NULL);
3981
4307
StaticPrompt (r, "Processing", 0, dialogTextHeight, programFont, 'l');
3982
ppp->processed = PopupList (r, TRUE, NULL);
4308
ppp->processed = PopupList (r, TRUE, ChangeProtProcessed);
4309
SetObjectExtra (ppp->processed, (Pointer) pfp, NULL);
3983
4310
PopupItem (ppp->processed, " ");
3984
4311
PopupItem (ppp->processed, "Proprotein");
3985
4312
PopupItem (ppp->processed, "Mature");