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) (side-by-side diff)
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 @@
+The routines in asn_print are convenience routines done as an exercise
+to gain familiarity with the ASN.1 native structures and their
+hierarchy.
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 @@
+#include "asn_print_authlist.h"
+#include "asn_print_personid.h"
+
+void
+asn_print_authlist (AuthListPtr a)
+{
+ switch (a->choice)
+ {
+ case 1 :
+ {
+ ValNodePtr name = a->names;
+ while (name != NULL)
+ {
+ AuthorPtr ap = (AuthorPtr)name->data.ptrvalue;
+ PersonIdPtr pid = ap->name;
+ printf (" AUTHOR\n");
+ asn_print_personid (pid);
+
+ name = name->next;
+ }
+ break;
+ }
+
+ default:
+ printf ("AUTHLIST-CHOICE UNHANDLED: %i\n", a->choice);
+ exit (-1);
+ break;
+ }
+
+ return;
+}
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 @@
+#ifndef ASN_PRINT_AUTHLIST_H
+#define ASN_PRINT_AUTHLIST_H
+
+#include <objbibli.h>
+
+void asn_print_authlist (AuthListPtr a);
+
+#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 @@
+#include "asn_print_citgen.h"
+#include "asn_print_authlist.h"
+
+void
+asn_print_citgen (CitGenPtr c)
+{
+ printf (" TYPE: %s\n", c->cit);
+
+ printf (" TITLE: %s\n", c->title);
+
+ if (c->pmid != -1)
+ printf (" PubMed ID: %i\n", c->pmid);
+
+ if (c->muid != -1)
+ printf (" MEDLINE UID: %i\n", c->muid);
+
+ if (c->authors != NULL)
+ {
+ printf (" AUTHORS\n");
+ asn_print_authlist (c->authors);
+ }
+
+ return;
+}
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 @@
+#ifndef ASN_PRINT_CITGEN_H
+#define ASN_PRINT_CITGEN_H
+
+#include <objbibli.h>
+
+void asn_print_citgen (CitGenPtr c);
+
+#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 @@
+#include "asn_print_citsub.h"
+#include "asn_print_authlist.h"
+
+void
+asn_print_citsub (CitSubPtr s)
+{
+ if(s->authors != NULL)
+ {
+ printf (" AUTHORS\n");
+ asn_print_authlist (s->authors);
+ }
+ return;
+}
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 @@
+#ifndef ASN_PRINT_CITSUB_H
+#define ASN_PRINT_CITSUB_H
+
+#include <objbibli.h>
+
+void asn_print_citsub (CitSubPtr s);
+
+#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 @@
+#include "asn_print_personid.h"
+
+void
+asn_print_personid (PersonIdPtr p)
+{
+ switch (p->choice)
+ {
+ case 2 :
+ {
+ /*
+ * Name
+ *
+ * Code affected by GCC Bug 37231 since this block starts with
+ * a declaration.
+ * [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37231]
+ */
+ NameStdPtr n = p->data;
+ if (n->names[0] != NULL)
+ printf (" LAST: %s\n", n->names[0]);
+ if (n->names[1] != NULL)
+ printf (" FIRST: %s\n", n->names[1]);
+ if (n->names[2] != NULL)
+ printf (" MIDDLE: %s\n", n->names[2]);
+ if (n->names[3] != NULL)
+ printf (" FULL: %s\n", n->names[3]);
+ if (n->names[4] != NULL)
+ printf (" INITIALS: %s\n", n->names[4]);
+ if (n->names[5] != NULL)
+ printf (" SUFFIX: %s\n", n->names[5]);
+ if (n->names[6] != NULL)
+ printf (" TITLE: %s\n", n->names[6]);
+ break;
+ }
+
+ default:
+ printf ("PERSONID-CHOICE UNHANDLED: %i\n", p->choice);
+ exit (-1);
+ break;
+ }
+
+ return;
+}
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 @@
+#ifndef ASN_PRINT_PERSONID_H
+#define ASN_PRINT_PERSONID_H
+
+#include <objgen.h>
+
+void asn_print_personid (PersonIdPtr p);
+
+#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 @@
+#include "asn_print_pub.h"
+#include "asn_print_citgen.h"
+#include "asn_print_citsub.h"
+
+void
+asn_print_pub (PubPtr pub)
+{
+ while (pub != NULL)
+ {
+ switch (pub->choice)
+ {
+ case PUB_Gen:
+ /*
+ * Cit-gen
+ */
+ printf (" GENERAL\n");
+ CitGenPtr citgen = pub->data.ptrvalue;
+ asn_print_citgen (citgen);
+ break;
+
+ case PUB_Sub:
+ /*
+ * Cit-sub
+ */
+ printf (" SUBMISSION\n");
+ CitSubPtr citsub = pub->data.ptrvalue;
+ asn_print_citsub (citsub);
+ break;
+
+ default:
+ printf (" PUB CHOICE UNHANDLED=%i\n", pub->choice);
+ exit (-1);
+ break;
+ }
+
+ pub = pub->next;
+ }
+
+ return;
+}
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 @@
+#ifndef ASN_PRINT_PUB_H
+#define ASN_PRINT_PUB_H
+
+#include <subutil.h>
+
+void asn_print_pub (PubPtr pub);
+
+#endif // ASN_PRINT_PUB_H

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.