Пример #1
0
int ExportMerlinDataFile ()
{
  int i;
  char mkrname[NAMESIZE], tempstr[NAMESIZE];

  // Makes pedigree file
  cfopen ("merlin.dat", "w");


  for (i = 1; i<=numberofmarkers(); i++)
  {
    // Remove white spaces in marker name
    RemoveWhiteSpace(tempstr, GetName(markernames, order[i]));
    strncpy(mkrname, tempstr, NAMESIZE);
    fprintf(F, "M %s\n", mkrname);
  }

  for (i = 1; i<=numberoftraits(); i++)
  {
    // Remove white spaces in marker name
    RemoveWhiteSpace(tempstr, GetName(traitnames, i));
    strncpy(mkrname, tempstr, 18);

    fprintf(F, "T %s\n", mkrname);
  }


  fclose(F);
  return 0;
}
Пример #2
0
void ExportMendelLocus(individual *indlist) {
  int i, j, nAlleles;
  char minibuf[10], tempstr[NAMESIZE];  

  cfopen ("mendel.loc", "w");

  // Make an artificial DISEASE variable
  fprintf(F, "DISEASE AUTOSOME 2 0\n+       .99\n-       .01\n");

  for (i = 0; i < numberofmarkers(); i++) {
    nAlleles = NumberOfAlleles(order[i+1]);

    RemoveWhiteSpace(tempstr, GetName(markernames, order[i+1]));
    strncpy(minibuf, tempstr, 8);
    minibuf[8] = '\0';

    // Prints the locus information
    //    fprintf(F, "%-8s%-8s%2d%2d\n", minibuf,"AUTOSOME", nAlleles, nAlleles*(nAlleles+1)/2);
    fprintf(F, "%-8s%-8s%2d%2d\n", minibuf,"AUTOSOME", nAlleles, 0);

    // Should now print the frequency information

    CopyAlleleFreq(order[i+1]);
    
    for (j=1; j<= NumberOfAlleles(order[i+1]); j++)
      fprintf(F, "%c       %8.5f\n", 64+j, allelefreq[j]);

  }

  fclose(F);

}
Пример #3
0
int ExportRelpairLocus(int chromosome)
{
  int i, j;
  char mkrname[NAMESIZE], tempstr[NAMESIZE];
  

  cfopen ("relpair.loc", "w");

  for (i = 1; i<=numberofmarkers(); i++)
  {
    // Remove white spaces in marker name
    RemoveWhiteSpace(tempstr, GetName(markernames, order[i]));
    strncpy(mkrname, tempstr, NAMESIZE);
    // Prints the locus information
    fprintf(F, "%-8s%8s%2d%2d%4d%8.5f\n", mkrname, "AUTOSOME", 
	    NumberOfAlleles(order[i]), 0, chromosome, MarkerDistance(0,i)/100);
    // Should now print the frequency information

    CopyAlleleFreq(order[i]);

    for (j=1; j<= NumberOfAlleles(order[i]); j++)
      fprintf(F, "%c       %8.5f\n", 64+j, allelefreq[j]);
  }
    
  fclose(F);

  printf("Created relpair locus file\n");

  return 1;
}
Пример #4
0
uint16_t GetNumber(uint8_t **pos) {
	uint16_t ret = 0;
	uint8_t ss, isvariable = 0;
	variable_ind = 65535;
	RemoveWhiteSpace(pos);
	while(1) {
	    ss = *((*pos)++);
	    if((ss == ' ') || 
			(ss == ';') || 
			(ss == ']') || 
			(ss == '[') || 
			(ss == ')') ||
			(ss == '}') ||
			(ss == '{')) break;
	    else if((ss >= '0') && (ss <= '9')) ret = ret * 10 + (ss - '0');
	    else if(ss == 'v') {
			while(ss != '(') ss = *((*pos)++);
			variable_ind = GetNumber(pos);
			while((*(*pos) == ')')) (*pos)++;
			isvariable = 1;
			break;
		}
	}
	// This is needed, so that we can catch loops
	if(ss == ';' || ss == ']') (*pos)--;
	if(isvariable) {
		if(variable_ind < MAX_VARIABLE) ret = variable[variable_ind];
		else ret = 65535;
	}
	//printf("ret: %d\n", ret);
	return(ret);
}
Пример #5
0
int ExportSolarFrequency (void)
{
  char mkrname[NAMESIZE], tempstr[NAMESIZE];
  int i, j;
  

  // Makes the frequency file
  cfopen ("solar.frq", "w");

  for (i = 1; i<=numberofmarkers(); i++)
  {
    // Remove white spaces in marker name
    RemoveWhiteSpace(tempstr, GetName(markernames, order[i]));
    strncpy(mkrname, tempstr, NAMESIZE);

    CopyAlleleFreq(order[i]);

    fprintf(F, "%-18s  ", mkrname);
    for (j=1; j<= NumberOfAlleles(order[i]); j++)
      fprintf(F, "%2d %5.3f  ", j, allelefreq[j]);

    fprintf(F, "\n");
  }

  fclose(F);

  puts("Made Solar frequency file");
  return 0;
}
Пример #6
0
Interpreter::Interpreter(const char *input)
{
	inputLength = 1+strlen(input);
	symbolTree=NULL;
	
	inputLine = new char[inputLength];
	strcpy(inputLine, input);
	
	
	errorState = no_error;
	RemoveWhiteSpace();
	if (strlen(inputLine) == 0)
		errorState = no_function;
		
	if (!ParensOK())
	{
		errorState=unmatched_parens;
		return;
	}
	else
		symbolTree = Parse(inputLine);

	
	return;
}
Пример #7
0
int ExportMerlinFreq (void) {
  int i, k;
  FreqList *fl;
  char mkrname[NAMESIZE], tempstr[NAMESIZE];

  cfopen ("merlin.freq", "w");

  for (i = 1; i<=numberofmarkers(); i++) {
    // Remove white spaces in marker name
    RemoveWhiteSpace(tempstr, GetName(markernames, order[i]));
    strncpy(mkrname, tempstr, NAMESIZE);
    fprintf(F, "M %s\nF ", mkrname);

    fl = FrequencyNumber(i);
    for (k=1; k<= fl->num_alleles; k++)
      fprintf(F, "%-6.4f ",fl->frequency[k]);
    fprintf(F, "\n");
  }

  fclose(F);
  puts("Made Merlin frequency file");
  

  return 0;
}
Пример #8
0
int ExportMerlinMap (void)
{
  char mkrname[NAMESIZE], tempstr[NAMESIZE];
  int i;
  double currentpos;

  printf("Which chromosome is this: ");
  InputLine(buf, BUFFERSIZE);

  currentpos = 0;
  // Makes the marker file
  cfopen ("merlin.map", "w");
  fprintf(F, "CHROMOSOME   MARKER          LOCATION\n");
  for (i = 1; i<=numberofmarkers(); i++)
  {
    // Remove white spaces in marker name
    RemoveWhiteSpace(tempstr, GetName(markernames, order[i]));
    strncpy(mkrname, tempstr, NAMESIZE);

    fprintf(F, "%-5s  %-18s  %f\n", buf, mkrname, MarkerDistance(0,i));
  }
  fclose(F);
  puts("Made Merlin map file");
  return 0;
}
Пример #9
0
int ExportSolarMarker (individual *indlist)
{
  individual *ind;
  markerlist *marker;
  char mkrname[NAMESIZE], tempstr[NAMESIZE];
  int i;
  

  // Makes the marker file
  cfopen ("solar.mkr", "w");
  fprintf(F, "id");
  for (i = 1; i<=numberofmarkers(); i++)
  {
    // Remove white spaces in marker name
    RemoveWhiteSpace(tempstr, GetName(markernames, order[i]));
    strncpy(mkrname, tempstr, NAMESIZE);
    fprintf(F, ",%s", mkrname);
  }
  fprintf(F, "\n");

  for (ind = indlist; ind; ind = ind->next)
  {
    fprintf(F, "%s", ind->id);
    for (i = 1; i<=numberofmarkers(); i++)
    {
      marker = markernumber(ind, order[i]);
      fprintf(F, ",%d/%d", marker->allele1, marker->allele2);
    }
    fprintf(F, "\n");
  }

  fclose(F);
  puts("Made Solar marker file");
  return 0;
}
Пример #10
0
uint16_t GetToken(uint8_t **pos) {
	uint16_t value = 0;
	uint8_t c;
	RemoveWhiteSpace(pos);
	while(1) {
		c = *((*pos)++);
		//if(c == '\0' || c == ' ' || c == ';' || c == '[' || c == ']') break;
		if(c >= 'a' && c <= 'z') value = (value << 5) + (c-96);
		else break;
	}
	if(c == ';' || c == '[' || c == ']') (*pos)--;
	return(value);
}
Пример #11
0
wxString CodeParser::GetFunctionContents(wxString function)
{
    wxString contents = wxT("");
    Function *func;

    m_functionIter = m_functions.find(RemoveWhiteSpace(function));
    if (m_functionIter != m_functions.end())
    {
        func = m_functionIter->second;
        contents = func->GetContents();
        m_functions.erase(m_functionIter);
        delete func;
    }
    return contents;
}
Пример #12
0
int ExportSolarPhenotype (individual *indlist)
{
  individual *ind;
  char mkrname[NAMESIZE], tempstr[NAMESIZE];
  int i;
  double currentpos, value;
  

  currentpos = 0;
  // Makes the marker file
  cfopen ("solar.phe", "w");

  // Prints the trait names
  fprintf(F,"id");
  for (i = 1; i<=numberoftraits(); i++)
  {
    // Remove white spaces in marker name
    RemoveWhiteSpace(tempstr, GetName(traitnames, i));
    strncpy(mkrname, tempstr, 18);

    fprintf(F, ",%s", mkrname);
  }
  fprintf(F,"\n");

  for (ind = indlist; ind; ind = ind->next)
  {
    fprintf(F, "%s", ind->id);
    for (i = 1; i<=numberoftraits(); i++)
    {
      fprintf(F, ",");
      if (!traitmiss(ind, i)) {
	value = trait(ind, i);
	// Print only integer part if it is an integer
	if ( (int) value == value) {
	  fprintf(F, "%d", (int) value);
	}
	else {
	  fprintf(F, "%f", value);
	}
      }
    }
    fprintf(F,"\n");
  }

  fclose(F);
  puts("Made Solar phenotype file");
  return 0;
}
Пример #13
0
void ExportMendelMap() {
  int i;
  char minibuf[10], tempstr[NAMESIZE];

  cfopen ("mendel.map", "w");

  for (i = 1; i<=numberofmarkers(); i++) {
    RemoveWhiteSpace(tempstr, GetName(markernames, order[i]));
    strncpy(minibuf, tempstr, 8);
    minibuf[8] = '\0';
    if (i<numberofmarkers()) {
      fprintf(F, "%-8s\n        %8.5f\n", minibuf, distance[i]);
    }
    else {
      fprintf(F, "%-8s\n", minibuf);
    }
  }

  fclose(F);
  
}
Пример #14
0
void
openGL_function_info::
SetNames(const string &functionName,
         const string &returnType,
         string &argList)
{
  argIterType i;
  string::size_type comma_place,last_comma_place;
  string::size_type start,end;
  ostringstream argListWithNames,argListWithoutNames,argListOnly;
  string tempString,arg;
  int j;

  m_functionName=RemoveWhiteSpace(functionName);


  if(returnType.length()!=0)
    {
      start=returnType.find_first_not_of(' ');
      end=returnType.find_last_not_of(' ');
      m_returnType=returnType.substr(start,end-start+1);
    }
  else
    {
      m_returnType="";
    }

  m_returnsValue=(m_returnType!="void") && (m_returnType!="GLvoid");

  m_pointerToFunctionTypeName="PFN"+m_functionName+"PROC";
  for(j=0;j<(int)m_pointerToFunctionTypeName.length();++j)
    {
      m_pointerToFunctionTypeName[j]=toupper(m_pointerToFunctionTypeName[j]);
    }


  if(argList!="void" && argList!="GLvoid")
    {
      argList=argList;
    }
  else
    {
      argList="";
    }

  //if argList is non-empy it may have one or more argument lists.
  last_comma_place=argList.find_first_of(',');
  if(last_comma_place!=string::npos)
    {

      arg=argList.substr(0,last_comma_place);
      GetTypeAndNameFromArgumentEntry(arg,tempString);
      m_argTypes.push_back(pair<string,string>(tempString,arg));

      //argList has atleast 2 arguments
      last_comma_place++;

      //now last_command_place is at the location just past the first comma.
      for(j=1, comma_place=argList.find_first_of(',',last_comma_place);
          comma_place!=string::npos && comma_place<argList.length();
          comma_place=argList.find_first_of(',',last_comma_place), ++j)
        {
          //add to the end all that was between
          //last_comma_place and comma_place.
          arg=argList.substr(last_comma_place,comma_place-last_comma_place);
          GetTypeAndNameFromArgumentEntry(arg, tempString);
          m_argTypes.push_back(pair<string,string>(tempString,arg));

          last_comma_place=comma_place+1;
        }
      //now there is also the last argument...
      arg=argList.substr(last_comma_place);
      GetTypeAndNameFromArgumentEntry(arg,tempString);
      m_argTypes.push_back(pair<string,string>(tempString,arg));




    }
  else if(argList.size()!=0)
    {
      GetTypeAndNameFromArgumentEntry(argList,tempString);
      m_argTypes.push_back(pair<string,string>(tempString,argList));
    }



  //now go through the list of argtype to
  //build our argument lsit with and without names
  for(j=0, i=m_argTypes.begin();i!=m_argTypes.end();++i, ++j)
    {
      if(j!=0)
        {
          argListWithNames <<",";
          argListWithoutNames <<",";
          argListOnly<<",";
        }

      argListWithNames << i->first << " " << argument_name() << j;
      argListWithoutNames << i->first;
      argListOnly << " " << argument_name() << j;
    }

  m_argListWithNames=argListWithNames.str();
  m_argListWithoutNames=argListWithoutNames.str();
  m_argListOnly=argListOnly.str();

  m_functionPointerName=sm_function_prefix+"function_ptr_"+m_functionName;
  m_debugFunctionName=sm_function_prefix+"debug_function__"+m_functionName;
  m_localFunctionName=sm_function_prefix+"local_function_"+m_functionName;
  m_doNothingFunctionName=sm_function_prefix+"do_nothing_function_"+m_functionName;
  m_existsFunctionName=sm_function_prefix+"exists_function_"+m_functionName;
  m_getFunctionName=sm_function_prefix+"get_function_ptr_"+m_functionName;
}
Пример #15
0
void CCodeParser::ParseSourceFunctions(wxString code)
{
    int functionStart = 0;
    int functionEnd = 0;
    int previousFunctionEnd = 0;
    wxString funcName, funcArg;
    Function *func;
    wxString Str, R;

    int loop = 0;
    while (1)
    {
        //find the begining of the function name
        Str = m_className + wxT("::");
        functionStart = code.find(Str, previousFunctionEnd);
        if (functionStart == wxNOT_FOUND)
        {
            //Get the last bit of remaining code after the last function in the file
            m_trailingCode = code.Mid(previousFunctionEnd);
            m_trailingCode.RemoveLast();
            return;
        }
        //found a function now creat a new function class
        func = new Function();

        //find the begining of the line on which the function name resides
        functionStart = code.rfind('\n', functionStart);
        func->SetDocumentation(code.Mid(previousFunctionEnd, functionStart - previousFunctionEnd));
        functionStart++;

        functionEnd = code.find('{', functionStart);
        wxString heading = code.Mid(functionStart, functionEnd - functionStart);
        if(heading.Right(1) == '\n')
        {
            heading.RemoveLast();
        }
        func->SetHeading(heading);

        m_functions[RemoveWhiteSpace(heading)] = func;

        //find the opening brackets of the function
        func->SetContents(ParseBrackets(code,  functionStart));
        if (functionStart != wxNOT_FOUND)
        {
            functionEnd = functionStart;
        }
        else
        {
            wxMessageBox(wxT("Brackets Missing in Source File!"));
            code.insert(functionEnd +1, wxT("//The Following Block is missing a closing bracket\n//and has been set aside by wxFormbuilder\n"));
            func->SetContents(wxT(""));
        }

        previousFunctionEnd = functionEnd;
        if (loop == 100)
        {
            return;
        }
        loop++;
    }
}
Пример #16
0
INT IIS_ScanCmdl(INT argc, TEXTCHAR* argv[], const TEXTCHAR* str, ...)
{
    INT i              = 0;
    INT found_and_set  = 0;
    INT nArgs          = 0;
    INT* switches_used = 0;
    INT*   b_str_opt   = 0;
    TEXTCHAR*  s_str       = 0;
    TEXTCHAR*  c_str_type  = 0;
    TEXTCHAR*  str_clean   = 0;

    va_list ap;

    if (argc == 0 || argc == 1)
    {
        FDKprintf("No command line arguments\n");
        goto bail;
    }

    str_clean  = (TEXTCHAR*)  FDKcalloc((unsigned int)_tcslen(str), sizeof(TEXTCHAR));
    if (str_clean == NULL) {
        FDKprintf("Error allocating memory line %d, file %s\n",  __LINE__, __FILE__);
        return 0;
    }

    RemoveWhiteSpace(str, str_clean );
    GetNumberOfArgs(str_clean, &nArgs);

    b_str_opt  = (INT*)   FDKcalloc(nArgs,    sizeof(INT));
    s_str      = (TEXTCHAR*)  FDKcalloc(nArgs*CMDL_MAX_ARGC, sizeof(TEXTCHAR) );
    c_str_type = (TEXTCHAR*)  FDKcalloc(nArgs,    sizeof(TEXTCHAR));
    switches_used = (INT*) FDKcalloc(argc, sizeof(INT));

    if (b_str_opt == NULL || s_str == NULL || c_str_type == NULL || switches_used == NULL) {
        FDKprintf("Error allocating memory line %d, file %s\n",  __LINE__, __FILE__);
        goto bail;
    }

    if ( ParseString( str_clean, b_str_opt, s_str, c_str_type )) {
        goto bail;
    }

    va_start(ap, str);

    for ( i = 0; i < nArgs; i++ )
    {
        TEXTCHAR arg[CMDL_MAX_STRLEN] = {L'\0'};
        TEXTCHAR* p_arg = arg;
        TEXTCHAR* current_str = &(s_str[i*CMDL_MAX_ARGC]);

        if (GetArgFromString(argc, argv, current_str, c_str_type[i], arg, switches_used )
                && !b_str_opt[i] )
        {
#ifdef _UNICODE
            _ftprintf(stderr, _TEXT("\n\nError: Parsing argument for required switch '%ls'.\n" ), current_str);
#else
            _ftprintf(stderr, _TEXT("\n\nError: Parsing argument for required switch '%s'.\n" ), current_str);
#endif
            found_and_set = 0;
            goto bail;
        }
        if (CheckArg(p_arg, s_str, nArgs, c_str_type[i], current_str))
        {
            goto bail;
        }

        switch (c_str_type[i] )
        {
        case 's':
        {
            TEXTCHAR* tmp;
            tmp = va_arg(ap, TEXTCHAR*);

            if ( arg[0] == '\0' )
                break;

            _tcsncpy( tmp, arg, CMDL_MAX_STRLEN );
            /* Remove quotes. Windows Mobile Workaround. */
            removeQuotes(tmp);
            found_and_set++;
            break;
        }
        case 'd':
        {
            INT* tmp = va_arg(ap, INT*);

            if ( arg[0] == '\0' )
                break;

            *tmp = _tcstol(arg, NULL, 0);
            found_and_set++;
            break;
        }
        case 'c':
        {
            char* tmp = va_arg(ap, char*);

            if ( arg[0] == '\0' )
                break;

            *tmp = *arg;
            found_and_set++;
            break;
        }
        case 'u':
        {
            UCHAR* tmp = va_arg(ap, UCHAR*);

            if ( arg[0] == '\0' )
                break;

            *tmp = _tstoi(arg);
            found_and_set++;
            break;
        }
        case 'f':
        {
            float* tmp = (float*) va_arg( ap,double*);

            if ( arg[0] == '\0' )
                break;

            *tmp = (float) _tstof(arg);
            found_and_set++;
            break;
        }
        case 'y': // support 'data type double'
        {
            double* tmp = (double*) va_arg( ap,double*);
            // use sscanf instead _tstof because of gcc
            //_tstof(arg,"%lf",tmp); // '%lf' reads as double
            *tmp = _tstof(arg); // '%lf' reads as double
            found_and_set++;
            break;
        }
        case '1':
        {

            INT* tmp = va_arg( ap, INT*);

            if ( arg[0] == '\0' )
                break;

            *tmp = 1;
            found_and_set++;
            break;
        }

        default:
            FDKprintfErr("Bug: unsupported data identifier \"%c\"\n", c_str_type[i]);
            break;

        }

    }

    va_end(ap);

    CheckForUnusedSwitches(argc, /*argv,*/ switches_used);

bail:
    if (b_str_opt)     FDKfree(b_str_opt);
    if (s_str)         FDKfree(s_str);
    if (c_str_type)    FDKfree(c_str_type);
    if (str_clean)     FDKfree(str_clean);
    if (switches_used) FDKfree(switches_used);

    return found_and_set;
}
Пример #17
0
int RemoveWhiteSpaceTest()
{
	// Causes a null pointer reference, sometimes, not actually
	{
		std::string expected = "foo/bar/f****d/up/beoynd/regonization";
		std::string result = RemoveWhiteSpace( expected );
		test_assert( result == expected );
	}

	// some basic testing
	{
		test_assert( RemoveWhiteSpace( "  \t \t		\t  \t \t \t" ) == "" );

		test_assert( RemoveWhiteSpace( " a" ) == "a" );
		test_assert( RemoveWhiteSpace( "a " ) == "a" );
		test_assert( RemoveWhiteSpace( " a " ) == "a" );

		test_assert( RemoveWhiteSpace( "\ta" ) == "a" );
		test_assert( RemoveWhiteSpace( "a\t" ) == "a" );
		test_assert( RemoveWhiteSpace( "\ta\t" ) == "a" );

		test_assert( RemoveWhiteSpace( " \ta" ) == "a" );
		test_assert( RemoveWhiteSpace( "a\t " ) == "a" );
		test_assert( RemoveWhiteSpace( " \ta\t " ) == "a" );

		test_assert( RemoveWhiteSpace( " a a" ) == "a a" );
		test_assert( RemoveWhiteSpace( "a a " ) == "a a" );
		test_assert( RemoveWhiteSpace( " a a" ) == "a a" );

		test_assert( RemoveWhiteSpace( "\ta a" ) == "a a" );
		test_assert( RemoveWhiteSpace( "a a\t" ) == "a a" );
		test_assert( RemoveWhiteSpace( "\ta a\t" ) == "a a" );

		test_assert( RemoveWhiteSpace( " \ta a" ) == "a a" );
		test_assert( RemoveWhiteSpace( "a a\t " ) == "a a" );
		test_assert( RemoveWhiteSpace( " \ta a\t " ) == "a a" );
	}

	srand((unsigned)time(0));

	// testing with big strings
	{
		std::string test_me;
		std::string expected;
		int length = 100;

		// Leading whitespace
		{
			// generate white space
			{
				for( int i = 0; i < length; i++ )
				{

					int len = rand()%100;
					for( int j = 0; j < len; j++ )
					{
						test_me += rand()%2?" ":"\t";
					}
				}
			}

			{
				for( int i = 0; i < length; i++ )
				{
					expected += "foo bar";
					expected += "foo\tbar";
					test_me += "foo bar";
					test_me += "foo\tbar";
				}
			}

			test_assert( RemoveWhiteSpace( test_me ) == expected );
		}

		test_me = "";
		expected = "";

		// Trailing whitespace
		{
			{
				for( int i = 0; i < length; i++ )
				{
					expected += "foo bar";
					expected += "foo\tbar";
					test_me += "foo bar";
					test_me += "foo\tbar";
				}
			}

			// generate white space
			{
				for( int i = 0; i < length; i++ )
				{

					int len = rand()%100;
					for( int j = 0; j < len; j++ )
					{
						test_me += rand()%2?" ":"\t";
					}
				}
			}


			test_assert( RemoveWhiteSpace( test_me ) == expected );
		}

		test_me = "";
		expected = "";

		// Whitespace everywhere
		{
			// generate white space
			{
				for( int i = 0; i < length; i++ )
				{

					int len = rand()%100;
					for( int j = 0; j < len; j++ )
					{
						test_me += rand()%2?" ":"\t";
					}
				}
			}


			{
				for( int i = 0; i < length; i++ )
				{
					expected += "foo bar";
					expected += "foo\tbar";
					test_me += "foo bar";
					test_me += "foo\tbar";
				}
			}

			// generate white space
			{
				for( int i = 0; i < length; i++ )
				{

					int len = rand()%100;
					for( int j = 0; j < len; j++ )
					{
						test_me += rand()%2?" ":"\t";
					}
				}
			}


			test_assert( RemoveWhiteSpace( test_me ) == expected );
		}

	}


	return 0;
}
Пример #18
0
BOOL WINPROC EXPORT DlgOpenProc(
/************************************************************************/
HWND 	hDlg,
UINT 	msg,
WPARAM 	wParam,
LPARAM 	lParam)
{
BOOL Bool;
ITEMID id;
WORD wMsg, wIndex;
int i, ii, l, fp, hi, lo;
FNAME szDriveNDir, szFileName, szExtension;
HMENU hMenu;
STRING szString;
char cChar;
BOOL bModifySaveName;
static BOOL bDisableCancel;

switch (msg)
    {
    case WM_INITDIALOG:
	SET_CLASS_HBRBACKGROUND(hDlg, ( HBRUSH )GetStockObject(LTGRAY_BRUSH));
	CenterPopup( hDlg );
	if ( !DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr) )
		{
		lstrcpy( szFileSpec, lstrchr( szFileSpec, '*' ) );
		DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr);
		}
	SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving);
	CheckComboItem( hDlg, IDC_FILETYPES, IDC_ART, IDC_BMP,
		IDC_ART + (idFileType-IDN_ART) );
	SendDlgItemMessage(hDlg, IDC_FNAME, EM_LIMITTEXT, MAX_FNAME_LEN-1, 0L);

	LoadComboWithDrives( hDlg, IDC_DRIVES );
	LoadComboWithDirectories( hDlg, IDC_DIRS, NO );
	CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath );
	CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed );
	for (i = IDC_ART; bImageOpen && i <= IDC_BMP; ++i)
		{
		ii = i-IDC_ART;
		if (lstrlen(Readers[ii].szDLL))
			{
			lstrcpy(szString, Control.ProgHome);
			lstrcat(szString, Readers[ii].szDLL);
			if (!FileExists(szString))
				{
				if ( GetPrivateProfileString( "Micrografx", "Libraries", "",
					szString, sizeof(STRING), "MGX.INI" ) > 2 )
						FixPath( szString );
				lstrcat(szString, Readers[ii].szDLL);
				if (!FileExists(szString))
					{
					ControlEnable( hDlg, i, NO);
					continue;
					}
				}
			}
		if (fSaving)
			ControlEnable( hDlg, i, lpImage &&
				Readers[ii].bSave[FrameDepth(ImgGetBaseEditFrame(lpImage))] );
		else
			ControlEnable( hDlg, i, Readers[ii].bOpen );
		}
	if ( bImageOpen && lpImage )
		{
		idDataType = lpImage->DataType;
		for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i)
			ControlEnable( hDlg, i,
			Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]);
		CheckComboItem( hDlg, IDC_DATATYPES, IDC_SAVECT,
			IDC_SAVE24BITCOLOR, idDataType );
		ControlEnable( hDlg, IDC_SAVECOMPRESS,
			Readers[idFileType-IDN_ART].bCompressed );
		}

	SetFocus( GetDlgItem( hDlg, IDC_FNAME ) );
	SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL,
		NULL, MAKELONG(0, 0x7fff));
	bNavigated = NO;
	bDisableCancel = NO;
	return( FALSE );

    case WM_PALETTECHANGED:
	break;

    case WM_MENUSELECT:
	lo = LOWORD(lParam);
	hi = HIWORD(lParam);
	if (hi == 0)
		break;
	if (lo == -1)
		break;
	if (lo & MF_SYSMENU)
		break;
	if (lo & MF_POPUP)
		{
		hMenu = (HMENU)wParam;
		while (GetSubMenu(hMenu, 0))
			hMenu = GetSubMenu(hMenu, 0);
		id = GetMenuItemID(hMenu, 0);
		if (id <= 0)
			break;
		wParam = id - 1;
		}
	HintLine( wParam );
	break;

    case WM_SETCURSOR:
	return( SetupCursor( wParam, lParam, idOpen ) );

    case WM_CLOSE:
	AstralDlgEnd( hDlg, FALSE|2 );
	break;

    case WM_MEASUREITEM:
    case WM_DRAWITEM:
	id = ((LPDRAWITEMSTRUCT)lParam)->CtlID;
	Bool = ( id == IDC_DRIVES || id == IDC_DIRS );
	return( OwnerDraw( hDlg, msg, lParam, Bool ) );
