Exemple #1
0
void LIBCALL  RewindPost (PostingPtr pst)

{
  if (pst != NULL) {
    if (pst->uids != NULL) {
      BSSeek (pst->uids, 0L, 0);
    }
    pst->count = 0;
    pst->index = 0;
  }
}
Exemple #2
0
DocUid LIBCALL MMDBEvalPDB(CharPtr str)
{
  Entrez2BooleanReplyPtr  e2br;
  Entrez2IdListPtr        e2id;
  Entrez2RequestPtr       e2rq;
  Entrez2ReplyPtr         e2ry;
  Char                    tmp [61];
  Uint4                   uid = 0;

  if (str == NULL) return 0;

  StringNCpy_0 (tmp, str, sizeof (tmp) - 10);
  if (StringStr (tmp, "[ACCN]") == NULL) {
    StringCat (tmp, " [ACCN]");
  }

  e2rq = EntrezCreateBooleanRequest (TRUE, FALSE, "Structure", tmp,
                                     0, 0, NULL, 1, 0);
  if (e2rq == NULL) return 0;
  e2ry = EntrezSynchronousQuery (e2rq);
  e2rq = Entrez2RequestFree (e2rq);
  if (e2ry == NULL) return 0;
  e2br = EntrezExtractBooleanReply (e2ry);
  if (e2br == NULL) return 0;

  if (e2br->count > 0) {
    e2id = e2br->uids;
    if (e2id != NULL && e2id->num > 0 && e2id->uids != NULL) {
      BSSeek (e2id->uids, 0, SEEK_SET);
      uid = Nlm_BSGetUint4 (e2id->uids);
    }
  }

  Entrez2BooleanReplyFree (e2br);

  return uid;
   /*
   LinkSetPtr plsLink = NULL;
   DocUid duUID = 0;
 
   if ((!str)) return (DocUid) 0;
   plsLink = EntrezTLEvalString(str, (DocType) TYP_ST,  
			  (DocField) FLD_ACCN,  NULL, NULL);  
  
   if (plsLink != NULL && plsLink->num > 0 && plsLink->uids != NULL)
	{
	   duUID = plsLink->uids[0];
        }
   LinkSetFree(plsLink); 

   return duUID;
   */
}
Exemple #3
0
/*****************************************************************************
*
*   ConvertToIupac(atp, ptr, len)
*
*****************************************************************************/
static ByteStorePtr ConvertToIupac (AsnTypePtr atp, ByteStorePtr bsp, Int4 seqlen)

