Exemplo n.º 1
0
NLM_EXTERN void print_label(FILE *fp, CharPtr label, Int4 pos, Uint1 strand, Boolean extra_space)
{
	Int4 len;
	Char symbol;
	Char temp[100];

	len = 0;
	if(label)
	{
		len = StringLen(label);
		fprintf(fp, "%s", label);
	}
	for(; len<B_SPACE; ++len)
		fprintf(fp, " ");

	symbol = ' ';
	if(strand == Seq_strand_plus)
		symbol = '>';
	if(strand == Seq_strand_minus)
		symbol = '<';
	fprintf(fp, " %c ", symbol);

	len = 0;
	if(pos != -1)
	{
		sprintf(temp, "%ld", (long) pos);
		len = StringLen(temp);
		fprintf(fp, "%s", temp);
	}

	if(extra_space)	/*for partial codon*/
		++len;
	for(; len <POS_SPACE; ++len)
		fprintf(fp, " ");
}
Exemplo n.º 2
0
int64_t decode(void *buffer, size_t size, int64_t sum)
{
    unsigned int i;
    C(table_t) foobarcontainer;
    FooBar(vec_t) list;
    FooBar(table_t) foobar;
    Bar(struct_t) bar;
    Foo(struct_t) foo;

    foobarcontainer = C(as_root(buffer));
    sum += C(initialized(foobarcontainer));
    sum += StringLen(C(location(foobarcontainer)));
    sum += C(fruit(foobarcontainer));
    list = C(list(foobarcontainer));
    for (i = 0; i < FooBar(vec_len(list)); ++i) {
        foobar = FooBar(vec_at(list, i));
        sum += StringLen(FooBar(name(foobar)));
        sum += FooBar(postfix(foobar));
        sum += (int64_t)FooBar(rating(foobar));
        bar = FooBar(sibling(foobar));
        sum += (int64_t)Bar(ratio(bar));
        sum += Bar(size(bar));
        sum += Bar(time(bar));
        foo = Bar(parent(bar));
        sum += Foo(count(foo));
        sum += Foo(id(foo));
        sum += Foo(length(foo));
        sum += Foo(prefix(foo));
    }
    return sum + 2 * sum;
}
Exemplo n.º 3
0
/*****************************************************************************
*
*   StdAuthListNamesPrint(dvp)
*   	prints just Auth-list.names to a string
*
*****************************************************************************/
NLM_EXTERN CharPtr StdAuthListNamesPrint(DataValPtr dvp)
{
	AuthListPtr alp;
	Boolean 	first = TRUE;
	ValNodePtr   vnp;
	PersonIdPtr  pip;
	AuthorPtr    ap;
	ByteStorePtr bsp;
	CharPtr str;
	Char buf[60];

	if (dvp == NULL) return NULL;
	alp = (AuthListPtr)(dvp->ptrvalue);
	if (alp == NULL) return NULL;

	bsp = BSNew(80);

	for (vnp = alp->names; vnp != NULL; vnp = vnp->next)
	{
		if (! first)     /* separators for names after first one */
		{
			if (vnp->next != NULL)
				BSPutByte(bsp, (Int2)',');
			else
			{
				BSPutByte(bsp, (Int2)' ');
				BSPutByte(bsp, (Int2)'&');
			}
			BSPutByte(bsp, (Int2)' ');
		}

		first = FALSE;
		if (alp->choice == 3 || alp->choice == 2)  /* ml or str */
		{
			BSWrite(bsp, vnp->data.ptrvalue, (Int4)(StringLen((CharPtr)(vnp->data.ptrvalue))));
		}
		else if (alp->choice == 1)   /* std */
		{
			ap = (AuthorPtr) (vnp->data.ptrvalue);
			if (ap != NULL)
			{
				pip = ap->name;
				PersonIdPrint(pip, buf);
				BSWrite(bsp, buf, (Int4)StringLen(buf));
			}
			else
				BSPutByte(bsp, (Int2)'?');
		}
	}

	str = BSMerge(bsp, NULL);
	BSFree(bsp);
	return str;
}
Exemplo n.º 4
0
static Boolean SaveSetsInOneSelectedSet (GatherObjectPtr gop)