//	break;

    case WM_CTLCOLOR:
	return( (BOOL)SetControlColors( (HDC)wParam, hDlg, (HWND)LOWORD(lParam),
		HIWORD(lParam) ) );

    case WM_COMMAND:
	if (wParam != IDCANCEL)
		bDisableCancel = NO;
	switch(wParam)
	    {
	    case IDC_FILETYPES:
//	    case IDC_ART:
//	    case IDC_TIFF:
//	    case IDC_BMP:
		if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) )
			break;
		idFileType = IDN_ART + (wParam-IDC_ART);
		if (bNavigated)
			{
			LookupExtension( idFileType, szFileSpec );
			}
		else	GetFileLocation( idFileType, szFileSpec );
		for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i)
			ControlEnable( hDlg, i,
			Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]);
		ControlEnable( hDlg, IDC_SAVECOMPRESS,
			Readers[idFileType-IDN_ART].bCompressed );
		SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO );
		SendMessage( hDlg, WM_COMMAND, IDOK, 0L );
		break;

	    case IDC_DATATYPES:
//	    case IDC_SAVECT:
//	    case IDC_SAVELA:
//	    case IDC_SAVESP: // scatterprint
//	    case IDC_SAVE8BITCOLOR:
//	    case IDC_SAVE24BITCOLOR:
		if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) )
			break;
		idDataType = wParam;
		break;

	    case IDC_SAVEPATH:
		Save.OKtoSavePath = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVEPATH,
		  BM_GETCHECK, 0, 0L);
