2
* ===========================================================================
5
* National Center for Biotechnology Information (NCBI)
7
* This software/database is a "United States Government Work" under the
8
* terms of the United States Copyright Act. It was written as part of
9
* the author's official duties as a United States Government employee and
10
* thus cannot be copyrighted. This software/database is freely available
11
* to the public for use. The National Library of Medicine and the U.S.
12
* Government do not place any restriction on its use or reproduction.
13
* We would, however, appreciate having the NCBI and the author cited in
14
* any work or product based on this material
16
* Although all reasonable efforts have been taken to ensure the accuracy
17
* and reliability of the software and data, the NLM and the U.S.
18
* Government do not and cannot warrant the performance or results that
19
* may be obtained by using this software or data. The NLM and the U.S.
20
* Government disclaim all warranties, express or implied, including
21
* warranties of performance, merchantability or fitness for any particular
24
* ===========================================================================
28
* Author: Jonathan Kans
30
* Version Creation Date: 10/31/08
37
* --------------------------------------------------------------------------
38
* Date Name Description of modification
39
* ------- ---------- -----------------------------------------------------
41
* ==========================================================================
58
static SeqEntryPtr ReadSep (
66
Uint2 datatype, entityID;
68
dataptr = ReadAsnFastaOrFlatFile (fp, &datatype, NULL, forceNuc, forcePrt, TRUE, FALSE);
69
if (dataptr == NULL) return NULL;
70
entityID = ObjMgrRegister (datatype, dataptr);
71
return GetTopSeqEntryForEntityID (entityID);
74
static void ProcessSuggest (
82
BioseqPtr nbsp = NULL, pbsp = NULL;
83
SeqEntryPtr nsep, psep, sep;
88
nsep = ReadSep (nfp, TRUE, FALSE);
89
psep = ReadSep (pfp, FALSE, TRUE);
91
if (nsep != NULL && psep != NULL) {
92
sep = FindNthBioseq (nsep, 1);
93
if (sep != NULL && IS_Bioseq (sep)) {
94
nbsp = (BioseqPtr) sep->data.ptrvalue;
96
sep = FindNthBioseq (psep, 1);
97
if (sep != NULL && IS_Bioseq (sep)) {
98
pbsp = (BioseqPtr) sep->data.ptrvalue;
100
if (nbsp != NULL && pbsp != NULL) {
101
if (ISA_na (nbsp->mol) && ISA_aa (pbsp->mol)) {
102
sap = SuggestCodingRegion (nbsp, pbsp, gencode);
104
if (sap != NULL && sap->type == 1) {
105
sfp = (SeqFeatPtr) sap->data;
106
if (sfp != NULL && sfp->data.choice == SEQFEAT_CDREGION) {
109
SeqLocAsnWrite (slp, ofp, NULL);
123
#define n_argNucInputFile 0
124
#define p_argPrtInputFile 1
125
#define o_argOutputFile 2
126
#define g_argGeneticCode 3
129
{"Nucleotide Input File", NULL, NULL, NULL,
130
FALSE, 'n', ARG_FILE_IN, 0.0, 0, NULL},
131
{"Protein Input File", NULL, NULL, NULL,
132
FALSE, 'p', ARG_FILE_IN, 0.0, 0, NULL},
133
{"Output File", NULL, NULL, NULL,
134
FALSE, 'o', ARG_FILE_OUT, 0.0, 0, NULL},
135
{"Genetic Code", "1", "0", "20",
136
TRUE, 'g', ARG_INT, 0.0, 0, NULL},
145
CharPtr nucfile, prtfile, outfile;
149
ErrSetFatalLevel (SEV_MAX);
150
ErrClearOptFlags (EO_SHOW_USERSTR);
151
UseLocalAsnloadDataAndErrMsg ();
154
/* finish resolving internal connections in ASN.1 parse tables */
156
if (! AllObjLoad ()) {
157
Message (MSG_FATAL, "AllObjLoad failed");
160
if (! SubmitAsnLoad ()) {
161
Message (MSG_FATAL, "SubmitAsnLoad failed");
164
if (! FeatDefSetLoad ()) {
165
Message (MSG_FATAL, "FeatDefSetLoad failed");
168
if (! SeqCodeSetLoad ()) {
169
Message (MSG_FATAL, "SeqCodeSetLoad failed");
172
if (! GeneticCodeTableLoad ()) {
173
Message (MSG_FATAL, "GeneticCodeTableLoad failed");
177
/* process command line arguments */
179
if (! GetArgs ("sugint", sizeof (myargs) / sizeof (Args), myargs)) {
183
nucfile = (CharPtr) myargs [n_argNucInputFile].strvalue;
184
prtfile = (CharPtr) myargs [p_argPrtInputFile].strvalue;
185
outfile = (CharPtr) myargs [o_argOutputFile].strvalue;
186
gencode = (Int2) myargs [g_argGeneticCode].intvalue;
188
nfp = FileOpen (nucfile, "r");
190
Message (MSG_FATAL, "Unable to open nucleotide input file");
194
pfp = FileOpen (prtfile, "r");
196
Message (MSG_FATAL, "Unable to open protein input file");
200
ofp = AsnIoOpen (outfile, "w");
202
Message (MSG_FATAL, "Unable to open output file");
206
ProcessSuggest (nfp, pfp, ofp, gencode);