{
  SetSavePtr      ssp;
  SelStructPtr    sel;
  BioseqSetPtr    bssp;
  CharPtr         filename, file_fmt = "%s_%d.sqn";
  SeqEntryPtr     sep;
  AsnIoPtr        aip;
#ifdef WIN_MAC
  FILE *fp;
#endif

  if (gop == NULL || gop->dataptr == NULL || gop->itemtype != OBJ_BIOSEQSET) return TRUE;
  ssp = (SetSavePtr) gop->userdata;
  if (ssp == NULL || StringHasNoText (ssp->file_base)) return TRUE;

  sel = ssp->sel;
  while (sel != NULL 
         && (sel->entityID != gop->entityID 
             || sel->itemtype != gop->itemtype 
             || sel->itemID != gop->itemID))
  {
    sel = sel->next;
  }

  if (sel == NULL) return TRUE;

  bssp = gop->dataptr;
   
  filename = (CharPtr) MemNew (sizeof (Char) + (StringLen (ssp->file_base) + StringLen (file_fmt) + 15));
  for (sep = bssp->seq_set; sep != NULL; sep = sep->next) {
    sprintf (filename, file_fmt, ssp->file_base, ssp->file_num);
    ssp->file_num++;
#ifdef WIN_MAC
        fp = FileOpen (filename, "r");
        if (fp != NULL) {
            FileClose (fp);
        } else {
            FileCreate (filename, "TEXT", "ttxt");
        }
#endif

        aip = AsnIoOpen(filename, "w");
        SeqEntryAsnWrite (sep, aip, NULL);
    AsnIoClose (aip);
  }
  filename = MemFree (filename);
  return TRUE;
}
Exemplo n.º 5
0
static Boolean UpdateContigReadId (TContigReadPtr read, SeqIdReplaceListPtr pair_list, Boolean no_lookup, Boolean is_srr, char *has_errors)
{
  SeqIdPairPtr pair;
  SeqIdPtr     sip_find;
  Char         id_buf[255];
  Boolean      rval = TRUE;

  if (read == NULL || StringHasNoText (read->read_id)) {
    rval = FALSE;
  } else {
    sip_find = MakeSeqID (read->read_id);
    pair = FindReplacementInSeqIdReplaceList (sip_find, pair_list);
    if (pair != NULL && (no_lookup || OkToReplaceId (pair, read->read_seq, has_errors))) {
      if (pair->is_complement) {
        if (read->is_complement) {
          read->is_complement = FALSE;
        } else {
          read->is_complement = TRUE;
        }
      }
      if (pair->ti > 0) {
        read->ti = pair->ti;
      } else {
        if (pair->sip_replace->choice == SEQID_LOCAL) {
          SeqIdWrite (pair->sip_replace, id_buf, PRINTID_REPORT, sizeof (id_buf) - 1);
        } else {
          SeqIdWrite (pair->sip_replace, id_buf, PRINTID_FASTA_LONG, sizeof (id_buf) - 1);
        }
        if (is_srr) {
          if (read->srr != NULL) {
            free (read->srr);
          }
          read->srr = malloc (sizeof (Char) * (StringLen (id_buf) + 1));
          sprintf (read->srr, "%s", id_buf);
          free (read->read_id);
          read->read_id = NULL;
        } else {
          free (read->read_id);
          read->read_id = malloc (sizeof (Char) * (StringLen (id_buf) + 1));
          sprintf (read->read_id, "%s", id_buf);
        }
      }
      read->local = FALSE;
    }
    sip_find = SeqIdFree (sip_find);
  }
  return rval;
}
Exemplo n.º 6
0
/* Pops top StringStack item from StringStack */
CharPtr 
SLRI_SSPop(SLRI_SStackPtr ssp) 
{
  CharPtr string = NULL;
  SLRI_SStackItemPtr ssipNewTop = NULL;

  if (ssp == NULL) {
    ErrPostEx(SEV_ERROR, 0, 0, "SLRI_SSPop: stack pointer is NULL");
    return(NULL);
  }

  if (SLRI_SSIsEmpty(ssp)) {
    ErrPostEx(SEV_ERROR, 0, 0, "SLRI_SSPop: stack is empty");
    return(NULL);
  }

  ssipNewTop = ssp->top->prev;
  string = StringSave(ssp->top->string);
  ssp->top = MemFree(ssp->top);
  ssp->top = ssipNewTop;
  ssp->totalStackSize -= StringLen(string);
  ssp->totalNumItems--;

  /* If last item on stack, set bottom pointer to top */
  if (ssp->top == NULL) {
    ssp->bottom = ssp->top;
  }

  return(string);
}
Exemplo n.º 7
0
/* Pushes a StringStack item onto StringStack */
Int4 
SLRI_SSPush(SLRI_SStackPtr ssp, CharPtr string) 
{
  SLRI_SStackItemPtr newItem = NULL;

  if (ssp == NULL) {
    ErrPostEx(SEV_ERROR, 0, 0, "SLRI_SSPush: stack pointer is NULL");
    return(-1);
  }

  newItem = MemNew(sizeof(SLRI_SStackItem));

  newItem->string = string;
  newItem->prev = ssp->top;
  newItem->next = NULL; 

  if (ssp->top != NULL) {
    ssp->top->next = newItem;
  }

  ssp->top = newItem;
  ssp->totalStackSize += StringLen(newItem->string);
  ssp->totalNumItems++;

  /* If first item, set bottom pointer to top */
  if (ssp->bottom == NULL) {
    ssp->bottom = ssp->top;
  }

  return(0);
}
Exemplo n.º 8
0
static Boolean s_MightBeCorruptSequence (Int4             seqCharCount,
					 CharPtr          seqString,
					 AliConfigInfoPtr configPtr)
{
  Int4    i;
  Int4    badCharCount;
  Int4    seqStrLen;
  FloatLo percentGood;

  seqStrLen = StringLen(seqString);
  badCharCount = 0;

  for (i = 0; i < seqStrLen; i++)
    {
      if (IsSequenceChar(seqString[i],
			 configPtr->gapChar,
			 configPtr->missingChar,
			 configPtr->unalignedChar))
	seqCharCount++;
      else
	badCharCount++;
    }

  percentGood = (FloatLo) seqCharCount / ((FloatLo) seqCharCount + 
                                         (FloatLo) badCharCount);

  if ((percentGood * 100) >= configPtr->corruptSeqThreshold)
    return TRUE;
  else
    return FALSE;
}
Exemplo n.º 9
0
NLM_EXTERN Boolean SendTextToFile (FILE *f, CharPtr text, ParPtr parFmt, ColPtr colFmt)