//		Save.OKtoSavePath = !Save.OKtoSavePath;
//		CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath );
		break;

	    case IDC_SAVECOMPRESS:
		Save.Compressed = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVECOMPRESS,
		  BM_GETCHECK, 0, 0L);
//		Save.Compressed = !Save.Compressed;
//		CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed );
		break;

	    case IDC_DRIVES:
		wMsg = HIWORD(lParam);
		if ( wMsg != CBN_SELCHANGE )
			break;
		wIndex = SendDlgItemMessage( hDlg, wParam, CB_GETCURSEL, 0, 0L);
		SendDlgItemMessage( hDlg, wParam, CB_GETLBTEXT, wIndex,
			(long)(LPSTR)szDriveNDir );
		id = ExtractStringID( szDriveNDir );
		if (CHDRIVE( *szDriveNDir - 'a' ))
			{
			LoadComboWithDrives(hDlg, IDC_DRIVES);
			break;
			}
		if (!CURRENTDIR(szString, sizeof(szString)))
			{
			GetDlgItemText(hDlg, IDC_FPATH, szString,
				 sizeof(szString));
			CHDRIVE(*szString - 'a');
			LoadComboWithDrives(hDlg, IDC_DRIVES);
			}
//12/15		SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO);
		DlgDirList( hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr );
		LoadComboWithDirectories( hDlg, IDC_DIRS, YES );
		SetDlgItemText( hDlg, IDC_DISKSPACE,
			DriveSize( *szDriveNDir - 'a', szString ) );
		SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving );
		bNavigated = YES;
		break;

	    case IDC_DIRS:
		wMsg = HIWORD(lParam);
		if ( wMsg == LBN_DBLCLK )
			{
			SendMessage(hDlg, WM_COMMAND, IDOK, 1L);
			break;
			}
		if ( wMsg != LBN_SELCHANGE )
			break;
		wIndex = SendDlgItemMessage( hDlg, wParam, LB_GETCURSEL, 0, 0L);
		// Figure out how to build the path name based on the selection
		SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, wIndex,
			(long)(LPSTR)szDriveNDir );
		id = ExtractStringID( szDriveNDir );
		if ( id == IDC_PATHICON_OPEN )
			i = 0; // Must start building the path from the root
		else
		if ( id == IDC_PATHICON_ACTIVE )
			i = 9999; // Don't build any path - we're there
		else	i = wIndex; // OK to build a relative path
		szFileName[0] = '\0';
		for ( ; i<=wIndex; i++ )
			{
			SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, i,
				(long)(LPSTR)szDriveNDir );
			id = ExtractStringID( szDriveNDir );
			if ( id == IDC_PATHICON_CLOSED && i != wIndex )
				continue;
			lstrcat( szFileName, SkipSpaces(szDriveNDir) );
			if ( id != IDC_PATHICON_ROOT )
				lstrcat( szFileName, "\\" );
			}
		lstrcat( szFileName, szFileSpec );
		SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO );
		bNavigated = YES;
		break;

	    case IDC_FLIST:
		wMsg = HIWORD(lParam);
		if ( wMsg == LBN_DBLCLK )
			{
			SendMessage(hDlg, WM_COMMAND, IDOK, 1L);
			break;
			}
		if ( wMsg != LBN_SELCHANGE )
			break;
		/* If a directory is selected... */
		if (DlgDirSelectEx(hDlg, szFileName, sizeof(szFileName), wParam))
			lstrcat(szFileName, szFileSpec);
		// 1-2-92 - TMR - always use SetFileName for all FNAME sets
