static SR_Status SR_LibInfoTableAddSeqTech(SR_LibInfoTable* pTable, const char* platformPos) { char buff[30]; const char* platformEnd = strpbrk(platformPos, " \t\n"); unsigned int platformLen = platformEnd - platformPos; if (platformLen > 29) return SR_ERR; strncpy(buff, platformPos, platformLen); buff[platformLen] = '\0'; StrToUpper(buff); unsigned int lastIndex = pTable->size; if (strstr(buff, "LONG") != NULL) pTable->pSeqTech[lastIndex] = ST_ILLUMINA_LONG; else if (strcmp(buff, "ILLUMINA") == 0) pTable->pSeqTech[lastIndex] = ST_ILLUMINA; else if (strcmp(buff, "LS454") == 0) pTable->pSeqTech[lastIndex] = ST_454; else if (strcmp(buff, "SOLID") == 0) pTable->pSeqTech[lastIndex] = ST_SOLID; else return SR_ERR; return SR_OK; }
int IsValidL1SymbolEmbeded( char *Line ) { if( Line[0] != '0' && Line[0] != '1' && Line[1] != ' ' ) return -1; //intrusive !!! StrToUpper( Line ); for( int i=0;i<L1SymbolListSize;i++) if( EmbededStrStr( &Line[2], L1SymbolList[i]->Name ) == &Line[2] ) return i; return -1; }
double ConvertToDegrees (char *direction) { StrToUpper(direction); RemoveTrailingSpaces(direction); // JLM 11/12/99 allow the string to contain a value in digits //if(isdigit(direction[0])) if (direction[0]>='0' && direction[0]<='9') // for code warrior { float val; long count = sscanf(direction, "%f", &val); if (count == 1) { // make sure it is in the range 0-360 double completeCircle = 360.0; long numCompleteCircles = val/completeCircle; // truncate val -= numCompleteCircles*completeCircle; while (val < 0.0) { val += completeCircle;} while (val > completeCircle) { val -= completeCircle;} return val; } } else { if (!strcmp(direction, "N")) return 0; if (!strcmp(direction, "E")) return 90; if (!strcmp(direction, "S")) return 180; if (!strcmp(direction, "W")) return 270; if (!strcmp(direction, "NE")) return 45; if (!strcmp(direction, "SE")) return 135; if (!strcmp(direction, "SW")) return 225; if (!strcmp(direction, "NW")) return 315; if (!strcmp(direction, "NNE")) return 22.5; if (!strcmp(direction, "ENE")) return 67.5; if (!strcmp(direction, "ESE")) return 112.5; if (!strcmp(direction, "SSE")) return 157.5; if (!strcmp(direction, "SSW")) return 202.5; if (!strcmp(direction, "WSW")) return 247.5; if (!strcmp(direction, "WNW")) return 292.5; if (!strcmp(direction, "NNW")) return 337.5; } return 0; }
//--------------------------------------------------------------------------- void __fastcall TFormCreateDoc::ButtonCreateDocClick(TObject *Sender) { assert(m_plaintext.size() > 1); //Start at index one, because index zero is the copyright line std::random_shuffle(&m_plaintext[1],m_plaintext.end()); if (CheckBoxUseCode->Checked) { m_doctext = CreateDoc( m_plaintext, EditNquestions->Text.ToInt(), StrToUpper(EditCode->Text.c_str())); } else { m_doctext = CreateDoc(m_plaintext,EditNquestions->Text.ToInt()); } VectorToStringList(m_doctext,RichEdit2->Lines); ++PageControl1->ActivePageIndex; }
void test_util() { char tmp[100]; strcpy(tmp,"strIng"); printf("test string Lower to Upper\n"); printf("before:%s\n",tmp); StrToUpper(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp,"STRiNG"); printf("test string Lower to Upper\n"); printf("before:%s\n",tmp); StrToLower(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp,"STRiNG "); printf("test string remove right space\n"); printf("before:%s\n",tmp); RTrim(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp," STRiNG"); printf("test string remove left space\n"); printf("before:%s\n",tmp); LTrim(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp," STRiNG "); printf("test string remove left and right space\n"); printf("before:%s\n",tmp); Trim(tmp); printf("after:%s\n",tmp); }
const char * SEL_ITEMget_enumtype( Type t ) { return StrToUpper( TYPEget_name( t ) ); }
char *WriteSeq( char *outSpec, /* Output sequence spec */ SeqEntry *seq, /* Seq Entry data structure */ int format) /* Output format */ { #define SIZE 255 /* String size */ char line[SIZE], header[SIZE], code[SIZE], testCode[SIZE]; char outFName[SIZE]; char *cPos, *pStrand; int lineSize, blockSize; int count, nOut; Boolean twoFiles; Boolean doText; char errMsg[SIZE]; static char outFileName[SIZE]; /* Static because it's the return value */ FILE *outFile, *inFile; /* ** Process available text for formats which allow freely formated text. */ switch ( format ) { case PIR: case GCG: doText = (seq->text != NULL); break; default: doText = 0; break; } /* ** Set LineSize and BlockSize for variou formats */ switch ( seq->spec->format ) { case GCG: lineSize = 50; blockSize= 10; break; case PIR: case IBI: lineSize = 60; blockSize = 10; break; case IG: case STRIDER: default: lineSize = blockSize= 80; } /* ** Extract the the code from OutSpec for multi-entry files. If OutSpec just ** has a filename then strip off the extension and use the filename as the code. ** Filenames are to the right of the equals. ** N.B. does not yet support pathnames. ** ** Outspec will look like either: ** ** code=filename.ext OR filename.ext */ if ( (cPos = strchr(outSpec,';')) ) *cPos = '\0'; /* Remove version */ strcpy(code,outSpec); if ( (cPos = strchr(code,'=')) ) *cPos = '\0'; /* code=filename.ext */ if ( (cPos = strchr(code,'.')) ) *cPos = '\0'; /* filename.ext */ StrToUpper(code); strcpy(outFName,outSpec); if ( (cPos = strchr(outFName,'=')) ) strcpy(outFName, ++cPos); /* ** Are we dealing with a new or old sequence file? Test for an existing ** file set "twoFiles" flag accordingly. */ if ( (inFile = fopen(outFName, "r")) ) { if ( !(outFile = fopen(outFName, "w")) ) goto Error; twoFiles = 1; } else { if ( !(outFile = fopen(outFName, "w")) ) goto Error; twoFiles = 0; } /* ** Do what needs to be done to prepare the file for writing or over-writing ** the new sequence data. ** ** PIR - create header, read into filename until we find the entry to ** replace or reach EOF. Save existing text if there is no new text. ** ** IG - Save any lines beginning with ";" these are comment characters. ** Write out codeword. Generate circular/linear flag. ** ** STADEN - Translate symbols from IUPAC to STADEN, append end of sequence ** character, "@". ** ** GCG - Save all text at the top of the file up to but not including the ** line with ".." in it, unless we have new text. Convert "-"'s to ** "."'s. Recalculate CheckSum. Write a new GCG descriptor line. ** ** IBI - Rewrite the LOCUS line and ORIGIN line. ** ** STRIDER- Write out strider header line and sequnce title. ** ** RAWSEQ - Do nothing. */ switch ( format ) { case PIR: strcpy(header, ">"); switch (seq->type ) { case PROTEIN: strcat(header,"P1;"); break; case FRAGMENT: strcat(header,"F1;"); break; case DNA: seq->circular ? strcat(header,"DC;"):strcat(header,"DL;") ; break; case RNA: seq->circular ? strcat(header,"RC;"):strcat(header,"RL;") ; break; case RRNA: strcat(header,"N1;"); break; case TRNA: strcat(header,"N3;"); break; default: strcat(header,"XX;"); break; } strcat(header, code); /* ** Read in/out until the beginning of entry to be overwritten ** or End of File. */ if ( twoFiles ) { testCode[0] = '\0'; while ( fgets(line, 255, inFile) ) { if( line[0] == '>') { strcpy(testCode, &line[4]); if ( (cPos = strchr(testCode, '\n')) ) *cPos = '\0'; StrToUpper(StrCollapse(testCode)); if( strcmp(testCode,code) == 0 ) break; } fputs(line,outFile); } } /* ** Write out the header and title lines. */ fprintf(outFile,"%s\n", header); fprintf(outFile,"%s\n", seq->title); break; /****************************************************************/ case IG: /* ** For IG format save any lines beginning with ";" these ** are comment characters */ if ( twoFiles && !doText ) { while ( fgets(line, 255, inFile) ) { if ( line[0] != ';' ) break; fputs(line,outFile); } } else if ( doText ) { if ( seq->text ) fputs(seq->text,outFile); } else fprintf(outFile, "; %s\n; %s\n", seq->title,seq->desc); fprintf(outFile, "%s\n", code); break; /****************************************************************/ case STADEN: if (seq->type >= DNA ) { StrChange(seq->mem,'M','5'); StrChange(seq->mem,'K','6'); StrChange(seq->mem,'W','7'); StrChange(seq->mem,'S','8'); StrChange(seq->mem,'m','5'); StrChange(seq->mem,'k','6'); StrChange(seq->mem,'w','7'); StrChange(seq->mem,'s','8'); } break; /****************************************************************/ case GCG: if ( twoFiles && !doText ) { while ( fgets(line, 255, inFile) ) { if ( StrIndex("..",line) ) break; fputs(line,outFile); } } else if ( doText ) { if ( seq->text ) fputs(seq->text,outFile); } else fprintf(outFile, " %s\n %s\n\n", seq->title,seq->desc); StrChange(seq->mem,'-','.'); seq->checkSum = CheckSum(seq->mem); fprintf(outFile, " %s Length: %ld %s Check: %d ..\n", outFName, seq->length, GetTime(3), seq->checkSum); fprintf(outFile," 1 "); break; /****************************************************************/ case IBI: fprintf(outFile, "LOCUS %s %ld BP UPDATED %s\n", code, seq->length, GetTime(0)); if ( twoFiles && !doText ) { while ( fgets(line, 255, inFile) ) { if ( StrIndex("LOCUS",line) ) continue; if ( StrIndex("ORIGIN",line) ) break; fputs(line,outFile); } } else if ( doText && seq->text ) { if ( (cPos = StrIndex("LOCUS ",seq->text)) ) strcpy(seq->text,strchr(cPos,'\n')); if ( (cPos = StrIndex("\nORIGIN",seq->text)) ) *cPos = '\0'; fputs(seq->text,outFile); } fprintf(outFile, "ORIGIN %s\n", seq->title); fprintf(outFile," 1 "); break; /****************************************************************/ case STRIDER: fprintf(outFile,"; ### from DNA Strider %s\n",GetTime(3)); fprintf(outFile,"; %s sequence %s length %ld", DecodeType(seq->type),seq->name,seq->length); if ( seq->type <= PROTEIN ) fprintf(outFile," a.a. complete sequence\n; %s\n",seq->title); else fprintf(outFile," n.a. complete sequence\n; %s\n",seq->title); break; /****************************************************************/ case RAWSEQ: default: break; } /* ** Write the sequence in Block/Line size. "NOut" counts the number ** of symbols written in each line. Support GCG and IBI line numbering ** schemes. */ nOut = 0; count = 1; pStrand = seq->mem; while( *pStrand ) { fprintf(outFile, "%c", *pStrand); nOut++; count++; if ( nOut == lineSize ) { switch ( format ) { case IBI: case GCG: fprintf(outFile,"\n%9d ",count); break; default: fprintf(outFile, "\n"); } nOut=0; } else if ( nOut%blockSize == 0 ) fprintf(outFile, " "); pStrand++; } /* ** Depending on the format we have some finishing up to do. ** ** PIR - Add the End of sequence character. Read past the old sequence ** form the original file. If "DoText" is true, write out the new ** text comments, skip over the comments in the old file, if any. ** Finally, copy the balance of the old file into the new file. ** ** IBI - Add sequence terminator "//" ** ** IG - Append linear/circular flag at end of sequence. ** ** STRIDER - Add sequence terminator "//" ** ** STADEN - Add end of sequence character. Convert sequence symbols back ** to IUPAC. ** ** GCG - Convert "."'s back to "-"'s. Recalc CheckSum. */ switch ( format ) { case PIR: fprintf(outFile,"*\n"); /* Skip over sequence in the old file */ if ( twoFiles ) while ( fgets(line, 255, inFile) ) if( strchr(line,'*' ) ) break; /* Skip over old comments, if any. */ if ( doText ) { if ( seq->text ) fputs(seq->text,outFile); if ( twoFiles ) while ( fgets(line, 255, inFile) ) if( *line == '>' ) { fputs(line,outFile); break; } } /* Copy the remainder of the file */ if ( twoFiles ) { while ( fgets(line, 255, inFile) ) fputs(line, outFile); } break; /****************************************************************/ case IBI: fprintf(outFile,"\n//"); break; /****************************************************************/ case IG: fprintf(outFile,"%c",seq->circular ? '2' : '1'); break; /****************************************************************/ case STRIDER: fprintf(outFile,"\n//"); break; /****************************************************************/ case STADEN: fprintf(outFile,"@"); if (seq->type >= DNA ) { StrChange(seq->mem,'5','M'); StrChange(seq->mem,'6','K'); StrChange(seq->mem,'7','W'); StrChange(seq->mem,'8','S'); } break; /****************************************************************/ case GCG: StrChange(seq->mem,'.','-'); seq->checkSum = CheckSum(seq->mem); break; } /* fgetname(outFile, outFileName); NO IDEA PUT strcopy to compile il*/ strcpy(outFileName,outFName); fclose(outFile); if ( twoFiles ) fclose(inFile); return(outFileName); /* ** The output file could not be created. Set error message and return ** NULL */ Error: sprintf(errMsg, "Output file \"%s\" could not be created.", outFName); PostError(2,errMsg); return(NULL); } /* End of WriteSeq */