{
  Uint2     cnt;
  Uint2     cntr;
  Boolean   rsult;
  Int2      start;
  TablePtr  tptr;

  rsult = TRUE;
  start = 0;
  cntr = StringLen (text);
  cnt = MIN (cntr, 64000);
  cnt = SkipPastNewLine (text + start, cnt);
  while (cnt > 0) {
    tptr = TableSegment (text + start, cnt, parFmt, colFmt);
    if (! SaveTableToFile (tptr, f)) {
      rsult = FALSE;
    }
    FreeTable (tptr);
    start += cnt;
    cntr -= cnt;
    cnt = MIN (cntr, 64000);
    cnt = SkipPastNewLine (text + start, cnt);
  }
  return rsult;
}
Exemplo n.º 10
0
Int2 Main (void)

{
    Char buf[256] = { '\0' };  /* Used below for name and version. */
    Int2 status = 0;    /* return value of function. */

    StringCpy(buf, "bl2seq ");
    StringNCat(buf, BlastGetVersionNumber(), sizeof(buf)-StringLen(buf)-1);
    if (! GetArgs (buf, NUMARG, myargs)) {
        return (1);
    }

    UseLocalAsnloadDataAndErrMsg ();

    if (! SeqEntryLoad())
                return 1;

    ErrSetMessageLevel(SEV_WARNING);

    if (myargs[ARG_FORCE_OLD].intvalue != 0)
        status = Main_old();
    else
        status = Main_new();

    FreeArgs(NUMARG, myargs);

    return status;
}
/*数据结构:链表,含头节点,每个节点为AnalysisNode,其中treeroot为一颗分析树,分析一类词法元素*/
AnalysisNodePtr AnalysisListCreate(char* lexString){
	char* lexicalDeclare = (char*)malloc(sizeof(char)*MAXLEXDECLEN);
	char* lexicalDef = (char*)malloc(sizeof(char)*MAXLEXDEFLEN);
	int lexicalDeclareLen = 0;
	int pos = 0;
	AnalysisNodePtr newAnalysisTree;
	AnalysisNodeBegin = (AnalysisNodePtr)malloc(sizeof(AnalysisNode));
	AnalysisNodeBegin->next = NULL;
	AnalysisNodeBegin->treeRoot = NULL;
	AnalysisNodeBegin->nodeName = "begin";
	while (LexStringSplit(lexString,&pos,lexicalDeclare,lexicalDef)==true){
		newAnalysisTree = (AnalysisNodePtr)malloc(sizeof(AnalysisNode));

		lexicalDeclareLen = StringLen(lexicalDeclare);
		newAnalysisTree->nodeName = (char*)malloc(sizeof(char)*lexicalDeclareLen);
		StringCopy(newAnalysisTree->nodeName, lexicalDeclare);

		newAnalysisTree->treeRoot = AnalysisTreeCreate(lexicalDef);

		//头插法,复杂分析树放在前,识别时从复杂部分开始;
		newAnalysisTree->next = AnalysisNodeBegin->next;
		AnalysisNodeBegin->next = newAnalysisTree;
	}
	return AnalysisNodeBegin;
}
Exemplo n.º 12
0
VOID LoadFile(LPTSTR File)
{
	TCHAR Command[2*MAX_PATH], fName[MAX_PATH], fExt[MAX_PATH], Buffer[MAX_PATH];

	//Move the current directory
	SetWorkingDirToFileLoc(File);

	

	// get file name and extension
	_tsplitpath (File, NULL, NULL, fName, fExt);
	wsprintf(Buffer,TEXT("%s%s"),fName,fExt);

	wsprintf(Command, TEXT(":load %s"), ExpandFileName(Buffer));
	AddMruFile(File);


	RtfWindowSetCommand(TEXT(":load "));
	StartOfInput += 6;	
	WinGHCiHyperlink(ExpandFileName(Buffer));
	StartOfInput += StringLen(ExpandFileName(Buffer));
	
	RtfWindowStartNextOutput();
	AddHistory(Command);
	SendToGHCiStdinLn(Command);

	Running = TRUE;
	EnableButtons();
	
	PrintGHCiOutputIfAvailable(hChildStderrRd, ErrorColor);
	PrintGHCiOutput(hChildStdoutRd, ForegroundColor);
	
	Running = FALSE;
	EnableButtons();
}
Exemplo n.º 13
0
Int2 Nlm_Main(void) {
    Boolean use_new_engine=FALSE;
    char buf[256] = { '\0' };

    StringCpy(buf, "mgblast ");
    StringNCat(buf, BlastGetVersionNumber(), sizeof(buf)-StringLen(buf)-1);
    if (! GetArgs (buf, NUMARG, myargs))
       return (1);

    UseLocalAsnloadDataAndErrMsg ();

    if (! SeqEntryLoad())
        return 1;

    ErrSetMessageLevel(SEV_WARNING);
    /*
    if (myargs[ARG_FORCE_OLD].intvalue == 0 &&
                  myargs[ARG_OUTTYPE].intvalue > 1 &&
                      myargs[ARG_GILIST].strvalue == NULL)
          use_new_engine = readdb_use_new_blast(myargs[ARG_DB].strvalue);
    if (myargs[ARG_MASKEDQUERY].strvalue)
        use_new_engine = FALSE;
    */
    
    /*if (use_new_engine)
        return Main_new();
    else */
        return Main_old();
}
Exemplo n.º 14
0
static void StringFit(char *s,int w)
	{
	if(StringLen(s) > w)
		{
		int i;


		w = w / 2;

		for(i = 0; i < w; i++)
			{
			s[i + w] = s[StringLen(s) - w + i];
			}
		s[w + w] = 0;
		}
	}