// 		SetDlgItemText(hDlg, IDC_FNAME, szFileName);
		SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO );
		SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL,
			NULL, MAKELONG(0, 0x7fff));
//		SendDlgItemMessage(hDlg, IDC_FNAME, CB_SETEDITSEL,
//			NULL, MAKELONG(0, 0x7fff));
		break;

	    case IDC_FNAME:
		/* If the name is changed, disable OK if its length goes 0 */
		if (HIWORD(lParam) != EN_CHANGE)
//		if (HIWORD(lParam) != CBN_EDITCHANGE)
			break;
		ControlEnable( hDlg, IDOK,
			(BOOL)SendDlgItemMessage( hDlg, wParam,
			WM_GETTEXTLENGTH, 0, 0L));
		
		// 1-2-92 - TMR - make sure Edit Box has focus to make sure
		// that szSaveName only gets overwritten from user input
		// 1-3-92 - TMR - move this after ControlEnable
		if (GetFocus() != GetDlgItem(hDlg, IDC_FNAME))
			break;
		if (fSaving)
			{
			GetDlgItemText(hDlg, IDC_FNAME, szSaveName,
				MAX_FNAME_LEN);
			fUntitled = NO;
			}
		break;

	    case IDC_FPATH:
		wMsg = HIWORD(lParam);
		if ( wMsg == BN_DOUBLECLICKED )
			{
			SendMessage(hDlg, WM_COMMAND, IDOK, 1L);
			break;
			}
		if ( wMsg != BN_CLICKED )
			break;
 		GetDlgItemText(hDlg, wParam, szFileName, sizeof(szFileName));
		if ( !szFileName[0] )
			break;
		FixPath( szFileName );
		lstrcat( szFileName, szFileSpec );
		SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO );
		bNavigated = YES;
		break;

	    case IDOK:
		GetDlgItemText(hDlg, IDC_FNAME, szFileName,sizeof(szFileName));
		bModifySaveName = fSaving && StringsEqual(szFileName,
			szSaveName);
		/* Strip off the drive and directory to make */
		/* a DlgDirlist() call to switch over to them */
		/* Loop backwards over the file name */
		l = lstrlen(szFileName);
		while( --l >= 0 )
		   {
		   cChar = szFileName[l];
		   /* If we find a wildcard, the next DlgDirList() takes */
		   /* care of drive and directory switching; so get out */
		   if ( cChar == '?' || cChar == '*' )
			break;
		   /* If we find a drive or directory, handle it and get out */
		   if ( cChar == '\\' || cChar == ':' )
			{
			lstrcpy(szDriveNDir, szFileName);
			l++;
			szDriveNDir[l] = '\0';
			lstrcat(szDriveNDir, szFileSpec);
			// 1-3-92 - TMR - Handle directory change error
			if (DlgDirList(hDlg, szDriveNDir,
					 IDC_FLIST, IDC_FPATH, wFileAttr))
				lstrcpy( szFileName, &szFileName[l] );
			else
				{
				szDriveNDir[l] = '\0';
				Message(IDS_EDIRECTORYCHANGE,
					 Lowercase(szDriveNDir));
				szFileName[0] = '\0';
				}
			break;
			}
		   }

		// 1-3-92 - TMR add extension if none present
		/* Check to see if the file has an extension... */
		if ( !lstrchr( szFileName, '.' ) ) // if no extension...
		    if ( LookupExtension( idFileType, szExtension ) )
			{
			if (lstrlen(szFileName))
			    lstrcat( szFileName, extension(szExtension) );
			else
			    lstrcat( szFileName, szExtension);
			}
		if (bModifySaveName)
			lstrcpy(szSaveName, szFileName);

		/* Try to display a new list box */
		if ( !szFileName[0] )
			lstrcat(szFileName, szFileSpec);
		if (DlgDirList(hDlg, szFileName, IDC_FLIST, IDC_FPATH,
		    wFileAttr))
			{ /* A wildcard was found and a new list displayed */
			lstrcpy(szFileSpec, szFileName);
			SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName,
				fSaving );
			LoadComboWithDrives( hDlg, IDC_DRIVES );
			LoadComboWithDirectories( hDlg, IDC_DIRS, YES );
			
			break;
			}

		// If there is still a path or wildcards in the name, the
		// file specification must be invalid
		if (lstrchr(szFileName, '\\') || lstrchr(szFileName, ':') ||
		    lstrchr(szFileName, '?') || lstrchr(szFileName, '*'))
			{
			lstrcpy(szString, szFileName);
			stripfile(szString);
			Message(IDS_EDIRECTORYCHANGE, Lowercase(szString));
			lstrcpy(szFileSpec, filename(szFileName));
			lstrcpy(szFileName, szFileSpec); // is this needed?
			SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName,
				fSaving );
			break;
			}

		/* No wildcards, and the drive and dir have been changed */
		LoadComboWithDrives( hDlg, IDC_DRIVES );
		LoadComboWithDirectories( hDlg, IDC_DIRS, YES );

		/* Check to see if the file has 8 characters or less... */
		if ( fSaving )
			RemoveWhiteSpace( szFileName );
		FixFileName( szFileName );

		/* Check to see if the file has an extension... */
		if ( !lstrchr( szFileName, '.' ) ) // if no extension...
			if ( LookupExtension( idFileType, szExtension ) )
				lstrcat( szFileName, extension(szExtension) );

		// Build the fully qualified path name
		GetDlgItemText( hDlg, IDC_FPATH, szString, sizeof(szString) );
		FixPath( szString );
		lstrcat( szString, szFileName );

		/* Check to see if the file exists... */
		if ( (fp = _lopen( szString, OF_READ ) ) < 0 )
			{ /* The file does not exist */
			if ( !fSaving )
				{
				Message(IDS_EOPEN, Lowercase(szString));
				break;
				}
			}
		else	{
			_lclose( fp );
			if ( fSaving )
				{
				if ( !AstralAffirm( IDS_OVERWRITEIMAGE,
					Lowercase(szString) ) )
					break;
				}
			}

		lstrcpy( szFileSpec, szString );
		AstralDlgEnd(hDlg, TRUE|2);
		break;

	    case IDC_CANCEL:
	    case IDCANCEL:
		if ( bDisableCancel && !LOWORD(lParam) )
			break;
		GetDlgItemText(hDlg, IDC_FPATH, szFileSpec,sizeof(szFileSpec));
		AstralDlgEnd(hDlg, FALSE|2);
		break;

	    default:
		return( FALSE );
	    }
	break;

    default:
	return( FALSE );
    }

