File: checksub.c

package info (click to toggle)
ncbi-tools6 6.1.20170106%2Bdfsg2-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 468,504 kB
  • sloc: ansic: 1,474,210; pascal: 6,740; cpp: 6,248; xml: 3,390; sh: 2,139; perl: 1,084; csh: 508; makefile: 437; ruby: 93; lisp: 81; javascript: 16
file content (64 lines) | stat: -rw-r--r-- 1,603 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

/*****************************************************************************
*
*   checksub.c
*     reads a sequenct submission with the object loaders
*
*****************************************************************************/
#include <objsub.h>

#define NUMARGS 3
Args myargs[NUMARGS] = {
	{ "Input data", NULL, "Seq-submit", NULL, FALSE, 'i', ARG_DATA_IN, 0.0,0,NULL},
	{ "Input data is binary", "F", NULL, NULL, TRUE , 'b', ARG_BOOLEAN, 0.0,0,NULL},
	{ "Output data", "stdout", "Seq-submit", NULL, FALSE, 'o', ARG_DATA_OUT, 0.0,0,NULL}};

Int2 Main(void)
{
	AsnIoPtr aip, aipout;
	AsnTypePtr atp;
	static CharPtr intypes[2] = { "r", "rb" };
	Int2 intype;
	SeqSubmitPtr ssp;

    if (! SubmitAsnLoad())
        Message(MSG_FATAL, "Unable to load parse trees.");

	atp = AsnFind("Seq-submit");
	if (atp == NULL)
		Message(MSG_FATAL, "Unable to find Seq-submit");

    if (! GetArgs("CheckSub 1.0", NUMARGS, myargs))
		return 1;

	if (myargs[1].intvalue)        /* binary input is TRUE */
		intype = 1;
	else
		intype = 0;

	if ((aip = AsnIoOpen(myargs[0].strvalue, intypes[intype])) == NULL)
	{
		Message(MSG_FATAL, "Couldn't open %s", myargs[0].strvalue);
		return 1;
	}

	if ((aipout = AsnIoOpen(myargs[2].strvalue, "w")) == NULL)
	{
		Message(MSG_ERROR, "Couldn't open %s", myargs[2].strvalue);
		return 1;
	}

	ssp = SeqSubmitAsnRead(aip, NULL);
	if (ssp == NULL)
		Message(MSG_FATAL, "Couldn't read input file");
	AsnIoClose(aip);

	if (! SeqSubmitAsnWrite(ssp, aipout, NULL))
		Message(MSG_FATAL, "Couldn't write output file");

	AsnIoClose(aipout);
	SeqSubmitFree(ssp);

	return 0;
}