Exemplo n.º 15
0
static CharPtr TagStringFromFieldRule (FieldRulePtr rule)
{
  Int4 len;
  CharPtr fmt = "%s\t%s\t%d\n";
  CharPtr str;

  if (rule == NULL) {
    return NULL;
  }

  len = StringLen (fmt) + StringLen (rule->field_name) + StringLen (rule->match_expression);
  str = (CharPtr) MemNew (sizeof (Char) * len);
  sprintf (str, fmt, rule->field_name == NULL ? "" : rule->field_name,
           rule->match_expression == NULL ? "" : rule->match_expression,
           rule->required ? 1 : 0);
  return str;
}
Exemplo n.º 16
0
static Boolean LIBCALLBACK ExtractCodingRegions (BioseqPtr bsp, SeqMgrBioseqContextPtr bcontext)

{
  Char               buf [255];
  SeqFeatPtr         cds;
  SeqMgrFeatContext  fcontext;
  FILE               *fp;
  SeqPortPtr         spp;

  if (! ISA_na (bsp->mol)) return TRUE;
  fp = (FILE *) bcontext->userdata;
  BioseqLock (bsp);

  cds = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_CDREGION, 0, &fcontext);
  while (cds != NULL) {
    /*
    spp = FastaSeqPort (bsp, TRUE, FALSE, Seq_code_iupacna);
    */
    spp = SeqPortNewByLoc (cds->location, Seq_code_iupacna);
    if (spp != NULL) {

      /*
      if (FastaId (bsp, buf, sizeof (buf) - 1)) {
        FastaFileFunc (bsp, FASTA_ID, buf, StringLen (buf), (Pointer) fp);
      }
      if (CreateDefLine (NULL, bsp, buf, sizeof (buf) - 1, 0, NULL, NULL)) {
        FastaFileFunc (bsp, FASTA_DEFLINE, buf, StringLen (buf), (Pointer) fp);
      }
      */
      SeqLocLabel (cds->location, buf, sizeof (buf), OM_LABEL_CONTENT);
      FastaFileFunc (bsp, FASTA_ID, buf, StringLen (buf), (Pointer) fp);
      FastaFileFunc (bsp, FASTA_DEFLINE, fcontext.label, StringLen (fcontext.label), (Pointer) fp);
      while (FastaSeqLine (spp, buf, 80, TRUE)) {
        FastaFileFunc (bsp, FASTA_SEQLINE, buf, StringLen (buf), (Pointer) fp);
      }
      FastaFileFunc (bsp, FASTA_EOS, buf, StringLen (buf), (Pointer) fp);

      SeqPortFree (spp);
    }
    cds = SeqMgrGetNextFeature (bsp, cds, SEQFEAT_CDREGION, 0, &fcontext);
  }

  BioseqUnlock (bsp);
  return TRUE;
}
Exemplo n.º 17
0
/*****************************************************************************
*
*   PersonIdPrint(pip, buf)
*
*****************************************************************************/
NLM_EXTERN CharPtr PersonIdPrint(PersonIdPtr pip, CharPtr buf)
{
	CharPtr tmp;
	NameStdPtr nsp;

	if (buf == NULL) return NULL;

	tmp = buf;
	*tmp = '?';
	*(tmp + 1) = '\0';

	if (pip == NULL) return buf;

	if (pip->choice == 2)    /* std */
	{
		nsp = (NameStdPtr) (pip->data);
		if (nsp != NULL)
		{
			if (nsp->names [3] != NULL)                 /* full name */
				tmp = StringMove(tmp, nsp->names [3]);
			else if (nsp->names[0] != NULL)             /* make from parts */
			{
				if (nsp->names [1] != NULL && nsp->names [2] != NULL)
				{
					tmp = StringMove(tmp, nsp->names [1]);	/* first */
					*tmp = ' '; tmp++; *tmp='\0';
					tmp = StringMove(tmp, nsp->names [2]);	/* middle */
					*tmp = ' '; tmp++; *tmp='\0';
				}
				else if ((nsp->names [4] != NULL) &&
						(nsp->names [0] != NULL) &&
						(StringLen(nsp->names[4]) < 10))
				{
					tmp = StringMove(tmp, nsp->names [4]);  /* initials */
					*tmp = ' '; tmp++; *tmp='\0';
				}
				else if (nsp->names [1] != NULL)
				{
					tmp = StringMove(tmp, nsp->names [1]);
					*tmp = ' '; tmp++; *tmp='\0';
				}
				tmp = StringMove(tmp, nsp->names [0]);		/* last */
				if (nsp->names[5] != NULL)                  /* suffix */
				{
					*tmp = ' '; tmp++; *tmp='\0';
					tmp = StringMove(tmp, nsp->names[5]);
				}
			}
		}
	}
	else if (pip->choice == 3 || pip->choice == 4) /* ml or str */
		StringMove(tmp, (CharPtr)(pip->data));

	return buf;
}
Exemplo n.º 18
0
static void Cn3D_KinEnableProc(TexT t)
{
    Char str[32];
    GetTitle(Cn3D_tKinSave, str, sizeof(str));
    if (StringLen(str) == 0) {
        Disable(Cn3D_bKinOk);
    } else {
        Enable(Cn3D_bKinOk);
    }
    return;
}
Exemplo n.º 19
0
static void Dumb_MonStrValue (MonitorPtr pMon)
{
	char *buf = (char *) pMon->extra;
	size_t len0 = (int)pMon->num1;
	size_t len1 = MIN(StringLen(pMon->strValue),len0);
	size_t diff = (len0-len1)/2;
	Nlm_MemFill(&buf[3],' ',len0+2);
	Nlm_MemCopy(&buf[4+diff],pMon->strValue,len1);
	fprintf(stderr,"\r%s",buf);
	fflush(stderr);
}
Exemplo n.º 20
0
NLM_EXTERN CONN QUERY_OpenServiceQueryEx (
  const char* service,
  const char* parameters,
  Nlm_Uint4   timeoutsec,
  const char* arguments
)
{
  CONN           conn;
  CONNECTOR      connector;
  SConnNetInfo*  net_info;
  size_t         n_written;
  EIO_Status     status;

  /* fill in connection info fields and create the connection */
  net_info = ConnNetInfo_Create (service);
  ASSERT ( net_info );

  /* let the user agent be set with a program name */
  x_SetupUserHeader (net_info,
                     NULL, eMIME_T_Unknown, eMIME_Unknown, eENCOD_None);

  if (timeoutsec == (Nlm_Uint4)(-1L)) {
    net_info->timeout  = kInfiniteTimeout;
  } else if ( timeoutsec ) {
    net_info->tmo.sec  = timeoutsec;
    net_info->tmo.usec = timeoutsec;
    net_info->timeout  = &net_info->tmo;
  }

  ConnNetInfo_PostOverrideArg (net_info, arguments, 0);

  connector = SERVICE_CreateConnectorEx (service, fSERV_Any, net_info, 0);

  ConnNetInfo_Destroy (net_info);

  if (connector == NULL) {
    ErrPostEx (SEV_ERROR, 0, 0, "QUERY_OpenServiceQuery failed in SERVICE_CreateConnectorEx");
    conn = NULL;
  } else if ((status = CONN_Create (connector, &conn)) != eIO_Success) {
    ErrPostEx (SEV_ERROR, 0, 0, "QUERY_OpenServiceQuery failed in CONN_Create:"
               " %s", IO_StatusStr (status));
    ASSERT (conn == NULL);
  } else if (StringDoesHaveText (parameters)) {
    status = CONN_Write (conn, parameters, StringLen (parameters),
                         &n_written, eIO_WritePersist);
    if (status != eIO_Success) {
      ErrPostEx (SEV_ERROR, 0, 0, "QUERY_OpenServiceQuery failed to write service parameters in CONN_Write: %s", IO_StatusStr (status));
      CONN_Close (conn);
      conn = NULL;
    }
  }

  return conn;
}
Exemplo n.º 21
0
/*************************************************************************
***
*	gb_id_make(): make the Seq-id for Genbank with tsip->name = name
*	tsip->acc.
*
*************************************************************************
***/
NLM_EXTERN SeqIdPtr gb_id_make(CharPtr name, CharPtr acc)
{
   SeqIdPtr new_id;
   TextSeqIdPtr tsip;

	   new_id= (SeqIdPtr)ValNodeNew(NULL);
	   new_id->choice = SEQID_GENBANK;
	   tsip = TextSeqIdNew();
	   if(name)
	   {
	   if(StringLen(name) >3 && IS_ALPHA(name[0]))
	     tsip->name = StringSave(name);
	   }
	   if(acc)
	   {
	   if(StringLen(acc) >3 && IS_ALPHA(acc[0]))
	     tsip->accession = StringSave(acc);
	   }
	   new_id->data.ptrvalue = tsip;
	   return new_id;
}
Exemplo n.º 22
0
CharPtr NextUniqueChainName(PMSD pmsd) {
/* Must return a new letter for the added chain name */
	PDNMM pdnmmHere;
	PMMD pmmdHere;
	char *ptr,*chainptr;
	CharPtr pcChainName=NULL;
	CharPtr newChainName=NULL;
	char Alphabet[]="123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	Int2 i=0;	
	
	chainptr=Alphabet;
	pdnmmHere=pmsd->pdnmmHead;
	
	while(pdnmmHere != NULL){
		
		/*printf("pdnmmHere is %d\n",pdnmmHere->choice);*/
		pmmdHere=(PMMD)pdnmmHere->data.ptrvalue;
		if (pmmdHere==NULL) break;
		pcChainName=pmmdHere->pcMolName;
		if (pcChainName==NULL) break;
		Misc_TrimSpacesAroundString(pcChainName);
		/* printf("pcChainame here is %s\n",pcChainName); */
		if (StringLen(pcChainName)==1 ) {
			ptr=Alphabet;
			while (*ptr != '\0'){
				if (*ptr == pcChainName[0]) {
					
					*ptr = '0';  /* marks the ones in use with 0 */
					break;
				}
				ptr++;
			}	
		
		}
		
		pdnmmHere=pdnmmHere->next;
	}
	
	newChainName=(CharPtr)MemNew(2*sizeof(Char));
	
	while(*chainptr !='\0'){
		if(*chainptr != '0') {
			newChainName[0] = *chainptr;
			break;
		}
		chainptr++;
	}
	return newChainName;
/* See original code ...  beware of non biopolymer names */

}
Exemplo n.º 23
0
static Boolean LoadObjPrtFromLocalString (CharPtr localStr)