return( TRUE );
}
// ---------------------------------------------------------------------------------
// CUpnpTmFilteredAppList::ParseAppFilterStringL
// Method parses the descriptor containing the filter string
// It parses the comma-separated list of A_ARG_TYPE_AppList schema 
// elements, attributes and their values
// eg: "name="*Audio*",description="*",icon@mimetype="*svg+xml*", remotingInfo@protocolID="*",
//     appInfo@appCategory="*",audioInfo@audioType="*",resourceStatus="free",signature="*""
// @param aAppFilter Buffer containing application filter string
// @param aErr[out]  Terminal Mode error code
// ---------------------------------------------------------------------------------
//
void CUpnpTmFilteredAppList::ParseAppFilterStringL( const TDesC8& aAppFilter, 
                                                     TTerminalModeErrorCode& aErr )
    {
    OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL_ENTRY );
    // Validate the filter string
    aErr = ETerminalModeSuccess;
    TInt quotePos = aAppFilter.Locate( KQuote );
    if ( ( quotePos != 0 ) || ( aAppFilter.Find(KDoubleQuote) == KErrNotFound ))    
        {
        // corrupt filter string
        aErr = ETerminalModeInvalidArgument;
        OstTrace1( TRACE_ERROR, DUP2_CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL, "CUpnpTmFilteredAppList::ParseAppFilterStringL;quotePos=%d", quotePos );
        return;
        }
    RBuf8 filterBuffer;
    CleanupClosePushL(filterBuffer);
    /* Create a buffer having the content of AppFilter buffer but without 
       the leading quote(")  */ 
    filterBuffer.CreateL(aAppFilter.Mid(quotePos+1));
    TInt equalToQuoteToken;
    while( ( equalToQuoteToken = filterBuffer.Find(Keq)) != KErrNotFound )
        {
        // Fetch the full key string
        TPtrC8 key = filterBuffer.Left(equalToQuoteToken);
        // Check for the presence of sub element by checking the @ in the key string
        TInt atTokenPos = key.Find(KAtToken);
        TBool displayInfo(EFalse);
        if ( atTokenPos != KErrNotFound )
            {
            // @ is found in the key string
            // Now extract the parent element
            TPtrC8 parentKey = key.Left(atTokenPos);
            //Remove any leading and trailing whitespaces in the parent element
            const TDesC8& parentKeyWithoutSpace = RemoveWhiteSpace(parentKey);
            // Check if the parent elemet is one of desired element or not.
            // It should be one of the following :
            // <1> icon <2> remotingInfo <3> appInfo <4> displayInfo <5> audioInfo
            if ( ( parentKeyWithoutSpace.Compare(KIconElement) != KErrNone ) &&
                ( parentKeyWithoutSpace.Compare(KRemotingInfo) != KErrNone ) &&
                ( parentKeyWithoutSpace.Compare(KAppInfo) != KErrNone ) &&
                ( parentKeyWithoutSpace.Compare(KDisplayInfo) != KErrNone ) &&
                ( parentKeyWithoutSpace.Compare(KAudioInfo) != KErrNone ) )
                {
                // parent element is not proper
                aErr = ETerminalModeInvalidArgument;   
                break;
                }
            if ( parentKeyWithoutSpace.Compare(KDisplayInfo) == KErrNone )
                {
                // The parent key element is displayInfo
                displayInfo = ETrue;   
                }
            // Fetch the actual key name ( child element )
            key.Set(key.Mid(atTokenPos+1));
            }
        
        //Remove any leading and trailing whitespaces in the key 
        const TDesC8& keyWithoutSpace = RemoveWhiteSpace(key);
        if ( (filterBuffer.Mid(equalToQuoteToken) ).Locate(KQuote) != 1 )
            {
            // Missing quote(") ahead of the value
            aErr = ETerminalModeInvalidArgument;
            break;    
            }
        TPtrC8 bufPtr = filterBuffer.Mid(equalToQuoteToken+2);
        quotePos = bufPtr.Locate( KQuote );
        if ( quotePos == KErrNotFound )
            {
            // missing quote (") at the end of the value
            aErr = ETerminalModeInvalidArgument;
            break;
            }
        
        /* Add the filter info as key-value pairs.
        // Also check if the parent key is display info.
           If display info flag is true then use the method with non default parameter */
        if ( displayInfo )
            {
            iFilterInfo->SetFilterInfoL( keyWithoutSpace, bufPtr.Left(quotePos), aErr, ETrue );
            }
        else
            {
            // Use the method with default parameter
            iFilterInfo->SetFilterInfoL( keyWithoutSpace, bufPtr.Left(quotePos), aErr );   
            }
        if ( aErr != ETerminalModeSuccess )
            {
            // Return the error code in case the key element is not as per the schema
            aErr = ETerminalModeInvalidArgument;
            break;
            }
        // Skip the quote position and set the buffer
        bufPtr.Set(bufPtr.Mid(quotePos+1));
        if ( ( bufPtr.Locate(KCommaSeparator) != 0 ) && ( bufPtr.Locate(KQuote) != 0 ) )
            {
            //  missing quote (") or comma (,) following the quote.
            //  Expected to be something of this kind ( ", or "" )
            aErr = ETerminalModeInvalidArgument;
            break;      
            }
        //Copy the residual content skipping two characters(", or "" ) in the actual buffer
        filterBuffer.Copy(bufPtr.Mid(UpnpString::KLinefeedLength));
        }
    CleanupStack::PopAndDestroy(&filterBuffer);
    OstTrace1( TRACE_FLOW, CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL, "CUpnpTmFilteredAppList::ParseAppFilterStringL;aErr=%d", aErr );
    OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL_EXIT );
    }