{
    static Char twobit[4] = {'A','C','G','T'};
    static Char fourbit[16] = { '-','A','C','M','G','R','S','V','T','W','Y',
        'H','K','D','B','N'};
    ByteStorePtr bsnew;
    Int2 bitctr;
    Uint1 base, b;

    if ((atp == SEQ_DATA_iupacna) || (atp == SEQ_DATA_iupacaa))
        return bsp;              /* all set */

    bsnew = BSNew((Uint4)seqlen);
    if (bsnew == NULL)
        return NULL;

    BSSeek(bsp, 0, SEEK_SET);
    BSSeek(bsnew, 0, SEEK_SET);
    
    if (atp == SEQ_DATA_ncbi2na)
    {
        bitctr = 0;
        while (seqlen)
        {
            if (! bitctr)
            {
                b = (Uint1) BSGetByte(bsp);
                bitctr = 4;
            }
            base = b & (Uint1) 192;
            base >>= 6;
            b <<= 2;
            BSPutByte(bsnew, (Uint1)twobit[base]);
            bitctr--;
            seqlen--;
        }
    }
Exemple #4
0
static void FindBlastMrna (SeqAnnotPtr sap, Int4Ptr uidlist, Int4 count)

{
  SeqAnnotPtr             annot;
  Entrez2BooleanReplyPtr  e2br;
  Entrez2IdListPtr        e2id;
  Entrez2RequestPtr       e2rq;
  Entrez2ReplyPtr         e2ry;
  Int4                    i;
  Int4Ptr                 gilist;
  E2ReplyPtr              reply;

  e2rq = EntrezCreateBooleanRequest (TRUE, FALSE, "nucleotide", NULL, 0, 0, NULL, 0, 0);
  EntrezAddToBooleanRequest (e2rq, "biomol_mrna [PROP]", 0, NULL, NULL, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
  EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_AND, NULL, NULL, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
  EntrezAddToBooleanRequest (e2rq, NULL, 0, NULL, NULL, NULL, 0, count, uidlist, NULL, TRUE, TRUE);
  e2ry = EntrezSynchronousQuery (e2rq);
  e2rq = Entrez2RequestFree (e2rq);
  if (e2ry == NULL) return;
  reply = e2ry->reply;
  if (reply == NULL || reply->choice != E2Reply_eval_boolean) return;
  e2br = EntrezExtractBooleanReply (e2ry);
  if (e2br == NULL) return;
  count = e2br->count;
  if (count < 1) return;
  e2id = e2br->uids;
  if (e2id == NULL || e2id->num < 1 || e2id->uids == NULL) return;

  gilist = (Int4Ptr) MemNew (sizeof (Int4) * (e2id->num + 1));
  if (gilist != NULL) {

    BSSeek (e2id->uids, 0, SEEK_SET);
    for (i = 0; i < e2id->num; i++) {
      gilist [i] = Nlm_BSGetUint4 (e2id->uids);
    }
    HeapSort (gilist, e2id->num, sizeof (Int4), SortByInt4);

    annot = ExtractBlastMrna ((SeqAlignPtr) sap->data, (Pointer PNTR) &(sap->data), gilist, e2id->num);
    if (annot != NULL) {
      annot->next = sap->next;
      sap->next = annot;
    }

    MemFree (gilist);
  }

  Entrez2BooleanReplyFree (e2br);
}
Exemple #5
0
static FloatHi GetFloatHi (Pointer data, Uint1 type, Int4 pos)
{
  FloatHi        fval;
  ByteStorePtr   bp;

  switch (type)
  {
   default:
   case 1:
    fval = (FloatHi) (((FloatHiPtr) data)[pos]);
    break;
   case 2:
    fval = (FloatHi) (((Int4Ptr) data)[pos]);
    break;
   case 3:
    bp = (ByteStorePtr) data;
    BSSeek (bp, pos, SEEK_SET);
    fval = (FloatHi) BSGetByte (bp);
    break;
  }
  return fval;
}
Exemple #6
0
LocalLinkSetPtr LIBCALL BSPtoLSP(ByteStorePtr bsp)
 {
	LocalLinkSetPtr lsp;

     if (bsp == NULL)
     {
         ErrPostEx(SEV_ERROR,0,0, "Invalid parameter.");
         return NULL;
     }
     if(BSLen(bsp) == 0)
     {
         ErrPostEx(SEV_ERROR,0,0, "Byte store contains no data.");
         return NULL;
     }
     lsp = LocalLinkSetNew();
	 if(lsp == NULL)
	 {
	   ErrPostEx(SEV_ERROR,0,0, "LocalLinkSetNew failed.");
	   return NULL;
	
	 }	
	
     lsp->num = BSLen(bsp) / sizeof(DocUid);
     if ((lsp->uids = MemNew(BSLen(bsp))) == NULL)
     {
         /* platforms which can't allocate this are out of luck */
         ErrPostEx(SEV_ERROR,0,0, "Cannot allocate memory for LinkSet");
         lsp = LocalLinkSetFree(lsp);
         return NULL;
     }
     else
     {
        BSSeek (bsp, 0L, 0);
        BSRead (bsp, lsp->uids, lsp->num * sizeof (DocUid));
     }
    return lsp;
}
Exemple #7
0
static void DoGraphs (BioseqPtr bsp, Pointer userdata)

{
  Byte          bases [400];
  ByteStorePtr  bs;
  Int2          ctr, i, j, val;
  Int4          curroffset = 0, gphlen = 0, seqlen = 0, slplen,
                bslen, min = INT4_MAX, max = INT4_MIN,
                NsWithScore, ACGTsWithoutScore;
  DeltaSeqPtr   dsp;
  Uint2         entityID, olditemid = 0, olditemtype = 0,
                numdsp = 0, numsgp = 0;
  GphItemPtr    gip;
  ValNodePtr    head, vnp;
  Boolean       noErrors = TRUE;
  Uint1         residue;
  ScanDataPtr   sdp;
  SeqGraphPtr   sgp;
  SeqIntPtr     sintp;
  SeqLocPtr     slocp;
  SeqLitPtr     slp;
  SeqPortPtr    spp;
  Char          str [128];

  if (bsp == NULL) return;
  if (! ISA_na (bsp->mol)) return;
  if (SeqMgrGetParentOfPart (bsp, NULL) != NULL) return;

  sdp = (ScanDataPtr) userdata;

  entityID = ObjMgrGetEntityIDForPointer (bsp);
  head = GetSeqGraphsOnBioseq (entityID, bsp);
  if (head == NULL) return;

  for (vnp = head; vnp != NULL; vnp = vnp->next) {
    gip = (GphItemPtr) vnp->data.ptrvalue;
    if (gip == NULL) continue;
    sgp = gip->sgp;
    min = MIN ((Int4) min, (Int4) sgp->min.intvalue);
    max = MAX ((Int4) max, (Int4) sgp->max.intvalue);

    if (sgp->min.intvalue < 0 || sgp->min.intvalue > 100) {
      sprintf (str, "Graph min (%ld) out of range", (long) sgp->min.intvalue);
      PrintGraphMessage (bsp, sdp, str, NULL);
      noErrors = FALSE;
    }

    if (sgp->max.intvalue < 0 || sgp->max.intvalue > 100) {
      sprintf (str, "Graph max (%ld) out of range", (long) sgp->max.intvalue);
      PrintGraphMessage (bsp, sdp, str, NULL);
      noErrors = FALSE;
    }

    gphlen += sgp->numval;
    bs = (ByteStorePtr) sgp->values;
    if (bs != NULL) {
      bslen = BSLen (bs);
      if (sgp->numval != bslen) {
        sprintf (str, "SeqGraph (%ld) and ByteStore (%ld) length mismatch", (long) sgp->numval, (long) bslen);
        PrintGraphMessage (bsp, sdp, str, NULL);
        noErrors = FALSE;
      }
    }
  }

  if (bsp->repr == Seq_repr_raw) {
    seqlen = bsp->length;
  } else if (bsp->repr == Seq_repr_delta) {
    for (dsp = (DeltaSeqPtr) (bsp->seq_ext); dsp != NULL; dsp = dsp->next) {
      switch (dsp->choice) {
        case 1 :
          slocp = (SeqLocPtr) dsp->data.ptrvalue;
          if (slocp == NULL) break;
          if (slocp->choice != SEQLOC_NULL) {
            seqlen += SeqLocLen (slocp);
          }
          break;
        case 2 :
          slp = (SeqLitPtr) dsp->data.ptrvalue;
          if (slp == NULL || slp->seq_data == NULL) break;
          seqlen += slp->length;
          break;
        default :
          break;
      }
    }
  }

  if (seqlen != gphlen) {
    sprintf (str, "SeqGraph (%ld) and Bioseq (%ld) length mismatch", (long) gphlen, (long) seqlen);
    PrintGraphMessage (bsp, sdp, str, NULL);
    noErrors = FALSE;
  }

  if (bsp->repr == Seq_repr_delta) {
    for (dsp = (DeltaSeqPtr) (bsp->seq_ext), vnp = head;
         dsp != NULL && vnp != NULL; dsp = dsp->next) {
      gip = (GphItemPtr) vnp->data.ptrvalue;
      if (gip == NULL) continue;
      sgp = gip->sgp;
      if (sgp == NULL) continue;
      switch (dsp->choice) {
        case 1 :
          slocp = (SeqLocPtr) dsp->data.ptrvalue;
          if (slocp != NULL && slocp->choice != SEQLOC_NULL) {
            slplen = SeqLocLen (slocp);
            curroffset += slplen;
            if (sgp->numval != slplen) {
              sprintf (str, "SeqGraph (%ld) and SeqLoc (%ld) length mismatch", (long) sgp->numval, (long) slplen);
              PrintGraphMessage (bsp, sdp, str, NULL);
              noErrors = FALSE;
            }
            numdsp++;
            if (vnp != NULL) {
              vnp = vnp->next;
              numsgp++;
            }
          }
          break;
        case 2 :
          slp = (SeqLitPtr) dsp->data.ptrvalue;
          if (slp != NULL && slp->seq_data != NULL) {
            if (sgp->numval != slp->length) {
              sprintf (str, "SeqGraph (%ld) and SeqLit (%ld) length mismatch", (long) sgp->numval, (long) slp->length);
              PrintGraphMessage (bsp, sdp, str, NULL);
              noErrors = FALSE;
            }
            slocp = sgp->loc;
            if (slocp != NULL && slocp->choice == SEQLOC_INT) {
              sintp = (SeqIntPtr) slocp->data.ptrvalue;
              if (sintp != NULL) {
                if (sintp->from != curroffset) {
                  sprintf (str, "SeqGraph (%ld) and SeqLit (%ld) start do not coincide", (long) sintp->from, (long) curroffset);
                  PrintGraphMessage (bsp, sdp, str, NULL);
                  noErrors = FALSE;
                }
                if (sintp->to != slp->length + curroffset - 1) {
                  sprintf (str, "SeqGraph (%ld) and SeqLit (%ld) stop do not coincide", (long) sintp->to, (long) (slp->length + curroffset - 1));
                  PrintGraphMessage (bsp, sdp, str, NULL);
                  noErrors = FALSE;
                }
              }
            }
            numdsp++;
            if (vnp != NULL) {
              vnp = vnp->next;
              numsgp++;
            }
          }
          if (slp != NULL) {
            curroffset += slp->length;
          }
          break;
        default :
          break;
      }
    }
    if (numdsp != numsgp) {
      sprintf (str, "Different number of SeqGraph (%d) and SeqLit (%d) components", (int) numsgp, (int) numdsp);
      PrintGraphMessage (bsp, sdp, str, NULL);
      noErrors = FALSE;
    }
  }

  for (vnp = head; vnp != NULL; vnp = vnp->next) {
    gip = (GphItemPtr) vnp->data.ptrvalue;
    if (gip == NULL) continue;
    sgp = gip->sgp;
    if (sgp == NULL) continue;
    spp = SeqPortNewByLoc (sgp->loc, Seq_code_iupacna);
    if (spp == NULL) continue;
    slplen = SeqLocLen (sgp->loc);
    if (bsp->repr == Seq_repr_delta || bsp->repr == Seq_repr_virtual) {
      SeqPortSet_do_virtual (spp, TRUE);
    }

    bs = (ByteStorePtr) sgp->values;
    BSSeek (bs, 0, SEEK_SET);
    j = 0;
    val = 0;

    ctr = SeqPortRead (spp, bases, sizeof (bases));
    i = 0;
    residue = (Uint1) bases [i];

    NsWithScore = 0;
    ACGTsWithoutScore = 0;

    while (residue != SEQPORT_EOF && j < sgp->numval) {
      if (IS_residue (residue)) {
        val = (Int2) BSGetByte (bs);
        j++;
        switch (residue) {
          case 'A' :
          case 'C' :
          case 'G' :
          case 'T' :
            if (val == 0) {
              ACGTsWithoutScore++;
            }
            break;
          case 'N' :
            if (val > 0) {
              NsWithScore++;
            }
            break;
          default :
            break;
        }
      }
      i++;
      if (i >= ctr) {
        i = 0;
        ctr = SeqPortRead (spp, bases, sizeof (bases));
        if (ctr < 0) {
          bases [0] = -ctr;
        } else if (ctr < 1) {
          bases [0] = SEQPORT_EOF;
        }
      }
      residue = (Uint1) bases [i];
    }

    if (ACGTsWithoutScore > 0) {
      sprintf (str, "%ld ACGT bases have zero score value", (long) ACGTsWithoutScore);
      PrintGraphMessage (bsp, sdp, str, NULL);
      noErrors = FALSE;
    }
    if (NsWithScore > 0) {
      sprintf (str, "%ld N bases have positive score value", (long) NsWithScore);
      PrintGraphMessage (bsp, sdp, str, NULL);
      noErrors = FALSE;
    }

    SeqPortFree (spp);
  }

  if (noErrors) {
    PrintGraphMessage (bsp, sdp, "Quality scores okay", NULL);
  }

  ValNodeFreeData (head);
}
Exemple #8
0
NLM_EXTERN Int4 print_protein_for_cds(SeqFeatPtr sfp, CharPtr buf, SeqLocPtr loc, Boolean reverse_minus)
{
	CdRegionPtr crp;
	Int4 frame_offset, start_offset;
	Uint1 f_strand;
	Boolean reverse;
	Int4 cd_len;
	GatherRange gr;
	Int2 p_pos, buf_len;
	Int4 a_left, a_right;
	Int4 aa, val;
	SeqLocPtr slp;
	SeqPortPtr spp;
	ByteStorePtr p_data;
	Int4 end_pos, start_pos = -1;
	Uint1 residue;
	Boolean seal_ends = FALSE;
	Boolean reverse_order;

	if(sfp == NULL || sfp->data.choice != 3)
		return -1;
	if(buf == NULL || loc == NULL)
		return -1;
	crp = sfp->data.value.ptrvalue;
	if(crp == NULL)
		return -1;

	if(buf[0] == '\0')
		seal_ends = TRUE;
	spp = NULL;
	p_data = NULL;
	if(sfp->product !=NULL && !IS_BOGO_Product(sfp->ext))
	{
		spp = SeqPortNewByLoc(sfp->product, Seq_code_ncbieaa);
		if(spp !=NULL)
		{
    			SeqPortSeek(spp, 0, SEEK_SET);
			end_pos = spp->totlen-1;
		}
	}
	if(spp == NULL)
	{
		p_data = ProteinFromCdRegion(sfp, TRUE);
		/* p_data = ProteinFromCdRegion(sfp, FALSE); */
		if(p_data !=NULL)
		{
			BSSeek(p_data, 0, SEEK_SET);
			end_pos = BSLen(p_data)-1;
		}
	}

	if(spp == NULL && p_data == NULL)
		return -1;

	if(crp->frame == 0)
		frame_offset = 0;
	else
		frame_offset = (Int4)crp->frame-1;
	start_offset = frame_offset;

	f_strand = SeqLocStrand(sfp->location);
	reverse = ck_reverse(f_strand, SeqLocStrand(loc));
	/*if reverse == TRUE, the translated protein is written backwards*/
	if(reverse && reverse_minus)
		reverse_order = TRUE;
	else
		reverse_order = FALSE;
	
	slp = NULL;
	cd_len = 0;
	aa = 0;

        buf_len = SeqLocLen(loc);

	if(reverse_order)
	{
		p_pos = buf_len -1;
		if(seal_ends)
		{
			buf[p_pos+1] = '\0';
			seal_ends = FALSE;
		}
	}
	else
		p_pos = 0;

	while((slp = SeqLocFindNext(sfp->location, slp))!=NULL)
	{
	   if(SeqLocOffset(loc, slp, &gr, 0))
	   {
		if(reverse_order)
		{
			if(gr.right < p_pos)
				p_pos = (Int2)(gr.right);
		}
		else
		{
			if(p_pos < gr.left)
				p_pos = (Int2)(gr.left);
		}
		SeqLocOffset(slp, loc, &gr, 0);
		
		a_left = gr.left + cd_len;
		a_right = gr.right + cd_len;
		/* if(reverse_order)
		{
			temp = a_right;
			a_right = -a_left;
			a_left = -temp;
		} */
		for(; a_left<=a_right; ++a_left)
		{
			val = ABS(a_left) - start_offset;
			aa = val/3;
			if(aa < 0 || aa > end_pos)/*stop & partial codon*/
			{
				buf[p_pos] = '^';
			}
			else
			{
				if(val%3==1)/*label aa in the middle of 3-bp codon*/
				{
					if(start_pos == -1)
						start_pos = aa;
					if(spp !=NULL)
					{
						SeqPortSeek(spp, aa, SEEK_SET);
						residue = SeqPortGetResidue(spp); 
					}
					else
					{
						BSSeek(p_data, aa, SEEK_SET);
						residue = (Uint1)BSGetByte(p_data);
					}
					if(IS_ALPHA(residue) || residue == '*' || residue == '-')
					
						buf[p_pos] = residue;
					else
						buf[p_pos] = '?';
				}
				else
					buf[p_pos] = ' ';
			}
			if(reverse_order)
				-- p_pos;
			else {
				++p_pos;
                                if (p_pos > buf_len)
                                   break;
                        }
		}
	     }
	     cd_len += SeqLocLen(slp);
	     /*frame_offset = (cd_len - start_offset)%3;
	     if(frame_offset > 0)
		--frame_offset;*/
		
	}

	if(spp != NULL)
		SeqPortFree(spp);
	if(p_data != NULL)
		BSFree(p_data);

	if(p_pos  == 0)	/*all the residues are introns*/
	{
		if(seal_ends)
		{
			end_pos = buf_len;
			MemSet((Pointer)buf, '~', (size_t)(end_pos) * sizeof(Char));
			buf[end_pos] = '\0';
		}
	}
	else
	{
		if(seal_ends)
		{
			buf[p_pos] = '\0';
		}
		if(start_pos == -1)
			start_pos = aa;
	}

	return start_pos;
}
Exemple #9
0
static Int4 BEGetUidsFromQuery(CharPtr query, Uint4Ptr PNTR uids, 
                               Boolean is_na, Boolean count_only)
{
    Entrez2ReplyPtr e2ry;
    Entrez2RequestPtr  e2rq;
    E2ReplyPtr e2rp;
    Int4 count = 0, i;
    Entrez2BooleanReplyPtr e2br;
    Entrez2IdListPtr e2idlist;
    
    *uids = NULL;
    
    EntrezSetProgramName ("BLAST API");
    /* EntrezSetServer ("www.ncbi.nlm.nih.gov", 80, 
                     "/entrez/utils/entrez2server.fcgi"); */
    
    e2rq = EntrezCreateBooleanRequest (!count_only, FALSE, 
                                       is_na? "Nucleotide" : "Protein", 
                                       query, 0, 0, NULL, 0, 0);
    
    e2ry = EntrezSynchronousQuery (e2rq);
    
    if (e2ry == NULL) {
        ErrPostEx(SEV_ERROR, 0, 0, 
                  "NULL returned from EntrezSynchronousQuery()");
        return -1;
    }

    if((e2rp = e2ry->reply) == NULL) {
        ErrPostEx(SEV_ERROR, 0, 0, "Invalid ASN.1: E2ReplyPtr==NULL");
        return -1;
    }
    
    switch(e2rp->choice) {
        
    case E2Reply_error:
        ErrPostEx(SEV_ERROR, 0, 0, (CharPtr) e2rp->data.ptrvalue);
        count = -1;
        break;
    case E2Reply_eval_boolean:
        e2br = (Entrez2BooleanReplyPtr) e2rp->data.ptrvalue;
        count = e2br->count;
        if((e2idlist = e2br->uids) != NULL) {
            count = e2idlist->num;
            *uids = MemNew(sizeof(Int4)*count);
            BSSeek((ByteStorePtr) e2idlist->uids, 0, SEEK_SET);
            BSRead((ByteStorePtr) e2idlist->uids, *uids, sizeof(Int4)*count);

        }
        break;
    default:
        ErrPostEx(SEV_ERROR, 0, 0, "Invalid reply type from the server: %d", e2rp->choice);
        count = -1;
        break;
        
    }

    Entrez2ReplyFree(e2ry);
    Entrez2RequestFree(e2rq);

    return count;
}
Exemple #10
0
static void DoQuery (
  FILE *fp,
  FILE *dfp,
  XtraPtr extra,
  Boolean get_var,
  Boolean do_nuc,
  Boolean do_prot
)

{
  Entrez2BooleanReplyPtr  e2br;
  Entrez2IdListPtr        e2lp;
  Entrez2RequestPtr       e2rq;
  Entrez2ReplyPtr         e2ry;
  Int4                    flags = 0;
  Int4                    i;
  Char                    line [256];
  E2ReplyPtr              reply;
  SeqEntryPtr             sep;
  CharPtr                 str;
  Uint4                   uid;

  if (get_var) {
    flags = 1;
  }

  e2rq = EntrezCreateBooleanRequest (TRUE, FALSE, "Nucleotide", NULL, 0, 0, NULL, 0, 0);
  if (e2rq == NULL) return;

  EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_LEFT_PAREN, NULL, NULL, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
  EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_LEFT_PAREN, NULL, NULL, NULL, 0, 0, NULL, NULL, TRUE, TRUE);

  str = ReadALine (line, sizeof (line), fp);
  if (! StringHasNoText (str)) {
    EntrezAddToBooleanRequest (e2rq, NULL, 0, "ACCN", str, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
  }

  while (str != NULL) {
    if (! StringHasNoText (str)) {
      EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_OR, NULL, NULL, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
      EntrezAddToBooleanRequest (e2rq, NULL, 0, "ACCN", str, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
    }
    str = ReadALine (line, sizeof (line), fp);
  }

  EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_RIGHT_PAREN, NULL, NULL, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
  EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_AND, NULL, NULL, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
  EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_LEFT_PAREN, NULL, NULL, NULL, 0, 0, NULL, NULL, TRUE, TRUE);

  str = ReadALine (line, sizeof (line), dfp);
  if (! StringHasNoText (str)) {
    EntrezAddToBooleanRequest (e2rq, NULL, 0, "MDAT", str, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
  }

  while (str != NULL) {
    if (! StringHasNoText (str)) {
      EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_OR, NULL, NULL, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
      EntrezAddToBooleanRequest (e2rq, NULL, 0, "MDAT", str, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
    }
    str = ReadALine (line, sizeof (line), dfp);
  }

  EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_RIGHT_PAREN, NULL, NULL, NULL, 0, 0, NULL, NULL, TRUE, TRUE);
  EntrezAddToBooleanRequest (e2rq, NULL, ENTREZ_OP_RIGHT_PAREN, NULL, NULL, NULL, 0, 0, NULL, NULL, TRUE, TRUE);

  e2ry = EntrezSynchronousQuery (e2rq);
  e2rq = Entrez2RequestFree (e2rq);

  if (e2ry == NULL) return;
  reply = e2ry->reply;
  if (reply == NULL || reply->choice != E2Reply_eval_boolean) return;
  e2br = EntrezExtractBooleanReply (e2ry);
  if (e2br == NULL) return;

  e2lp = e2br->uids;
  if (e2lp != NULL) {
    BSSeek (e2lp->uids, 0, SEEK_SET);
    for (i = 0; i < e2lp->num; i++) {
      uid = Nlm_BSGetUint4 (e2lp->uids);
      if (uid < 1) continue;

      sep = PubSeqSynchronousQuery (uid, 0, flags);
      if (sep == NULL) continue;

      if (do_nuc) {
        DoSeqEntryToGnbk (sep, GENBANK_FMT, extra);
      }
      if (do_prot) {
        DoSeqEntryToGnbk (sep, GENPEPT_FMT, extra);
      }

      SeqEntryFree (sep);
    }
  }

  Entrez2BooleanReplyFree (e2br);
}