NCBI C Toolkit Cross Reference

C/demo/cnsrt.c


  1 /*
  2 * ===========================================================================
  3 *
  4 *                            PUBLIC DOMAIN NOTICE
  5 *               National Center for Biotechnology Information
  6 *
  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 have not placed any restriction on its use or reproduction.
 13 *
 14 *  Although all reasonable efforts have been taken to ensure the accuracy
 15 *  and reliability of the software and data, the NLM and the U.S.
 16 *  Government do not and cannot warrant the performance or results that
 17 *  may be obtained by using this software or data. The NLM and the U.S.
 18 *  Government disclaim all warranties, express or implied, including
 19 *  warranties of performance, merchantability or fitness for any particular
 20 *  purpose.
 21 *
 22 *  Please cite the author in any work or product based on this material.
 23 *
 24 * ===========================================================================
 25 *
 26 * File Name: cnsrt.c
 27 *
 28 * Author(s): John Kuzio
 29 *
 30 * Version Creation Date: 98-01-01
 31 *
 32 * $Revision: 6.4 $
 33 *
 34 * File Description: consort - codon usage
 35 *
 36 * Modifications:
 37 * --------------------------------------------------------------------------
 38 * Date       Name        Description of modification
 39 * --------------------------------------------------------------------------
 40 * $Log: cnsrt.c,v $
 41 * Revision 6.4  1998/12/18 16:24:53  kuzio
 42 * big GIs
 43 *
 44 * Revision 6.3  1998/09/16 18:19:27  kuzio
 45 * cvs logging
 46 *
 47 * ==========================================================================
 48 */
 49 
 50 #include <ncbi.h>
 51 #include <accentr.h>
 52 #include <gather.h>
 53 #include <urkcnsrt.h>
 54 
 55 #define TOP_ERROR 1
 56 static char _this_module[] = "consort";
 57 #undef  THIS_MODULE
 58 #define THIS_MODULE _this_module
 59 static char _this_file[] = __FILE__;
 60 #undef  THIS_FILE
 61 #define THIS_FILE _this_file
 62 
 63 Args myargs[] =
 64 {
 65   { "nucleotide GI", "0", "0", "9000000", TRUE,
 66     'g', ARG_INT, 0.0, 0, NULL},
 67   { "ASN.1 SeqEntry", NULL, NULL, NULL, TRUE,
 68     'f', ARG_STRING, 0.0, 0, NULL}
 69 };
 70 
 71 Int2 Main (void)
 72 {
 73   Int2        argcount;
 74   Boolean     flagHaveNet, flagTakeNext;
 75   Int4        gi;
 76   CharPtr     filename;
 77   AsnIoPtr    aiop;
 78   SeqEntryPtr sep;
 79   TreeNodePtr ptrNode, ptrNodeFind;
 80   Char        nameL[256], nameR[256];
 81   Int4Ptr     freq;
 82 
 83   argcount = sizeof (myargs) / sizeof (Args);
 84   if (!GetArgs ("consort", argcount, myargs))
 85     return 1;
 86 
 87   gi = myargs[0].intvalue;
 88   filename = myargs[1].strvalue;
 89 
 90   if (gi > 0)
 91   {
 92     if (!EntrezInit ("consort", FALSE, &flagHaveNet))
 93     {
 94       ErrPostEx (SEV_ERROR, TOP_ERROR, 101,
 95                  "Entrez init failed");
 96       ErrShow ();
 97       exit (1);
 98     }
 99     sep = EntrezSeqEntryGet (myargs[0].intvalue, SEQENTRY_READ_BIOSEQ);
100     EntrezFini ();
101   }
102   else if (filename != NULL)
103   {
104     if ((aiop = AsnIoOpen (filename, "r")) == NULL)
105     {
106       ErrPostEx (SEV_ERROR, TOP_ERROR, 102,
107                  "Failed to open: %s", filename);
108       ErrShow ();
109     }
110     sep = SeqEntryAsnRead (aiop, NULL);
111     AsnIoClose (aiop);
112   }
113   else
114   {
115     ErrPostEx (SEV_ERROR, TOP_ERROR, 103,
116                "No gi or ASN.1 file given :: for help :   cnsrt -");
117     ErrShow ();
118     exit (1);
119   }
120 
121   if (sep == NULL)
122   {
123     ErrPostEx (SEV_ERROR, TOP_ERROR, 104,
124                "No seqentry found");
125     ErrShow ();
126     exit (1);
127   }
128 
129   if ((freq = ConformSeqEntry (sep)) != NULL)
130     Conform (freq, stdout);
131   ptrNode = ConsortSeqEntry (sep);
132   SeqEntryFree (sep);
133 
134   SetAllNumberNodes (ptrNode);
135   printf ("%4s %24s %24s %16s\n", "Node", "Left", "Right", "Score");
136 
137   ptrNodeFind = NULL;
138   flagTakeNext = FALSE;
139   while ((ptrNodeFind = ExploreTree (ptrNode, ptrNodeFind,
140          &flagTakeNext)) != NULL)
141   {
142     if (ptrNodeFind->ptrChildLeft != NULL &&
143         ptrNodeFind->ptrChildRight != NULL)
144     {
145       StrCpy (nameL, ptrNodeFind->ptrChildLeft->name);
146       if (StrLen (nameL) > 24)
147         nameL[24] = '\0';
148       StrCpy (nameR, ptrNodeFind->ptrChildRight->name);
149       if (StrLen (nameR) > 24)
150         nameR[24] = '\0';
151       printf ("%4ld %24s %24s %16.5f\n", ptrNodeFind->nodenumber,
152               nameL, nameR, ptrNodeFind->score);
153     }
154     flagTakeNext = FALSE;
155   }
156 
157   return 0;
158 }
159 

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.