Пример #20
0
int ExportCRIMAPGen(individual *indlist, int xlinked)
{
  individual *ind;
  
  namelist *pedigree, *ped;
  markerlist *mkr;
  char mkrname[NAMESIZE], tempstr[NAMESIZE];
  int nFamilies, nLoci, i, nInternalID, nMembers, al1, al2, pseudoal;

  nLoci = listlen(indlist->marker);
  pedigree = MakePedigreeList(indlist);
  nFamilies = listlen(pedigree);

  cfopen ("crimap.gen", "w");
  fprintf(F, "%d %d", nFamilies, nLoci);  // The first line

  // Prints the markers in the correct order
  for (i = 1; i<= nLoci; i++)
  {
    // Remove white spaces in marker name
    RemoveWhiteSpace(tempstr, GetName(markernames, order[i]));
    strncpy(mkrname, tempstr, 15);
    fprintf(F, " %s", mkrname);
  }
  fprintf(F, "\n");

  // Fixes internal id's for use below
  for (ped = pedigree; ped; ped = ped->next)
  {
    nInternalID = 1;
    for (ind = indlist; ind; ind = ind->next)
    {
      // From the right pedigree
      if (!strcmpl(ind->pedigree, ped->name))
      {
        ind->localid = nInternalID;
        nInternalID++;
      }
    }    
  }  

  // Writes each family 
  for (ped = pedigree; ped; ped = ped->next)
  {
    // Family name
    fprintf(F, "%s\n", ped->name); 

    nMembers = 0;
    // Count the number of family members
    for (ind = indlist; ind; ind = ind->next)
    {
      // From the right pedigree
      if (!strcmpl(ind->pedigree, ped->name))
	nMembers++;
    }
    fprintf(F, "%d\n", nMembers);

    for (ind = indlist; ind; ind = ind->next)
    {
      // From the right pedigree
      if (!strcmpl(ind->pedigree, ped->name))
      {
        if (founder(ind))
          fprintf(F, "%d 0 0 ", ind->localid);
        else
          fprintf(F, "%d %d %d ", ind->localid, ind->father->localid, ind->mother->localid);

        switch (ind->sex)
	{
	  case S_MALE:   fprintf(F, "1"); break;
	  case S_FEMALE: fprintf(F, "0"); break;
 	  default:       fprintf(F, "3"); break;
	}

	// Should now print the alleles for each locus

	// If xlinked, then create a pseudo allele for each marker
	// to make the males heterozygous
        for (i = 1; i<= nLoci; i++)
	{
          mkr = markernumber(ind, order[i]);
	  al1 = mkr->allele1;
	  al2 = mkr->allele2;
	  
	  if (xlinked && ind->sex == S_MALE && al1>0 && al2>0) {
	    pseudoal = NumberOfAlleles(order[i])+1;
	    al2 = pseudoal;
	  }
          fprintf(F, " %d %d", al1, al2);
	}
        fprintf(F, "\n");
      }
    }
  }


  fclose(F);

  printf("Created crimap gen file\n");
  if (xlinked) {
    printf("Pseudo-allele generated for all males\n");
  }

  return 0;  
}
Пример #21
-7
uint16_t GetIndex(uint8_t **pos) {
	uint8_t ss;
	RemoveWhiteSpace(pos);
	ss = *((*pos)++);
	if(ss != 'v') return(65535);
	return(GetNumber(pos));
}