{
  Boolean     retval = FALSE;
#ifndef WIN16
  AsnIoMemPtr aimp;

  aimp = AsnIoMemOpen ("r", (BytePtr) localStr, (Int4) StringLen (localStr));
  if (aimp == NULL || aimp->aip == NULL) return FALSE;
  retval = PrintTemplateSetAsnRead (aimp->aip);
  AsnIoMemClose (aimp);
#endif
  return retval;
}
Exemplo n.º 24
0
static void 
/*FCN*/OnText16 ( 
  TexT t 
){
  Char curVal[20];

  GetTitle ( t, &(curVal[0]), 20 );
  curVal[19] = 0;
  if ( StringLen ( &(curVal[0]) ) > 16 ){
    Nlm_Beep();
    curVal[17] = 0;
    SetTitle ( t, &(curVal[0]) );
  }
}
Exemplo n.º 25
0
VOID WinGHCiHyperlink(LPCTSTR msg)
{
    CHARFORMAT2 cf2;
    FlushBuffer(TRUE);

    cf2.cbSize = sizeof(cf2);
    cf2.dwMask = CFM_LINK;
    cf2.dwEffects = CFE_LINK;

    SendMessage(hWndRtf, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2);
    SendMessage(hWndRtf, EM_REPLACESEL, FALSE, (LPARAM) msg);
    StartOfInput += StringLen(msg);
    cf2.dwEffects = 0;
    SendMessage(hWndRtf, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf2);
}
Exemplo n.º 26
0
// all strings are null terminated. Assumes enough space in Result
VOID StringReplaceAllOccurrences(LPTSTR Str, LPTSTR ToReplace, LPTSTR Replacement, LPTSTR Result)
{
	LPTSTR p;
	TCHAR svChar;
	INT ToReplaceLen = StringLen(ToReplace);
	INT ReplacementLen = StringLen(Replacement);

	Result[0] = TEXT('\0');	
	for(;;) {
		p = StringSearchString(Str,ToReplace);
		if (p==NULL) {
			StringCat(Result,Str);
			break;
		}
		svChar = *p;
		*p=TEXT('\0');
		StringCat(Result,Str);
		*p=svChar;
		StringCat(Result,Replacement);
		Str = (p+ToReplaceLen);

	}
	
}
Exemplo n.º 27
0
// need to copy from s to Buf
VOID AddToBufferExt(LPCTSTR s, INT numChars)
{
    UpdateFormat();

    if (InEscBuf) {
        for (; numChars>0; s++, numChars--) {
            if (*s == TEXT('m')) {
                Format f = NowFormat;
                if (ParseEscapeCode(&f)) {
                    FormatChanged = TRUE;
                    NowFormat = f;
                }
                InEscBuf = FALSE;
                AddToBufferExt(s+1,numChars-1);
                return;
            } else if ((*s >= TEXT('0') && *s <= TEXT('9')) ||
                       (*s == TEXT(';')) || (*s == TEXT('['))) {
                EscBuf[EscBufPos++] = *s;
                EscBufPos = min(EscBufPos, MAX_ESC_BUFSIZE);
            } else {
                InEscBuf = FALSE;
                AddToBufferExt(EscBuf,StringLen(EscBuf));
                break;
            }
        }
    }

    for (; numChars>0; s++, numChars--) {
        if (*s == TEXT('\b')) {
            if (BufPos == 0) {
                OutputPos--;
            } else
                BufPos--;
        } else if (*s == TEXT('\07')) {
            Beep( 750, 150 );
        } else if (*s == TEXT('\033')) {
            InEscBuf = TRUE;
            EscBufPos = 0;
            AddToBufferExt(s+1,numChars-1);
            return;
        } else {
            if (BufLen >= BufSize)
                FlushBuffer(TRUE);
            Buf[BufPos++] = *s;
            BufLen = max(BufLen, BufPos);
        }
    }
}
Exemplo n.º 28
0
static Uint4
HashPDBCode(CharPtr pcPdb)
{

  Uint4 iPdbhash;
  Uint4 c1, c2, c3, c4;

  if (!pcPdb) return 0;
  if (StringLen(pcPdb) != 4) return 0;
  c1 =  pcPdb[3];
  c2 =  pcPdb[2];
  c3 =  pcPdb[1];
  c4 =  pcPdb[0];
  iPdbhash =  c1 + (c2 << 8) + (c3 << 16) + (c4 << 24);
  
  return iPdbhash;
}
Exemplo n.º 29
0
static Boolean PvtStrToLong (CharPtr str, Int4Ptr longval)

