summaryrefslogtreecommitdiffstats
authorDon Pellegrino <don@drexel.edu>2010-03-30 01:49:19 (GMT)
committer Don Pellegrino <don@drexel.edu>2010-03-30 01:49:19 (GMT)
commita1746971e1443fce7483614c4559b73fe792af54 (patch) (unidiff)
tree68eb326976a10b23b551915ca31a7ad05abf897d
parent7686d6b4176c6c88828f01d2fa4858148c264da5 (diff)
downloadexp007-a1746971e1443fce7483614c4559b73fe792af54.zip
exp007-a1746971e1443fce7483614c4559b73fe792af54.tar.gz
exp007-a1746971e1443fce7483614c4559b73fe792af54.tar.bz2
Added simple print routines as an exercise in navigating the NCBI object structure.
-rw-r--r--src/model/asn_print/README3
-rw-r--r--src/model/asn_print/asn_print_authlist.c31
-rw-r--r--src/model/asn_print/asn_print_authlist.h8
-rw-r--r--src/model/asn_print/asn_print_citgen.c24
-rw-r--r--src/model/asn_print/asn_print_citgen.h8
-rw-r--r--src/model/asn_print/asn_print_citsub.c13
-rw-r--r--src/model/asn_print/asn_print_citsub.h8
-rw-r--r--src/model/asn_print/asn_print_personid.c42
-rw-r--r--src/model/asn_print/asn_print_personid.h8
-rw-r--r--src/model/asn_print/asn_print_pub.c40
-rw-r--r--src/model/asn_print/asn_print_pub.h8
11 files changed, 193 insertions, 0 deletions
diff --git a/src/model/asn_print/README b/src/model/asn_print/README
new file mode 100644
index 0000000..44ceb1f
--- a/dev/null
+++ b/src/model/asn_print/README
@@ -0,0 +1,3 @@
1The routines in asn_print are convenience routines done as an exercise
2to gain familiarity with the ASN.1 native structures and their
3hierarchy.
diff --git a/src/model/asn_print/asn_print_authlist.c b/src/model/asn_print/asn_print_authlist.c
new file mode 100644
index 0000000..c14e7d6
--- a/dev/null
+++ b/src/model/asn_print/asn_print_authlist.c
@@ -0,0 +1,31 @@
1#include "asn_print_authlist.h"
2#include "asn_print_personid.h"
3
4void
5asn_print_authlist (AuthListPtr a)
6{
7 switch (a->choice)
8 {
9 case 1 :
10 {
11 ValNodePtr name = a->names;
12 while (name != NULL)
13 {
14 AuthorPtr ap = (AuthorPtr)name->data.ptrvalue;
15 PersonIdPtr pid = ap->name;
16 printf (" AUTHOR\n");
17 asn_print_personid (pid);
18
19 name = name->next;
20 }
21 break;
22 }
23
24 default:
25 printf ("AUTHLIST-CHOICE UNHANDLED: %i\n", a->choice);
26 exit (-1);
27 break;
28 }
29
30 return;
31}
diff --git a/src/model/asn_print/asn_print_authlist.h b/src/model/asn_print/asn_print_authlist.h
new file mode 100644
index 0000000..9fbbb52
--- a/dev/null
+++ b/src/model/asn_print/asn_print_authlist.h
@@ -0,0 +1,8 @@
1#ifndef ASN_PRINT_AUTHLIST_H
2#define ASN_PRINT_AUTHLIST_H
3
4#include <objbibli.h>
5
6void asn_print_authlist (AuthListPtr a);
7
8#endif // ASN_PRINT_AUTHLIST_H
diff --git a/src/model/asn_print/asn_print_citgen.c b/src/model/asn_print/asn_print_citgen.c
new file mode 100644
index 0000000..4e4edb3
--- a/dev/null
+++ b/src/model/asn_print/asn_print_citgen.c
@@ -0,0 +1,24 @@
1#include "asn_print_citgen.h"
2#include "asn_print_authlist.h"
3
4void
5asn_print_citgen (CitGenPtr c)
6{
7 printf (" TYPE: %s\n", c->cit);
8
9 printf (" TITLE: %s\n", c->title);
10
11 if (c->pmid != -1)
12 printf (" PubMed ID: %i\n", c->pmid);
13
14 if (c->muid != -1)
15 printf (" MEDLINE UID: %i\n", c->muid);
16
17 if (c->authors != NULL)
18 {
19 printf (" AUTHORS\n");
20 asn_print_authlist (c->authors);
21 }
22
23 return;
24}
diff --git a/src/model/asn_print/asn_print_citgen.h b/src/model/asn_print/asn_print_citgen.h
new file mode 100644
index 0000000..858dff6
--- a/dev/null
+++ b/src/model/asn_print/asn_print_citgen.h
@@ -0,0 +1,8 @@
1#ifndef ASN_PRINT_CITGEN_H
2#define ASN_PRINT_CITGEN_H
3
4#include <objbibli.h>
5
6void asn_print_citgen (CitGenPtr c);
7
8#endif // ASN_PRINT_CITGEN_H
diff --git a/src/model/asn_print/asn_print_citsub.c b/src/model/asn_print/asn_print_citsub.c
new file mode 100644
index 0000000..50878fc
--- a/dev/null
+++ b/src/model/asn_print/asn_print_citsub.c
@@ -0,0 +1,13 @@
1#include "asn_print_citsub.h"
2#include "asn_print_authlist.h"
3
4void
5asn_print_citsub (CitSubPtr s)
6{
7 if(s->authors != NULL)
8 {
9 printf (" AUTHORS\n");
10 asn_print_authlist (s->authors);
11 }
12 return;
13}
diff --git a/src/model/asn_print/asn_print_citsub.h b/src/model/asn_print/asn_print_citsub.h
new file mode 100644
index 0000000..bd7dbe4
--- a/dev/null
+++ b/src/model/asn_print/asn_print_citsub.h
@@ -0,0 +1,8 @@
1#ifndef ASN_PRINT_CITSUB_H
2#define ASN_PRINT_CITSUB_H
3
4#include <objbibli.h>
5
6void asn_print_citsub (CitSubPtr s);
7
8#endif // ASN_PRINT_CITSUB_H
diff --git a/src/model/asn_print/asn_print_personid.c b/src/model/asn_print/asn_print_personid.c
new file mode 100644
index 0000000..b4b0711
--- a/dev/null
+++ b/src/model/asn_print/asn_print_personid.c
@@ -0,0 +1,42 @@
1#include "asn_print_personid.h"
2
3void
4asn_print_personid (PersonIdPtr p)
5{
6 switch (p->choice)
7 {
8 case 2 :
9 {
10 /*
11 * Name
12 *
13 * Code affected by GCC Bug 37231 since this block starts with
14 * a declaration.
15 * [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37231]
16 */
17 NameStdPtr n = p->data;
18 if (n->names[0] != NULL)
19 printf (" LAST: %s\n", n->names[0]);
20 if (n->names[1] != NULL)
21 printf (" FIRST: %s\n", n->names[1]);
22 if (n->names[2] != NULL)
23 printf (" MIDDLE: %s\n", n->names[2]);
24 if (n->names[3] != NULL)
25 printf (" FULL: %s\n", n->names[3]);
26 if (n->names[4] != NULL)
27 printf (" INITIALS: %s\n", n->names[4]);
28 if (n->names[5] != NULL)
29 printf (" SUFFIX: %s\n", n->names[5]);
30 if (n->names[6] != NULL)
31 printf (" TITLE: %s\n", n->names[6]);
32 break;
33 }
34
35 default:
36 printf ("PERSONID-CHOICE UNHANDLED: %i\n", p->choice);
37 exit (-1);
38 break;
39 }
40
41 return;
42}
diff --git a/src/model/asn_print/asn_print_personid.h b/src/model/asn_print/asn_print_personid.h
new file mode 100644
index 0000000..e231c1e
--- a/dev/null
+++ b/src/model/asn_print/asn_print_personid.h
@@ -0,0 +1,8 @@
1#ifndef ASN_PRINT_PERSONID_H
2#define ASN_PRINT_PERSONID_H
3
4#include <objgen.h>
5
6void asn_print_personid (PersonIdPtr p);
7
8#endif // ASN_PRINT_PERSONID_H
diff --git a/src/model/asn_print/asn_print_pub.c b/src/model/asn_print/asn_print_pub.c
new file mode 100644
index 0000000..7880d03
--- a/dev/null
+++ b/src/model/asn_print/asn_print_pub.c
@@ -0,0 +1,40 @@
1#include "asn_print_pub.h"
2#include "asn_print_citgen.h"
3#include "asn_print_citsub.h"
4
5void
6asn_print_pub (PubPtr pub)
7{
8 while (pub != NULL)
9 {
10 switch (pub->choice)
11 {
12 case PUB_Gen:
13 /*
14 * Cit-gen
15 */
16 printf (" GENERAL\n");
17 CitGenPtr citgen = pub->data.ptrvalue;
18 asn_print_citgen (citgen);
19 break;
20
21 case PUB_Sub:
22 /*
23 * Cit-sub
24 */
25 printf (" SUBMISSION\n");
26 CitSubPtr citsub = pub->data.ptrvalue;
27 asn_print_citsub (citsub);
28 break;
29
30 default:
31 printf (" PUB CHOICE UNHANDLED=%i\n", pub->choice);
32 exit (-1);
33 break;
34 }
35
36 pub = pub->next;
37 }
38
39 return;
40}
diff --git a/src/model/asn_print/asn_print_pub.h b/src/model/asn_print/asn_print_pub.h
new file mode 100644
index 0000000..7f3407a
--- a/dev/null
+++ b/src/model/asn_print/asn_print_pub.h
@@ -0,0 +1,8 @@
1#ifndef ASN_PRINT_PUB_H
2#define ASN_PRINT_PUB_H
3
4#include <subutil.h>
5
6void asn_print_pub (PubPtr pub);
7
8#endif // ASN_PRINT_PUB_H

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.