diff options
author | Aaron M. Ucko <ucko@debian.org> | 2005-03-23 19:38:09 +0000 |
---|---|---|
committer | Aaron M. Ucko <ucko@debian.org> | 2005-03-23 19:38:09 +0000 |
commit | 9334e3885ef056415008956cb520e26ac220a1cb (patch) | |
tree | b07bc2353ba2abf3c09b7d4bbcd710928db2c5c8 /object | |
parent | 3fc377c9a9cd6419f4ab6c21b956d5a98ce62f0b (diff) |
Load ncbi (20011220) into ncbi-tools6/branches/upstream/current.
Diffstat (limited to 'object')
-rw-r--r-- | object/mapmime.h | 1 | ||||
-rw-r--r-- | object/objbibli.c | 18 | ||||
-rw-r--r-- | object/objfdef.c | 26 | ||||
-rw-r--r-- | object/objfeat.c | 28 | ||||
-rw-r--r-- | object/objfeat.h | 9 | ||||
-rw-r--r-- | object/objloc.c | 41 | ||||
-rw-r--r-- | object/objloc.h | 15 | ||||
-rw-r--r-- | object/objmime.c | 568 | ||||
-rw-r--r-- | object/objmime.h | 72 | ||||
-rw-r--r-- | object/objpub.c | 7 | ||||
-rw-r--r-- | object/objseq.c | 185 | ||||
-rw-r--r-- | object/objseq.h | 18 | ||||
-rw-r--r-- | object/objsset.c | 28 |
13 files changed, 989 insertions, 27 deletions
diff --git a/object/mapmime.h b/object/mapmime.h index d7e69839..ff4ae0f2 100644 --- a/object/mapmime.h +++ b/object/mapmime.h @@ -3,3 +3,4 @@ #include <objsset.h> #include <objmmdb1.h> #include <objcn3d.h> +#include <objcdd.h>
diff --git a/object/objbibli.c b/object/objbibli.c index 87f4ee8d..ce6c6f5e 100644 --- a/object/objbibli.c +++ b/object/objbibli.c @@ -29,7 +29,7 @@ * * Version Creation Date: 1/1/91 * -* $Revision: 6.4 $ +* $Revision: 6.5 $ * * File Description: Object manager for module NCBI-Biblio * @@ -41,6 +41,9 @@ * 07-19-93 Ostell Support for ASN30 added * * $Log: objbibli.c,v $ +* Revision 6.5 2001/10/09 15:57:38 kans +* AuthListMatch does StringICmp if both are structured last names, StringNICmp otherwise +* * Revision 6.4 2000/01/18 19:40:51 ostell * added support for PubStatusDate, ArticleIds * @@ -3285,7 +3288,7 @@ NLM_EXTERN Int2 LIBCALL CitJourMatch (CitJourPtr a, CitJourPtr b) *****************************************************************************/ NLM_EXTERN Int2 LIBCALL AuthListMatch(AuthListPtr a, AuthListPtr b, Boolean all) { - Int2 retval = 1, i; + Int2 retval = 1, lastnames = 0, i; size_t len, tlen; Char name[2][256]; ValNodePtr vnp[2]; @@ -3318,9 +3321,10 @@ NLM_EXTERN Int2 LIBCALL AuthListMatch(AuthListPtr a, AuthListPtr b, Boolean all) if (pip->choice == 2) /* std */ { nsp = (NameStdPtr)pip->data; - if (nsp->names[0] != NULL) /* last name */ + if (nsp->names[0] != NULL) { /* last name */ StringMove(name[i], nsp->names[0]); - else if (nsp->names[3] != NULL) /* full name */ + lastnames++; + } else if (nsp->names[3] != NULL) /* full name */ StringMove(name[i], nsp->names[0]); } else if (pip->choice > 2) @@ -3340,7 +3344,11 @@ NLM_EXTERN Int2 LIBCALL AuthListMatch(AuthListPtr a, AuthListPtr b, Boolean all) else return (Int2) 1; } - retval = (Int2)StringNICmp(name[0], name[1], tlen); + if (lastnames == 2) { + retval = (Int2)StringICmp(name[0], name[1]); + } else { + retval = (Int2)StringNICmp(name[0], name[1], tlen); + } if (retval < 0) return (Int2) -1; else if (retval > 0) diff --git a/object/objfdef.c b/object/objfdef.c index 6e46b747..f0d99583 100644 --- a/object/objfdef.c +++ b/object/objfdef.c @@ -29,7 +29,7 @@ * * Version Creation Date: 9/94 * -* $Revision: 6.20 $ +* $Revision: 6.21 $ * * File Description: Object manager for feature definitions * @@ -1267,8 +1267,28 @@ protref: if (prp->name != NULL) if (label == NULL) label = typelabel; } - else if (StringICmp("misc_feature", ifp->key)) - label = typelabel; + else if (StringICmp("misc_feature", ifp->key)) { + for (gbp = sfp->qual; label == NULL && gbp != NULL; gbp = gbp->next) { + if (StringICmp ("standard_name", gbp->qual) == 0) { + label = gbp->val; + } + } + for (gbp = sfp->qual; label == NULL && gbp != NULL; gbp = gbp->next) { + if (StringICmp ("function", gbp->qual) == 0) { + label = gbp->val; + } + } + for (gbp = sfp->qual; label == NULL && gbp != NULL; gbp = gbp->next) { + if (StringICmp ("number", gbp->qual) == 0) { + label = gbp->val; + } + } + for (gbp = sfp->qual; label == NULL && gbp != NULL; gbp = gbp->next) { + label = gbp->val; + } + if (label == NULL) + label = typelabel; + } } break; case SEQFEAT_REGION: diff --git a/object/objfeat.c b/object/objfeat.c index 3f53b566..583a6aa6 100644 --- a/object/objfeat.c +++ b/object/objfeat.c @@ -29,7 +29,7 @@ * * Version Creation Date: 4/1/91 * -* $Revision: 6.15 $ +* $Revision: 6.16 $ * * File Description: Object manager for module NCBI-SeqFeat * @@ -523,8 +523,20 @@ erret: *****************************************************************************/ NLM_EXTERN Boolean LIBCALL SeqFeatSetAsnWrite (SeqFeatPtr sfp, AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element) { + return SeqFeatSetAsnWriteExtra(sfp, aip, set, element, (ValNodePtr) NULL); +} + +/***************************************************************************** +* +* SeqFeatSetAsnWriteExtra(sfp, aip, set, element, extras) +* this is to accomodate extra features from SeqEntryAsnOut() +* +*****************************************************************************/ +NLM_EXTERN Boolean LIBCALL SeqFeatSetAsnWriteExtra (SeqFeatPtr sfp, AsnIoPtr aip, + AsnTypePtr set, AsnTypePtr element, ValNodePtr extras) +{ AsnTypePtr atp; - SeqFeatPtr oldsfp; + SeqFeatPtr oldsfp, tsfp; Boolean retval = FALSE; Int2 ctr = 0; @@ -540,7 +552,10 @@ NLM_EXTERN Boolean LIBCALL SeqFeatSetAsnWrite (SeqFeatPtr sfp, AsnIoPtr aip, Asn atp = AsnLinkType(element, SEQ_FEAT); /* link local tree */ if (atp == NULL) return FALSE; + oldsfp = sfp; + if (extras != NULL) /* this is an extra set of feats */ + oldsfp = (SeqFeatPtr)(extras->data.ptrvalue); if (! AsnOpenStruct(aip, set, (Pointer)oldsfp)) goto erret; @@ -560,6 +575,14 @@ NLM_EXTERN Boolean LIBCALL SeqFeatSetAsnWrite (SeqFeatPtr sfp, AsnIoPtr aip, Asn } + while (extras != NULL) + { + tsfp = (SeqFeatPtr)(extras->data.ptrvalue); + if (! SeqFeatAsnWrite(tsfp, aip, atp)) + goto erret; + extras = extras->next; + } + if (! AsnCloseStruct(aip, set, (Pointer)oldsfp)) goto erret; retval = TRUE; @@ -5646,3 +5669,4 @@ erret: + diff --git a/object/objfeat.h b/object/objfeat.h index ddfdc6f0..81937ae2 100644 --- a/object/objfeat.h +++ b/object/objfeat.h @@ -29,7 +29,7 @@ * * Version Creation Date: 4/1/91 * -* $Revision: 6.9 $ +* $Revision: 6.10 $ * * File Description: Object manager interface for module NCBI-SeqFeat * @@ -40,6 +40,9 @@ * * * $Log: objfeat.h,v $ +* Revision 6.10 2001/10/02 21:47:54 kans +* added hooks for writing extra descriptors or features (JO) +* * Revision 6.9 2000/09/28 11:40:19 ostell * added endogenous_virus (19) to MolInfo.genome * @@ -305,6 +308,9 @@ NLM_EXTERN Boolean LIBCALL SeqFeatDataAsnRead PROTO((AsnIoPtr aip, AsnTypePtr or NLM_EXTERN Boolean LIBCALL SeqFeatSetAsnWrite PROTO((SeqFeatPtr anp, AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)); NLM_EXTERN SeqFeatPtr LIBCALL SeqFeatSetAsnRead PROTO((AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)); +/** used only SeqAnnotAsnWriteExtra **/ +NLM_EXTERN Boolean LIBCALL SeqFeatSetAsnWriteExtra PROTO((SeqFeatPtr anp, AsnIoPtr aip, + AsnTypePtr set, AsnTypePtr element, ValNodePtr extras)); /***************************************************************************** * * CodeBreak @@ -694,3 +700,4 @@ NLM_EXTERN TxinitPtr LIBCALL TxinitFree PROTO((TxinitPtr txp)); #endif #endif + diff --git a/object/objloc.c b/object/objloc.c index 97ecf8ee..22210c5e 100644 --- a/object/objloc.c +++ b/object/objloc.c @@ -29,7 +29,7 @@ * * Version Creation Date: 4/1/91 * -* $Revision: 6.5 $ +* $Revision: 6.6 $ * * File Description: Object manager for module NCBI-Seqloc * @@ -41,6 +41,9 @@ * * * $Log: objloc.c,v $ +* Revision 6.6 2001/08/06 20:07:26 ostell +* added SEQID_TPG, TPE, TPD types +* * Revision 6.5 2001/01/31 15:24:20 kans * PatentSeqId.seqid is now an Int4 (JO) * @@ -287,6 +290,9 @@ NLM_EXTERN Boolean LIBCALL SeqLocAsnLoad (void) 13 = ddbj Textseq-id -- ddbj 14 = prf Textseq-id , -- PRF SEQDB 15 = pdb PDB-seq-id -- PDB sequence + 16 = tpg Textseq-id , -- Third Party Annot/Seq Genbank + 17 = tpe Textseq-id , -- Third Party Annot/Seq EMBL + 18 = tpd Textseq-id } -- Third Party Annot/Seq DDBJ * *****************************************************************************/ /***************************************************************************** @@ -321,6 +327,9 @@ NLM_EXTERN SeqIdPtr LIBCALL SeqIdFree (SeqIdPtr anp) case SEQID_OTHER: /* other */ case SEQID_DDBJ: case SEQID_PRF: + case SEQID_TPG: + case SEQID_TPE: + case SEQID_TPD: TextSeqIdFree((TextSeqIdPtr)pnt); break; case SEQID_PATENT: /* patent seq id */ @@ -436,6 +445,18 @@ NLM_EXTERN Boolean LIBCALL SeqIdAsnWrite (SeqIdPtr anp, AsnIoPtr aip, AsnTypePtr writetype = SEQ_ID_pdb; func = (AsnWriteFunc) PDBSeqIdAsnWrite; break; + case SEQID_TPG: /* tpg */ + writetype = SEQ_ID_tpg; + func = (AsnWriteFunc) TextSeqIdAsnWrite; + break; + case SEQID_TPE: /* tpe */ + writetype = SEQ_ID_tpe; + func = (AsnWriteFunc) TextSeqIdAsnWrite; + break; + case SEQID_TPD: /* tpd */ + writetype = SEQ_ID_tpd; + func = (AsnWriteFunc) TextSeqIdAsnWrite; + break; } if (writetype != NULL) retval = (* func)(pnt, aip, writetype); /* write it out */ @@ -566,6 +587,21 @@ NLM_EXTERN SeqIdPtr LIBCALL SeqIdAsnRead (AsnIoPtr aip, AsnTypePtr orig) choice = SEQID_PDB; func = (AsnReadFunc) PDBSeqIdAsnRead; } + else if (atp == SEQ_ID_tpg) + { + choice = SEQID_TPG; + func = (AsnReadFunc) TextSeqIdAsnRead; + } + else if (atp == SEQ_ID_tpe) + { + choice = SEQID_TPE; + func = (AsnReadFunc) TextSeqIdAsnRead; + } + else if (atp == SEQ_ID_tpd) + { + choice = SEQID_TPD; + func = (AsnReadFunc) TextSeqIdAsnRead; + } else goto erret; @@ -641,6 +677,9 @@ NLM_EXTERN SeqIdPtr LIBCALL SeqIdDup (SeqIdPtr oldid) case SEQID_OTHER: case SEQID_DDBJ: case SEQID_PRF: + case SEQID_TPG: + case SEQID_TPE: + case SEQID_TPD: at = (TextSeqIdPtr)oldid->data.ptrvalue; bt = TextSeqIdNew(); if (bt == NULL) return NULL; diff --git a/object/objloc.h b/object/objloc.h index a1d5d73e..441bb05b 100644 --- a/object/objloc.h +++ b/object/objloc.h @@ -29,7 +29,7 @@ * * Version Creation Date: 4/1/91 * -* $Revision: 6.2 $ +* $Revision: 6.3 $ * * File Description: Object manager interface for module NCBI-Seqloc * @@ -40,6 +40,9 @@ * * * $Log: objloc.h,v $ +* Revision 6.3 2001/08/06 20:07:26 ostell +* added SEQID_TPG, TPE, TPD types +* * Revision 6.2 2001/01/31 15:24:20 kans * PatentSeqId.seqid is now an Int4 (JO) * @@ -128,6 +131,10 @@ NLM_EXTERN Boolean LIBCALL SeqLocAsnLoad PROTO((void)); 13 = ddbj Textseq-id 14 = prf Textseq-id , -- PRF SEQDB 15 = pdb PDB-seq-id -- PDB sequence + 16 = tpg Textseq-id , -- Third Party Annot/Seq Genbank + 17 = tpe Textseq-id , -- Third Party Annot/Seq EMBL + 18 = tpd Textseq-id } -- Third Party Annot/Seq DDBJ + WARNING: Some routines in sequtil.c (e.g. SeqIdPrint, SeqIdParse) and tofasta.c use @@ -136,7 +143,7 @@ NLM_EXTERN Boolean LIBCALL SeqLocAsnLoad PROTO((void)); * *****************************************************************************/ -#define NUM_SEQID 16 /* total number of SeqId types */ +#define NUM_SEQID 19 /* total number of SeqId types */ #define SEQID_NOT_SET ( (Uint1)0) #define SEQID_LOCAL ( (Uint1)1) @@ -158,6 +165,10 @@ NLM_EXTERN Boolean LIBCALL SeqLocAsnLoad PROTO((void)); #define SEQID_PRF ((Uint1)14) #define SEQID_PDB ((Uint1)15) +#define SEQID_TPG ((Uint1)16) +#define SEQID_TPE ((Uint1)17) +#define SEQID_TPD ((Uint1)18) + NLM_EXTERN Boolean LIBCALL SeqIdAsnWrite PROTO((SeqIdPtr anp, AsnIoPtr aip, AsnTypePtr atp)); NLM_EXTERN SeqIdPtr LIBCALL SeqIdAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp)); NLM_EXTERN SeqIdPtr LIBCALL SeqIdFree PROTO((SeqIdPtr anp)); diff --git a/object/objmime.c b/object/objmime.c index 616c9971..2c8b8277 100644 --- a/object/objmime.c +++ b/object/objmime.c @@ -31,6 +31,18 @@ * ------- ---------- ----------------------------------------------------- * * $Log: objmime.c,v $ +* Revision 6.11 2001/11/21 16:38:23 thiessen +* move cn3d stuff into bundle +* +* Revision 6.10 2001/11/21 14:25:41 thiessen +* remove BisotrucOrId +* +* Revision 6.9 2001/11/20 15:59:34 thiessen +* add imports to BundleSeqsAligns +* +* Revision 6.8 2001/11/16 14:54:26 thiessen +* add new general type +* * Revision 6.7 2001/06/21 14:44:29 thiessen * add new user annotations * @@ -122,6 +134,9 @@ NcbiMimeAsn1Free(ValNodePtr anp) case NcbiMimeAsn1_strucseqs: BiostrucSeqsFree(anp -> data.ptrvalue); break; + case NcbiMimeAsn1_general: + BiostrucSeqsAlignsCddFree(anp -> data.ptrvalue); + break; } return MemFree(anp); } @@ -198,6 +213,10 @@ NcbiMimeAsn1AsnRead(AsnIoPtr aip, AsnTypePtr orig) choice = NcbiMimeAsn1_strucseqs; func = (AsnReadFunc) BiostrucSeqsAsnRead; } + else if (atp == NCBI_MIME_ASN1_general) { + choice = NcbiMimeAsn1_general; + func = (AsnReadFunc) BiostrucSeqsAlignsCddAsnRead; + } anp->choice = choice; if (func != NULL) { @@ -279,6 +298,10 @@ NcbiMimeAsn1AsnWrite(NcbiMimeAsn1Ptr anp, AsnIoPtr aip, AsnTypePtr orig) writetype = NCBI_MIME_ASN1_strucseqs; func = (AsnWriteFunc) BiostrucSeqsAsnWrite; break; + case NcbiMimeAsn1_general: + writetype = NCBI_MIME_ASN1_general; + func = (AsnWriteFunc) BiostrucSeqsAlignsCddAsnWrite; + break; } if (writetype != NULL) { retval = (* func)(pnt, aip, writetype); /* write it out */ @@ -1521,3 +1544,548 @@ erret: return retval; } +/************************************************** +* +* BiostrucSeqsAlignsCddNew() +* +**************************************************/ +NLM_EXTERN +BiostrucSeqsAlignsCddPtr LIBCALL +BiostrucSeqsAlignsCddNew(void) +{ + BiostrucSeqsAlignsCddPtr ptr = MemNew((size_t) sizeof(BiostrucSeqsAlignsCdd)); + + return ptr; + +} + + +/************************************************** +* +* BiostrucSeqsAlignsCddFree() +* +**************************************************/ +NLM_EXTERN +BiostrucSeqsAlignsCddPtr LIBCALL +BiostrucSeqsAlignsCddFree(BiostrucSeqsAlignsCddPtr ptr) +{ + + if(ptr == NULL) { + return NULL; + } + SeqAlignData_seq_align_dataFree(ptr -> SeqAlignData_seq_align_data); + AsnGenericUserSeqOfFree(ptr -> structures, (AsnOptFreeFunc) BiostrucFree); + return MemFree(ptr); +} + + +/************************************************** +* +* SeqAlignData_seq_align_dataFree() +* +**************************************************/ +static +SeqAlignData_seq_align_dataPtr LIBCALL +SeqAlignData_seq_align_dataFree(ValNodePtr anp) +{ + Pointer pnt; + + if (anp == NULL) { + return NULL; + } + + pnt = anp->data.ptrvalue; + switch (anp->choice) + { + default: + break; + case SeqAlignData_seq_align_data_bundle: + BundleSeqsAlignsFree(anp -> data.ptrvalue); + break; + case SeqAlignData_seq_align_data_cdd: + CddFree(anp -> data.ptrvalue); + break; + } + return MemFree(anp); +} + + +/************************************************** +* +* BiostrucSeqsAlignsCddAsnRead() +* +**************************************************/ +NLM_EXTERN +BiostrucSeqsAlignsCddPtr LIBCALL +BiostrucSeqsAlignsCddAsnRead(AsnIoPtr aip, AsnTypePtr orig) +{ + DataVal av; + AsnTypePtr atp; + Boolean isError = FALSE; + AsnReadFunc func; + BiostrucSeqsAlignsCddPtr ptr; + + if (! loaded) + { + if (! objmimeAsnLoad()) { + return NULL; + } + } + + if (aip == NULL) { + return NULL; + } + + if (orig == NULL) { /* BiostrucSeqsAlignsCdd ::= (self contained) */ + atp = AsnReadId(aip, amp, BIOSTRUC_SEQS_ALIGNS_CDD); + } else { + atp = AsnLinkType(orig, BIOSTRUC_SEQS_ALIGNS_CDD); + } + /* link in local tree */ + if (atp == NULL) { + return NULL; + } + + ptr = BiostrucSeqsAlignsCddNew(); + if (ptr == NULL) { + goto erret; + } + if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */ + goto erret; + } + + atp = AsnReadId(aip,amp, atp); + func = NULL; + + if (atp == SEQS_ALIGNS_CDD_seq_align_data) { + ptr -> SeqAlignData_seq_align_data = SeqAlignData_seq_align_dataAsnRead(aip, atp); + if (aip -> io_failure) { + goto erret; + } + atp = AsnReadId(aip,amp, atp); + } + if (atp == SEQS_ALIGNS_CDD_structures) { + ptr -> structures = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) BiostrucAsnRead, (AsnOptFreeFunc) BiostrucFree); + if (isError && ptr -> structures == NULL) { + goto erret; + } + atp = AsnReadId(aip,amp, atp); + } + + if (AsnReadVal(aip, atp, &av) <= 0) { + goto erret; + } + /* end struct */ + +ret: + AsnUnlinkType(orig); /* unlink local tree */ + return ptr; + +erret: + aip -> io_failure = TRUE; + ptr = BiostrucSeqsAlignsCddFree(ptr); + goto ret; +} + + + +/************************************************** +* +* SeqAlignData_seq_align_dataAsnRead() +* +**************************************************/ +static +SeqAlignData_seq_align_dataPtr LIBCALL +SeqAlignData_seq_align_dataAsnRead(AsnIoPtr aip, AsnTypePtr orig) +{ + DataVal av; + AsnTypePtr atp; + ValNodePtr anp; + Uint1 choice; + Boolean isError = FALSE; + Boolean nullIsError = FALSE; + AsnReadFunc func; + + if (! loaded) + { + if (! objmimeAsnLoad()) { + return NULL; + } + } + + if (aip == NULL) { + return NULL; + } + + if (orig == NULL) { /* SeqAlignData_seq_align_data ::= (self contained) */ + atp = AsnReadId(aip, amp, SEQS_ALIGNS_CDD_seq_align_data); + } else { + atp = AsnLinkType(orig, SEQS_ALIGNS_CDD_seq_align_data); /* link in local tree */ + } + if (atp == NULL) { + return NULL; + } + + anp = ValNodeNew(NULL); + if (anp == NULL) { + goto erret; + } + if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */ + goto erret; + } + + func = NULL; + + atp = AsnReadId(aip, amp, atp); /* find the choice */ + if (atp == NULL) { + goto erret; + } + if (atp == CDD_seq_align_data_bundle) { + choice = SeqAlignData_seq_align_data_bundle; + func = (AsnReadFunc) BundleSeqsAlignsAsnRead; + } + else if (atp == ALIGNS_CDD_seq_align_data_cdd) { + choice = SeqAlignData_seq_align_data_cdd; + func = (AsnReadFunc) CddAsnRead; + } + anp->choice = choice; + if (func != NULL) + { + anp->data.ptrvalue = (* func)(aip, atp); + if (aip -> io_failure) goto erret; + + if (nullIsError && anp->data.ptrvalue == NULL) { + goto erret; + } + } + +ret: + AsnUnlinkType(orig); /* unlink local tree */ + return anp; + +erret: + anp = MemFree(anp); + aip -> io_failure = TRUE; + goto ret; +} + + +/************************************************** +* +* BiostrucSeqsAlignsCddAsnWrite() +* +**************************************************/ +NLM_EXTERN Boolean LIBCALL +BiostrucSeqsAlignsCddAsnWrite(BiostrucSeqsAlignsCddPtr ptr, AsnIoPtr aip, AsnTypePtr orig) +{ + DataVal av; + AsnTypePtr atp; + Boolean retval = FALSE; + + if (! loaded) + { + if (! objmimeAsnLoad()) { + return FALSE; + } + } + + if (aip == NULL) { + return FALSE; + } + + atp = AsnLinkType(orig, BIOSTRUC_SEQS_ALIGNS_CDD); /* link local tree */ + if (atp == NULL) { + return FALSE; + } + + if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; } + if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) { + goto erret; + } + + if (ptr -> SeqAlignData_seq_align_data != NULL) { + if ( ! SeqAlignData_seq_align_dataAsnWrite(ptr -> SeqAlignData_seq_align_data, aip, SEQS_ALIGNS_CDD_seq_align_data)) { + goto erret; + } + } + AsnGenericUserSeqOfAsnWrite(ptr -> structures, (AsnWriteFunc) BiostrucAsnWrite, aip, SEQS_ALIGNS_CDD_structures, SEQS_ALIGNS_CDD_structures_E); + if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) { + goto erret; + } + retval = TRUE; + +erret: + AsnUnlinkType(orig); /* unlink local tree */ + return retval; +} + + + +/************************************************** +* +* SeqAlignData_seq_align_dataAsnWrite() +* +**************************************************/ +static Boolean LIBCALL +SeqAlignData_seq_align_dataAsnWrite(SeqAlignData_seq_align_dataPtr anp, AsnIoPtr aip, AsnTypePtr orig) + +{ + DataVal av; + AsnTypePtr atp, writetype = NULL; + Pointer pnt; + AsnWriteFunc func = NULL; + Boolean retval = FALSE; + + if (! loaded) + { + if (! objmimeAsnLoad()) + return FALSE; + } + + if (aip == NULL) + return FALSE; + + atp = AsnLinkType(orig, SEQS_ALIGNS_CDD_seq_align_data); /* link local tree */ + if (atp == NULL) { + return FALSE; + } + + if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; } + + av.ptrvalue = (Pointer)anp; + if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) { + goto erret; + } + + pnt = anp->data.ptrvalue; + switch (anp->choice) + { + case SeqAlignData_seq_align_data_bundle: + writetype = CDD_seq_align_data_bundle; + func = (AsnWriteFunc) BundleSeqsAlignsAsnWrite; + break; + case SeqAlignData_seq_align_data_cdd: + writetype = ALIGNS_CDD_seq_align_data_cdd; + func = (AsnWriteFunc) CddAsnWrite; + break; + } + if (writetype != NULL) { + retval = (* func)(pnt, aip, writetype); /* write it out */ + } + if (!retval) { + goto erret; + } + retval = TRUE; + +erret: + AsnUnlinkType(orig); /* unlink local tree */ + return retval; +} + + +/************************************************** +* +* BundleSeqsAlignsNew() +* +**************************************************/ +NLM_EXTERN +BundleSeqsAlignsPtr LIBCALL +BundleSeqsAlignsNew(void) +{ + BundleSeqsAlignsPtr ptr = MemNew((size_t) sizeof(BundleSeqsAligns)); + + return ptr; + +} + + +/************************************************** +* +* BundleSeqsAlignsFree() +* +**************************************************/ +NLM_EXTERN +BundleSeqsAlignsPtr LIBCALL +BundleSeqsAlignsFree(BundleSeqsAlignsPtr ptr) +{ + + if(ptr == NULL) { + return NULL; + } + AsnGenericChoiceSeqOfFree(ptr -> sequences, (AsnOptFreeFunc) SeqEntryFree); + AsnGenericUserSeqOfFree(ptr -> seqaligns, (AsnOptFreeFunc) SeqAnnotFree); + BiostrucAnnotSetFree(ptr -> strucaligns); + AsnGenericUserSeqOfFree(ptr -> imports, (AsnOptFreeFunc) SeqAnnotFree); + Cn3dStyleDictionaryFree(ptr -> style_dictionary); + Cn3dUserAnnotationsFree(ptr -> user_annotations); + return MemFree(ptr); +} + + +/************************************************** +* +* BundleSeqsAlignsAsnRead() +* +**************************************************/ +NLM_EXTERN +BundleSeqsAlignsPtr LIBCALL +BundleSeqsAlignsAsnRead(AsnIoPtr aip, AsnTypePtr orig) +{ + DataVal av; + AsnTypePtr atp; + Boolean isError = FALSE; + AsnReadFunc func; + BundleSeqsAlignsPtr ptr; + + if (! loaded) + { + if (! objmimeAsnLoad()) { + return NULL; + } + } + + if (aip == NULL) { + return NULL; + } + + if (orig == NULL) { /* BundleSeqsAligns ::= (self contained) */ + atp = AsnReadId(aip, amp, BUNDLE_SEQS_ALIGNS); + } else { + atp = AsnLinkType(orig, BUNDLE_SEQS_ALIGNS); + } + /* link in local tree */ + if (atp == NULL) { + return NULL; + } + + ptr = BundleSeqsAlignsNew(); + if (ptr == NULL) { + goto erret; + } + if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */ + goto erret; + } + + atp = AsnReadId(aip,amp, atp); + func = NULL; + + if (atp == BUNDLE_SEQS_ALIGNS_sequences) { + ptr -> sequences = AsnGenericChoiceSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqEntryAsnRead, (AsnOptFreeFunc) SeqEntryFree); + if (isError && ptr -> sequences == NULL) { + goto erret; + } + atp = AsnReadId(aip,amp, atp); + } + if (atp == BUNDLE_SEQS_ALIGNS_seqaligns) { + ptr -> seqaligns = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqAnnotAsnRead, (AsnOptFreeFunc) SeqAnnotFree); + if (isError && ptr -> seqaligns == NULL) { + goto erret; + } + atp = AsnReadId(aip,amp, atp); + } + if (atp == BUNDLE_SEQS_ALIGNS_strucaligns) { + ptr -> strucaligns = BiostrucAnnotSetAsnRead(aip, atp); + if (aip -> io_failure) { + goto erret; + } + atp = AsnReadId(aip,amp, atp); + } + if (atp == BUNDLE_SEQS_ALIGNS_imports) { + ptr -> imports = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) SeqAnnotAsnRead, (AsnOptFreeFunc) SeqAnnotFree); + if (isError && ptr -> imports == NULL) { + goto erret; + } + atp = AsnReadId(aip,amp, atp); + } + if (atp == SEQS_ALIGNS_style_dictionary) { + ptr -> style_dictionary = Cn3dStyleDictionaryAsnRead(aip, atp); + if (aip -> io_failure) { + goto erret; + } + atp = AsnReadId(aip,amp, atp); + } + if (atp == SEQS_ALIGNS_user_annotations) { + ptr -> user_annotations = Cn3dUserAnnotationsAsnRead(aip, atp); + if (aip -> io_failure) { + goto erret; + } + atp = AsnReadId(aip,amp, atp); + } + + if (AsnReadVal(aip, atp, &av) <= 0) { + goto erret; + } + /* end struct */ + +ret: + AsnUnlinkType(orig); /* unlink local tree */ + return ptr; + +erret: + aip -> io_failure = TRUE; + ptr = BundleSeqsAlignsFree(ptr); + goto ret; +} + + + +/************************************************** +* +* BundleSeqsAlignsAsnWrite() +* +**************************************************/ +NLM_EXTERN Boolean LIBCALL +BundleSeqsAlignsAsnWrite(BundleSeqsAlignsPtr ptr, AsnIoPtr aip, AsnTypePtr orig) +{ + DataVal av; + AsnTypePtr atp; + Boolean retval = FALSE; + + if (! loaded) + { + if (! objmimeAsnLoad()) { + return FALSE; + } + } + + if (aip == NULL) { + return FALSE; + } + + atp = AsnLinkType(orig, BUNDLE_SEQS_ALIGNS); /* link local tree */ + if (atp == NULL) { + return FALSE; + } + + if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; } + if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) { + goto erret; + } + + AsnGenericChoiceSeqOfAsnWrite(ptr -> sequences, (AsnWriteFunc) SeqEntryAsnWrite, aip, BUNDLE_SEQS_ALIGNS_sequences, BUNDLE_SEQS_ALIGNS_sequences_E); + AsnGenericUserSeqOfAsnWrite(ptr -> seqaligns, (AsnWriteFunc) SeqAnnotAsnWrite, aip, BUNDLE_SEQS_ALIGNS_seqaligns, BUNDLE_SEQS_ALIGNS_seqaligns_E); + if (ptr -> strucaligns != NULL) { + if ( ! BiostrucAnnotSetAsnWrite(ptr -> strucaligns, aip, BUNDLE_SEQS_ALIGNS_strucaligns)) { + goto erret; + } + } + AsnGenericUserSeqOfAsnWrite(ptr -> imports, (AsnWriteFunc) SeqAnnotAsnWrite, aip, BUNDLE_SEQS_ALIGNS_imports, BUNDLE_SEQS_ALIGNS_imports_E); + if (ptr -> style_dictionary != NULL) { + if ( ! Cn3dStyleDictionaryAsnWrite(ptr -> style_dictionary, aip, SEQS_ALIGNS_style_dictionary)) { + goto erret; + } + } + if (ptr -> user_annotations != NULL) { + if ( ! Cn3dUserAnnotationsAsnWrite(ptr -> user_annotations, aip, SEQS_ALIGNS_user_annotations)) { + goto erret; + } + } + if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) { + goto erret; + } + retval = TRUE; + +erret: + AsnUnlinkType(orig); /* unlink local tree */ + return retval; +} diff --git a/object/objmime.h b/object/objmime.h index 9c97929c..302f9380 100644 --- a/object/objmime.h +++ b/object/objmime.h @@ -31,6 +31,18 @@ * ------- ---------- ----------------------------------------------------- * * $Log: objmime.h,v $ +* Revision 6.11 2001/11/21 16:38:23 thiessen +* move cn3d stuff into bundle +* +* Revision 6.10 2001/11/21 14:25:41 thiessen +* remove BisotrucOrId +* +* Revision 6.9 2001/11/20 15:59:34 thiessen +* add imports to BundleSeqsAligns +* +* Revision 6.8 2001/11/16 14:54:26 thiessen +* add new general type +* * Revision 6.7 2001/06/21 14:44:29 thiessen * add new user annotations * @@ -77,6 +89,7 @@ typedef ValNode NcbiMimeAsn1; #define NcbiMimeAsn1_alignseq 3 /* yanli added */ #define NcbiMimeAsn1_strucseq 4 /* yanli added */ #define NcbiMimeAsn1_strucseqs 5 /* yanli added */ +#define NcbiMimeAsn1_general 6 /* paul */ NLM_EXTERN NcbiMimeAsn1Ptr LIBCALL NcbiMimeAsn1Free PROTO ((NcbiMimeAsn1Ptr )); @@ -225,6 +238,65 @@ NLM_EXTERN Boolean LIBCALL BiostrucSeqsAsnWrite PROTO (( BiostrucSeqsPtr , AsnIo #define Entrez_style_pdb 12 #define Entrez_style_kinemage 13 + +/************************************************** +* +* BiostrucSeqsAlignsCdd +* +**************************************************/ +typedef struct struct_Biostruc_seqs_aligns_cdd { + ValNodePtr SeqAlignData_seq_align_data; + struct struct_Biostruc PNTR structures; +} BiostrucSeqsAlignsCdd, PNTR BiostrucSeqsAlignsCddPtr; + + +NLM_EXTERN BiostrucSeqsAlignsCddPtr LIBCALL BiostrucSeqsAlignsCddFree PROTO ((BiostrucSeqsAlignsCddPtr )); +NLM_EXTERN BiostrucSeqsAlignsCddPtr LIBCALL BiostrucSeqsAlignsCddNew PROTO (( void )); +NLM_EXTERN BiostrucSeqsAlignsCddPtr LIBCALL BiostrucSeqsAlignsCddAsnRead PROTO (( AsnIoPtr, AsnTypePtr)); +NLM_EXTERN Boolean LIBCALL BiostrucSeqsAlignsCddAsnWrite PROTO (( BiostrucSeqsAlignsCddPtr , AsnIoPtr, AsnTypePtr)); + + +#ifdef NLM_GENERATED_CODE_PROTO + +typedef ValNodePtr SeqAlignData_seq_align_dataPtr; +typedef ValNode SeqAlignData_seq_align_data; + +#endif /* NLM_GENERATED_CODE_PROTO */ + +#define SeqAlignData_seq_align_data_bundle 1 +#define SeqAlignData_seq_align_data_cdd 2 + +#ifdef NLM_GENERATED_CODE_PROTO + +static SeqAlignData_seq_align_dataPtr LIBCALL SeqAlignData_seq_align_dataFree PROTO ((SeqAlignData_seq_align_dataPtr )); +static SeqAlignData_seq_align_dataPtr LIBCALL SeqAlignData_seq_align_dataAsnRead PROTO (( AsnIoPtr, AsnTypePtr)); +static Boolean LIBCALL SeqAlignData_seq_align_dataAsnWrite PROTO (( SeqAlignData_seq_align_dataPtr , AsnIoPtr, AsnTypePtr)); + +#endif /* NLM_GENERATED_CODE_PROTO */ + + + +/************************************************** +* +* BundleSeqsAligns +* +**************************************************/ +typedef struct struct_Bundle_seqs_aligns { + ValNodePtr sequences; + struct struct_Seq_annot PNTR seqaligns; + struct struct_Biostruc_annot_set PNTR strucaligns; + struct struct_Seq_annot PNTR imports; + struct struct_Cn3d_style_dictionary PNTR style_dictionary; + struct struct_Cn3d_user_annotations PNTR user_annotations; +} BundleSeqsAligns, PNTR BundleSeqsAlignsPtr; + + +NLM_EXTERN BundleSeqsAlignsPtr LIBCALL BundleSeqsAlignsFree PROTO ((BundleSeqsAlignsPtr )); +NLM_EXTERN BundleSeqsAlignsPtr LIBCALL BundleSeqsAlignsNew PROTO (( void )); +NLM_EXTERN BundleSeqsAlignsPtr LIBCALL BundleSeqsAlignsAsnRead PROTO (( AsnIoPtr, AsnTypePtr)); +NLM_EXTERN Boolean LIBCALL BundleSeqsAlignsAsnWrite PROTO (( BundleSeqsAlignsPtr , AsnIoPtr, AsnTypePtr)); + + #ifdef __cplusplus /* { */ } #endif diff --git a/object/objpub.c b/object/objpub.c index 62504eff..8d8fcf61 100644 --- a/object/objpub.c +++ b/object/objpub.c @@ -29,7 +29,7 @@ * * Version Creation Date: 4/1/91 * -* $Revision: 6.3 $ +* $Revision: 6.4 $ * * File Description: Object manager for module NCBI-Pub * @@ -41,6 +41,9 @@ * * * $Log: objpub.c,v $ +* Revision 6.4 2001/11/20 14:50:54 kans +* PubLabelUnique return immediately if PMID or MUID, already unique +* * Revision 6.3 2000/06/15 19:13:28 yaschenk * PubAsnWrite should not fail when pmid is stripped * @@ -1348,11 +1351,13 @@ NLM_EXTERN Int2 LIBCALL PubLabelUnique (ValNodePtr pub, CharPtr buf, Int2 buflen sprintf(tbuf, "NLM%ld", (long)(pub->data.intvalue)); diff = LabelCopy(buf, tbuf, buflen); buflen -= diff; + return (len - buflen); /* already unique */ break; case PUB_PMid: sprintf(tbuf, "PM%ld", (long)(pub->data.intvalue)); diff = LabelCopy(buf, tbuf, buflen); buflen -= diff; + return (len - buflen); /* already unique */ break; case PUB_Equiv: for (i = 0; i < 5; i++) diff --git a/object/objseq.c b/object/objseq.c index ec0fcced..15065b84 100644 --- a/object/objseq.c +++ b/object/objseq.c @@ -29,7 +29,7 @@ * * Version Creation Date: 4/1/91 * -* $Revision: 6.10 $ +* $Revision: 6.15 $ * * File Description: Object manager for module NCBI-Seq * @@ -91,6 +91,13 @@ static char *this_file = __FILE__; #include <objmgr.h> #include <sequtil.h> +static Boolean SeqDescrAsnWriteExtra (ValNodePtr anp, AsnIoPtr aip, AsnTypePtr orig, + Boolean anp_not_null); +static Boolean SeqAnnotSetAsnWriteExtra (SeqAnnotPtr sap, AsnIoPtr aip, AsnTypePtr set, + AsnTypePtr element, Boolean sap_not_null); +static Boolean SeqAnnotAsnWriteExtra (SeqAnnotPtr sap, AsnIoPtr aip, AsnTypePtr orig, + ValNodePtr extras); + /***************************************************************************** * * Bioseq ObjMgr Routines @@ -609,15 +616,28 @@ NLM_EXTERN BioseqPtr LIBCALL BioseqNew (void) *****************************************************************************/ NLM_EXTERN BioseqPtr LIBCALL BioseqFree (BioseqPtr bsp) { + Boolean top = FALSE; + if (bsp == NULL) return bsp; + if (bsp->idx.parentptr == NULL || bsp->idx.parenttype == OBJ_SEQSUB) { + if (bsp->seqentry != NULL) { + SeqMgrDeleteIndexesInRecord (bsp->seqentry); + top = TRUE; + } + } + if (! SeqMgrDelete(SM_BIOSEQ, (Pointer)bsp)) ErrPostEx(SEV_ERROR, 0,0, "BioseqFree: pointer not registered"); SeqIdSetFree(bsp->id); BioseqFreeComponents(bsp); + if (top) { + ObjMgrDeleteAllInRecord (); + } + return (BioseqPtr)MemFree(bsp); } @@ -730,6 +750,10 @@ NLM_EXTERN Boolean LIBCALL BioseqAsnWrite (BioseqPtr bsp, AsnIoPtr aip, AsnTypeP { if (! SeqDescrAsnWrite(bsp->descr, aip, BIOSEQ_descr)) goto erret; } + else + { + if (! SeqDescrExtraCheck(aip, BIOSEQ_descr)) goto erret; + } if (! BioseqInstAsnWrite(bsp, aip, BIOSEQ_inst)) goto erret; @@ -738,6 +762,10 @@ NLM_EXTERN Boolean LIBCALL BioseqAsnWrite (BioseqPtr bsp, AsnIoPtr aip, AsnTypeP if (! SeqAnnotSetAsnWrite(bsp->annot, aip, BIOSEQ_annot, BIOSEQ_annot_E)) goto erret; } + else /* look for extra features from SeqEntryAsnOut() */ + { + if (! SeqAnnotSetExtraCheck(aip, BIOSEQ_annot, BIOSEQ_annot_E)) goto erret; + } if (! AsnCloseStruct(aip, atp, (Pointer)bsp)) goto erret; retval = TRUE; @@ -1348,6 +1376,7 @@ NLM_EXTERN SeqDescPtr LIBCALL SeqDescFree (SeqDescPtr anp) return anp; } + /***************************************************************************** * * SeqDescrAsnWrite(anp, aip, atp) @@ -1357,9 +1386,38 @@ NLM_EXTERN SeqDescPtr LIBCALL SeqDescFree (SeqDescPtr anp) *****************************************************************************/ NLM_EXTERN Boolean LIBCALL SeqDescrAsnWrite (ValNodePtr anp, AsnIoPtr aip, AsnTypePtr orig) { + return SeqDescrAsnWriteExtra(anp, aip, orig, TRUE); +} + +/***************************************************************************** +* +* SeqDescrExtraCheck(aip, atp) +* atp is the current type (if identifier of a parent struct) +* if atp == NULL, then assumes it stands alone (SeqDescr ::=) +* checks for extra descriptors from SeqEntryAsnOut, when descr is NULL +* +*****************************************************************************/ +NLM_EXTERN Boolean LIBCALL SeqDescrExtraCheck (AsnIoPtr aip, AsnTypePtr orig) +{ + return SeqDescrAsnWriteExtra((ValNodePtr)NULL, aip, orig, FALSE); +} +/***************************************************************************** +* +* SeqDescrAsnWriteExtra(anp, aip, atp, anp_not_null) +* atp is the current type (if identifier of a parent struct) +* if atp == NULL, then assumes it stands alone (SeqDescr ::=) +* either anp or extras from SeqEntryAsnOut can be written +* if anp_not_null, means anp cannot be NULL +* +*****************************************************************************/ +static Boolean SeqDescrAsnWriteExtra (ValNodePtr anp, AsnIoPtr aip, AsnTypePtr orig, + Boolean anp_not_null) +{ AsnTypePtr atp; - ValNodePtr oldanp; - Boolean retval = FALSE; + ValNodePtr oldanp = NULL, tanp; + Boolean retval = FALSE, had_extra = FALSE, had_anp = FALSE; + AsnOptionPtr aopp; + ValNodePtr extras = NULL; if (! loaded) { @@ -1370,17 +1428,39 @@ NLM_EXTERN Boolean LIBCALL SeqDescrAsnWrite (ValNodePtr anp, AsnIoPtr aip, AsnTy if (aip == NULL) return FALSE; + if (anp != NULL) had_anp = TRUE; + aopp = AsnIoOptionGet(aip, OP_NCBIOBJSEQ, CHECK_EXTRA_DESC, NULL); + if (aopp != NULL) + { + had_extra = TRUE; + extras = (ValNodePtr)(aopp->data.ptrvalue); + } + else if ((anp == NULL) && (! anp_not_null)) /* nothing to write */ + return TRUE; + if (! ProgMon("Write SeqDescr")) return FALSE; atp = AsnLinkType(orig, SEQ_DESCR); /* link local tree */ if (atp == NULL) return FALSE; - if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; } + if (anp_not_null) + oldanp = anp; + else if (extras != NULL) + oldanp = (ValNodePtr)(extras->data.ptrvalue); + + if (oldanp == NULL) + { AsnNullValueMsg(aip, atp); goto erret; } - oldanp = anp; if (! AsnOpenStruct(aip, atp, (Pointer)oldanp)) goto erret; /* SET OF */ + while (extras != NULL) /* extras first */ + { + tanp = (ValNodePtr)(extras->data.ptrvalue); + if (! SeqDescAsnWrite(tanp, aip, SEQ_DESCR_E)) goto erret; + extras = extras->next; + } + while (anp != NULL) { if (! SeqDescAsnWrite (anp, aip, SEQ_DESCR_E)) goto erret; @@ -1389,6 +1469,10 @@ NLM_EXTERN Boolean LIBCALL SeqDescrAsnWrite (ValNodePtr anp, AsnIoPtr aip, AsnTy if (! AsnCloseStruct(aip, atp, oldanp)) goto erret; retval = TRUE; erret: + if (had_extra) + { + AsnIoOptionFree(aip, OP_NCBIOBJSEQ, CHECK_EXTRA_DESC); + } AsnUnlinkType(orig); /* unlink local tree */ return retval; } @@ -2662,6 +2746,25 @@ NLM_EXTERN SeqAnnotPtr LIBCALL SeqAnnotFree (SeqAnnotPtr sap) *****************************************************************************/ NLM_EXTERN Boolean LIBCALL SeqAnnotAsnWrite (SeqAnnotPtr sap, AsnIoPtr aip, AsnTypePtr orig) { + return SeqAnnotAsnWriteExtra(sap, aip, orig, (ValNodePtr)NULL); +} + +/***************************************************************************** +* +* SeqAnnotAsnWriteExtra(sap, aip, atp, extras) +* atp is the current type (if identifier of a parent struct) +* if atp == NULL, then assumes it stands alone (SeqAnnot ::=) +* if extras != NULL +* assumes sap has no data ptr +* assumes extras is a ValNode chain pointing to SeqFeats from +* SeqEntryAsnOut() +* else +* ignores extras and writes the SeqAnnot +* +*****************************************************************************/ +static Boolean SeqAnnotAsnWriteExtra (SeqAnnotPtr sap, AsnIoPtr aip, AsnTypePtr orig, + ValNodePtr extras) +{ DataVal av; AsnTypePtr atp; Boolean retval = FALSE; @@ -2715,7 +2818,15 @@ NLM_EXTERN Boolean LIBCALL SeqAnnotAsnWrite (SeqAnnotPtr sap, AsnIoPtr aip, AsnT switch (sap->type) { case 1: - if (! SeqFeatSetAsnWrite((SeqFeatPtr)sap->data, aip, SEQ_ANNOT_data_ftable, SEQ_ANNOT_data_ftable_E)) goto erret; + if (extras != NULL) /* from SeqEntryAsnOut */ + { + if (! SeqFeatSetAsnWriteExtra((SeqFeatPtr)sap->data, aip, SEQ_ANNOT_data_ftable, + SEQ_ANNOT_data_ftable_E, extras)) goto erret; + } + else + { + if (! SeqFeatSetAsnWrite((SeqFeatPtr)sap->data, aip, SEQ_ANNOT_data_ftable, SEQ_ANNOT_data_ftable_E)) goto erret; + } break; case 2: if (! SeqAlignSetAsnWrite((SeqAlignPtr)sap->data, aip, SEQ_ANNOT_data_align, SEQ_ANNOT_data_align_E)) goto erret; @@ -2865,9 +2976,38 @@ erret: *****************************************************************************/ NLM_EXTERN Boolean LIBCALL SeqAnnotSetAsnWrite (SeqAnnotPtr sap, AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element) { + return SeqAnnotSetAsnWriteExtra(sap, aip, set, element, TRUE); +} + +/***************************************************************************** +* +* SeqAnnotSetExtraCheck(aip, set, element) +* atp is the current type (if identifier of a parent struct) +* if atp == NULL, then assumes it stands alone (SeqAnnot ::=) +* called to check for extra features from SeqEntryAsnOut when sap is NULL +* +*****************************************************************************/ +NLM_EXTERN Boolean LIBCALL SeqAnnotSetExtraCheck (AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element) +{ + return SeqAnnotSetAsnWriteExtra((SeqAnnotPtr)NULL, aip, set, element, FALSE); +} + +/***************************************************************************** +* +* SeqAnnotSetAsnWriteExtra(sap, aip, set, element, sap_not_null) +* atp is the current type (if identifier of a parent struct) +* if atp == NULL, then assumes it stands alone (SeqAnnot ::=) +* +*****************************************************************************/ +static Boolean SeqAnnotSetAsnWriteExtra (SeqAnnotPtr sap, AsnIoPtr aip, AsnTypePtr set, + AsnTypePtr element, Boolean sap_not_null) +{ AsnTypePtr atp; - SeqAnnotPtr oldsap; - Boolean retval = FALSE; + SeqAnnotPtr oldsap = NULL, tsap = NULL; + Boolean retval = FALSE, had_sap = FALSE, had_extra = FALSE; + AsnOptionPtr aopp; + ValNodePtr extras = NULL; + SeqAnnot sa; if (! loaded) { @@ -2878,12 +3018,28 @@ NLM_EXTERN Boolean LIBCALL SeqAnnotSetAsnWrite (SeqAnnotPtr sap, AsnIoPtr aip, A if (aip == NULL) return FALSE; + aopp = AsnIoOptionGet(aip, OP_NCBIOBJSEQ, CHECK_EXTRA_FEAT, NULL); + if (aopp != NULL) + { + had_extra = TRUE; + extras = aopp->data.ptrvalue; + tsap = &sa; + MemSet(tsap, 0, sizeof(SeqAnnot)); + tsap->type = 1; /* feature table */ + } + else if ((sap == NULL) && (! sap_not_null)) /* nothing to write */ + return TRUE; + atp = AsnLinkType(element, SEQ_ANNOT); /* link local tree */ if (atp == NULL) return FALSE; - if (sap == NULL) { AsnNullValueMsg(aip, atp); goto erret; } + if (sap_not_null) + oldsap = sap; + else + oldsap = tsap; + + if (oldsap == NULL) { AsnNullValueMsg(aip, atp); goto erret; } - oldsap = sap; if (! AsnOpenStruct(aip, set, (Pointer)oldsap)) goto erret; while (sap != NULL) @@ -2891,9 +3047,17 @@ NLM_EXTERN Boolean LIBCALL SeqAnnotSetAsnWrite (SeqAnnotPtr sap, AsnIoPtr aip, A if (! SeqAnnotAsnWrite(sap, aip, atp)) goto erret; sap = sap->next; } + + if (tsap != NULL) + { + if (! SeqAnnotAsnWriteExtra(tsap, aip, atp, extras)) goto erret; + } + if (! AsnCloseStruct(aip, set, (Pointer)oldsap)) goto erret; retval = TRUE; erret: + if (had_extra) + AsnIoOptionFree(aip, OP_NCBIOBJSEQ, CHECK_EXTRA_FEAT); AsnUnlinkType(element); /* unlink local tree */ return retval; } @@ -4525,3 +4689,4 @@ erret: goto ret; } + diff --git a/object/objseq.h b/object/objseq.h index cfcce33c..2ca38054 100644 --- a/object/objseq.h +++ b/object/objseq.h @@ -29,7 +29,7 @@ * * Version Creation Date: 4/1/91 * -* $Revision: 6.4 $ +* $Revision: 6.5 $ * * File Description: Object manager interface for module NCBI-Seq * @@ -40,6 +40,9 @@ * * * $Log: objseq.h,v $ +* Revision 6.5 2001/10/02 21:47:54 kans +* added hooks for writing extra descriptors or features (JO) +* * Revision 6.4 1999/09/27 17:48:38 kans * using GatherIndex structure * @@ -284,6 +287,11 @@ NLM_EXTERN Int2 LIBCALL SeqAnnotLabel PROTO((SeqAnnotPtr sap, CharPtr buffer, In NLM_EXTERN Boolean LIBCALL SeqAnnotSetAsnWrite PROTO((SeqAnnotPtr sap, AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)); NLM_EXTERN SeqAnnotPtr LIBCALL SeqAnnotSetAsnRead PROTO((AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)); +/** SeqAnnotSetExtraCheck looks for extra Features from SeqEntryAsnOut + and adds them to the stream when the annot pointer is NULL +*********/ +NLM_EXTERN Boolean LIBCALL SeqAnnotSetExtraCheck (AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element); + /***************************************************************************** * @@ -467,6 +475,8 @@ typedef struct op_objseq { /* types for AsnIoOption OP_NCBIOBJSEQ */ #define BIOSEQ_CHECK_ID 1 /* match Op_objseq.sip */ +#define CHECK_EXTRA_DESC 2 /* used by SeqEntryAsnOut */ +#define CHECK_EXTRA_FEAT 3 /* used by SeqEntryAsnOut */ /***************************************************************************** * @@ -548,6 +558,11 @@ NLM_EXTERN SeqDescPtr LIBCALL SeqDescAsnRead PROTO((AsnIoPtr aip, AsnTypePtr atp NLM_EXTERN SeqDescPtr LIBCALL SeqDescFree PROTO((SeqDescPtr anp)); NLM_EXTERN Int2 LIBCALL SeqDescLabel PROTO((SeqDescPtr vnp, CharPtr buffer, Int2 buflen, Boolean content)); +/** SeqDescrExtraCheck looks for extra Descriptors from SeqEntryAsnOut + and adds them to the stream when the descr pointer is NULL +*********/ +NLM_EXTERN Boolean LIBCALL SeqDescrExtraCheck (AsnIoPtr aip, AsnTypePtr atp); + /***************************************************************************** * * Pubdesc, Numbering, MolInfo, BioSource types defined in objpubd.h @@ -567,3 +582,4 @@ NLM_EXTERN Int2 LIBCALL SeqDescLabel PROTO((SeqDescPtr vnp, CharPtr buffer, Int2 #endif + diff --git a/object/objsset.c b/object/objsset.c index e12e4500..9d2f5611 100644 --- a/object/objsset.c +++ b/object/objsset.c @@ -29,7 +29,7 @@ * * Version Creation Date: 4/1/91 * -* $Revision: 6.1 $ +* $Revision: 6.4 $ * * File Description: Object manager for module NCBI-Seqset * @@ -41,6 +41,15 @@ * * * $Log: objsset.c,v $ +* Revision 6.4 2001/11/30 12:20:18 kans +* ObjMgrDeleteAllInRecord called when freeing top bsp or bssp +* +* Revision 6.3 2001/11/16 19:31:09 kans +* BioseqFree and BioseqSetFree on top-level object call SeqMgrDeleteIndexesInRecord +* +* Revision 6.2 2001/08/07 17:22:27 kans +* added third party annotation SeqIDs to FindBestBioseqLabel +* * Revision 6.1 1998/08/24 18:28:11 kans * removed solaris -v -fd warnings * @@ -143,6 +152,10 @@ static void FindBestBioseqLabel (SeqEntryPtr sep, Pointer data, Int4 index, Int2 case SEQID_GENBANK: case SEQID_EMBL: case SEQID_DDBJ: + case SEQID_OTHER: + case SEQID_TPG: + case SEQID_TPE: + case SEQID_TPD: has_gb = TRUE; case SEQID_PIR: case SEQID_SWISSPROT: @@ -378,14 +391,27 @@ NLM_EXTERN BioseqSetPtr LIBCALL BioseqSetNew (void) *****************************************************************************/ NLM_EXTERN BioseqSetPtr LIBCALL BioseqSetFree (BioseqSetPtr bsp) { + Boolean top = FALSE; + if (bsp == NULL) return bsp; + if (bsp->idx.parentptr == NULL || bsp->idx.parenttype == OBJ_SEQSUB) { + if (bsp->seqentry != NULL) { + SeqMgrDeleteIndexesInRecord (bsp->seqentry); + top = TRUE; + } + } + if (! SeqMgrDelete(SM_BIOSEQSET, (Pointer)bsp)) ErrPostEx(SEV_ERROR, 0,0, "BioseqSetFree: pointer not registered"); BioseqSetFreeComponents(bsp, TRUE); + if (top) { + ObjMgrDeleteAllInRecord (); + } + return (BioseqSetPtr)MemFree(bsp); } |