{
   Char     ch;
   Int2     i;
   Int2     len;
   Char     local [64];
   Boolean  nodigits;
   Boolean  rsult;
   long int     val;

   rsult = FALSE;
   if (longval != NULL) {
     *longval = (Int4) 0;
   }
   len = (Int2) StringLen (str);
   if (len != 0) {
     rsult = TRUE;
     nodigits = TRUE;
     for (i = 0; i < len; i++) {
       ch = str [i];
       if (ch == ' ' || ch == '+' || ch == '-') {
       } else if (ch < '0' || ch > '9') {
         rsult = FALSE;
       } else {
         nodigits = FALSE;
       }
     }
     if (nodigits) {
       rsult = FALSE;
     }
     if (rsult && longval != NULL) {
       StringNCpy_0 (local, str, sizeof (local));
       if (sscanf (local, "%ld", &val) == 1) {
         *longval = val;
       }
     }
   }
   return rsult;
}
Exemplo n.º 30
0
static void DoThesis (PubdescPtr pdp, Pointer userdata)

{
  CitBookPtr   cbp;
  Char         ch;
  ScanDataPtr  sdp;
  CharPtr      title, tmp;
  ValNodePtr   ttl, vnp;

  if (pdp == NULL) return;

  for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
    if (vnp->choice == PUB_Man) {
      cbp = (CitBookPtr) vnp->data.ptrvalue;
      if (cbp != NULL) {
        ttl = cbp->title;
        if (ttl != NULL) {
          title = (CharPtr) ttl->data.ptrvalue;
          if (! StringHasNoText (title)) {
            if (StringLen (title) > 3) {
              ch = *title;
              if (IS_LOWER (ch)) {
                tmp = title;
                ch = *tmp;
                while (ch != '\0' && (! (IS_WHITESP (ch)))) {
                  tmp++;
                  ch = *tmp;
                }
                *tmp = '\0';
                sdp = (ScanDataPtr) userdata;
                RecordThesis (sdp, title);
              }
            }
          }
        }
      }
    }
  }
}