11 for (indk = 0; index < len; index++) {
13 pstring[indk++] = line[index];
14 if (line[index] ==
'(')
16 if (line[index] ==
')')
21 pstring[--indk] =
'\0';
32 for (indk = 0; index < len; index++, indk++) {
33 temp[indk] = line[index];
34 if (temp[indk] ==
'(')
36 if (temp[indk] ==
')')
41 else if (paren_num == 0 && (temp[indk] ==
';' || temp[indk] ==
'.' || temp[indk] ==
',' || temp[indk] ==
'/' || temp[indk] ==
'\n'))
47 static char *
get_atcc(
const Macke& macke,
char *source) {
48 static int cc_num = 16;
49 static const char *CC[16] = {
50 "ATCC",
"CCM",
"CDC",
"CIP",
"CNCTC",
51 "DSM",
"EPA",
"JCM",
"NADC",
"NCDO",
"NCTC",
"NRCC",
52 "NRRL",
"PCC",
"USDA",
"VPI"
55 int indi, indj, index;
61 for (indi = 0; indi < cc_num; indi++) {
63 while ((index =
paren_string(source, pstring, index)) > 0) {
71 sprintf(temp,
"%s %s", CC[indi], buffer);
101 sprintf(temp,
"(%s)", macke.strain);
107 void Macke::add_35end_remark(
char end35,
char yn) {
108 if (yn ==
' ')
return;
110 char *content =
strf(
"%c' end complete: %s\n", end35, yn ==
'y' ?
"Yes" :
"No");
115 void Macke::add_remarks_from(
const GenbankRef& ref) {
116 add_remark_if_content(
"ref:", ref.
ref);
117 add_remark_if_content(
"auth:", ref.
author);
118 add_remark_if_content(
"jour:", ref.
journal);
119 add_remark_if_content(
"title:", ref.
title);
120 add_remark_if_content(
"standard:", ref.
standard);
123 void Macke::add_remarks_from(
const OrgInfo& orginf) {
124 add_remark_if_content(
"Source of strain:", orginf.
source);
125 add_remark_if_content(
"Former name:", orginf.
formname);
126 add_remark_if_content(
"Alternate name:", orginf.
nickname);
127 add_remark_if_content(
"Common name:", orginf.
commname);
128 add_remark_if_content(
"Host organism:", orginf.
hostorg);
131 void Macke::add_remarks_from(
const RDP_comments& comments) {
132 add_remarks_from(comments.
orginf);
133 add_remarks_from(comments.
seqinf);
138 for (
int indi = 0, indj = 0; indi < len; indi++) {
140 temp[indj++] = comments.
others[indi];
141 if (comments.
others[indi] ==
'\n' || comments.
others[indi] ==
'\0') {
150 void Macke::add_remarks_from(
const SeqInfo& seqinf) {
151 add_remark_if_content(
"RDP ID:", seqinf.
RDPid);
152 add_remark_if_content(
"Sequencing methods:", seqinf.
methods);
154 add_35end_remark(
'3', seqinf.
comp3);
155 add_35end_remark(
'5', seqinf.
comp5);
158 void Macke::add_remarks_from(
const GenBank& gbk) {
163 add_remark_if_content(
"ref:", gbk.get_ref(0).ref);
166 for (
int indi = 1; indi < gbk.get_refcount(); indi++) {
167 add_remarks_from(gbk.get_ref(indi));
170 add_remark_if_content(
"KEYWORDS:", gbk.keywords);
171 add_remark_if_content(
"GenBank ACCESSION:", gbk.accession);
172 add_remarks_from(gbk.comments);
181 subspecies[indj - 1] =
'\n';
182 subspecies[indj] =
'\0';
189 warningf(20,
"Inconsistent %s definitions detected:\n"
191 "and %s", what, var, New);
210 for (indk = 0; index < len; index++, indk++) {
211 temp[indk] = line[index];
212 if (temp[indk] ==
'(')
214 if (temp[indk] ==
')')
219 else if (temp[indk] ==
'\n' || (paren_num == 0 && temp[indk] ==
';'))
254 int indj =
find_pattern(gbk.comments.others,
"*source:");
256 int indk =
skip_pattern(gbk.comments.others + indj,
"strain=");
264 return nulldup(strain);
272 subspecies[0] =
'\0';
275 if ((indj =
skip_pattern(gbk.definition,
"subsp. ")) >= 0) {
280 if ((indj =
find_pattern(gbk.comments.others,
"*source:")) >= 0) {
294 return nulldup(subspecies);
301 if (
has_content(macke.author)) freedup(gbk.get_new_ref().author, macke.author);
302 if (
has_content(macke.journal)) freedup(gbk.get_latest_ref().journal, macke.journal);
303 if (
has_content(macke.title)) freedup(gbk.get_latest_ref().title, macke.title);
305 bool first_ref =
true;
311 for (
int ridx = 0; ridx < macke.get_rem_count(); ridx++) {
316 GenbankRef& ref = first_ref ? gbk.get_latest_ref() : gbk.get_new_ref();
317 freeset(ref.
ref, macke.copy_multi_rem(ridx, offset));
321 freeset(gbk.get_latest_ref().author, macke.copy_multi_rem(ridx, offset));
324 freeset(gbk.get_latest_ref().title, macke.copy_multi_rem(ridx, offset));
327 freeset(gbk.get_latest_ref().journal, macke.copy_multi_rem(ridx, offset));
330 freeset(gbk.get_latest_ref().standard, macke.copy_multi_rem(ridx, offset));
333 freeset(gbk.keywords, macke.copy_multi_rem(ridx, offset));
336 else if (
str_equal(key,
"GenBank ACCESSION")) {
337 freeset(gbk.accession, macke.copy_multi_rem(ridx, offset));
339 else if (
str_equal(key,
"Source of strain")) {
340 freeset(orginf.
source, macke.copy_multi_rem(ridx, offset));
342 else if (
str_equal(key,
"Former name")) {
343 freeset(orginf.
formname, macke.copy_multi_rem(ridx, offset));
345 else if (
str_equal(key,
"Alternate name")) {
346 freeset(orginf.
nickname, macke.copy_multi_rem(ridx, offset));
348 else if (
str_equal(key,
"Common name")) {
349 freeset(orginf.
commname, macke.copy_multi_rem(ridx, offset));
351 else if (
str_equal(key,
"Host organism")) {
352 freeset(orginf.
hostorg, macke.copy_multi_rem(ridx, offset));
355 freeset(seqinf.
RDPid, macke.copy_multi_rem(ridx, offset));
357 else if (
str_equal(key,
"Sequencing methods")) {
358 freeset(seqinf.
methods, macke.copy_multi_rem(ridx, offset));
360 else if (
str_equal(key,
"3' end complete")) {
364 else if (
str_equal(key,
"5' end complete")) {
379 warning(22,
"Genus and Species not defined");
385 Append(gbk.definition, macke.subspecies);
390 warning(23,
"Genus and Species and Subspecies not defined");
396 Append(gbk.definition, macke.strain);
419 strcpy(temp, macke.seqabbr);
421 for (indi =
str0len(temp); indi < 13; temp[indi++] =
' ') {}
428 freedup(gbk.locus, temp);
454 int gtom(
const GenBank& gbk, Macke& macke) {
462 freedup(macke.seqabbr, temp);
470 ASSERT_RESULT(
int, 2, sscanf(gbk.definition,
"%s %s", genus, species));
473 if (species[last] ==
';') species[last] =
'\0';
475 freeset(macke.name,
strf(
"%s %s\n", genus, species));
478 const OrgInfo& orginf = gbk.comments.orginf;
479 const SeqInfo& seqinf = gbk.comments.seqinf;
484 freeset(macke.date, gbk.get_date());
Append(macke.date,
"\n");
491 strcat(buffer,
"\n");
494 strcpy(buffer,
"\n");
496 freedup(macke.acs, buffer);
500 if (gbk.has_refs()) {
506 macke.add_remarks_from(gbk);
CONSTEXPR_INLINE int str0len(const char *str)
int mtog(const Macke &macke, GenBank &gbk, const Seq &seq)
int gtom(const GenBank &gbk, Macke &macke)
static char * genbank_get_subspecies(const GenBank &gbk)
static char * get_atcc(const Macke &macke, char *source)
static char * genbank_get_strain(const GenBank &gbk)
void warningf(int warning_num, const char *warning_messagef,...) __ATTR__FORMAT(2)
int find_pattern(const char *text, const char *pattern)
void skip_eolnl_and_append(char *&string1, const char *string2)
#define ASSERT_RESULT(Type, Expected, Expr)
void warning(int warning_num, const char *warning_message)
char * strf(const char *format,...) __ATTR__FORMAT(1)
int skip_subspecies(const char *str, char expect_behind)
int find_strain(const char *str, char expect_behind)
int macke_key_word(const char *line, int index, char *key)
static void copy_subspecies_and_check_consistency(char *const &subspecies, const char *from, int indj)
char buffer[MESSAGE_BUFFERSIZE]
const char * genbank_date(const char *other_date)
CONSTEXPR_INLINE bool has_content(const char *field)
static void check_consistency(const char *what, char *const &var, const char *New)
bool copy_content(char *&entry, const char *content)
static void get_string(char *temp, const char *line, int index)
CONSTEXPR_INLINE bool is_end_mark(char ch)
static int paren_string(char *line, char *pstring, int index)
void genbank_key_word(const char *line, int index, char *key)
static void correct_subspecies(char *subspecies)
void scan_token_or_die(char *to, const char *from)
int Skip_white_space(const char *line, int index)
static char * genbank_get_atcc(const GenBank &gbk, const Macke &macke)
static void get_atcc_string(const char *line, char *temp, int index)
static void check_strain_from(char *const &strain, const char *from)
const char * today_date()
void Append(char *&string1, const char *string2)
int skip_strain(const char *str, char expect_behind)
CONSTEXPR_INLINE bool str_equal(const char *s1, const char *s2)
static void mtog_decode_ref_and_remarks(const Macke &macke, GenBank &gbk)
int skip_pattern(const char *text, const char *pattern)
static void mtog_genbank_def_and_source(const Macke &macke, GenBank &gbk)
void terminate_with(char *&str, char ch)
static void copy_strain_and_check_consistency(char *const &strain, const char *from, int indj)