Example #1
0
bool inclChrom(struct slName *chrom)
/* check if a chromosome should be included */
{
return  !((noRandom && (endsWith(chrom->name, "_random")
                        || startsWith("chrUn", chrom->name)))
          || (noHap && haplotype(chrom->name)));
}
Example #2
0
bool inclChrom(char *name)
/* check if a chromosome should be included */
{
return  !((noRandom && (endsWith(name, "_random")
                        || startsWith("chrUn", name)
                        || sameWord("chrNA", name) /* danRer */
                        || sameWord("chrU", name)))  /* dm */
          || (noHap && haplotype(name)));
}
Example #3
0
static boolean inclChrom(char *chrom)
/* check if rows for chromosome should be included */
{
if (noRandom && (strstr(chrom, "_random") != NULL))
    return FALSE;
if (noHap && haplotype(chrom))
    return FALSE;
return TRUE;
}
Example #4
0
void hap_transmit(int *n, int *ped, int *id, int *father, int *mother,
		  int *sex, int *aff, int *if_qt, double *qt, 
		  int *m, int *markers, 
		  int *multiple_cases, int *impute_using_affected,
		  char **ofname) {
  Family *first, *f, *prev;
  FILE *outfile;
  int nn, mm, hr, iqt;
  char *tmp;
  nn = *n;
  mm = *m;
  iqt = *if_qt;
  if (!*if_qt) qt = (double *) 0;
  first = nuclear(nn, ped, id, father, mother, sex, aff, qt, mm, markers);
  /* Multiple case treatment */
  if (*multiple_cases) {
    for (f=first; f; f=f->next) {
      if (*multiple_cases == 1) {
	prev = f;
	f = expand_family(f, mm);
	if (!f) goto overflow;
      }
      else if (*multiple_cases == 2) {
	use_only_first(f);
      }
    }
  }

  /* Do remaining computations on families */
  
  prev = (Family *) 0;
  for (f=first; f; f=f->next) {
    /* Impute missing parental genotypes */
    impute_parent(f, mm, (int) *impute_using_affected);
    /* Compute inheritance vectors */
    inheritance(f, mm);
    /* Resolve haplotype phase and transmission */
    hr = haplotype(f, mm, 1);
    /* If recombination, write error message */
    if (hr<0) {
      REprintf("*** Recombination/expaternity at locus %d *** ", -hr);
      show_family(f);
    }
    /* If no information or recombination, omit family */
    if (hr!=0) {
      if (prev)
	prev->next = f->next;
      else
	first = f->next;
    }
    else {
      prev = f;
    }
  } 

  /* Write haplotypes to disk */

  tmp = *ofname;
  /* If no file name supplied, generate one */
  if (!*tmp) {
    tmp = tmpnam((char *) 0);
    *ofname = tmp;
  }
  outfile = fopen(tmp, "wb");
  if (outfile) {
    *n = hap_write(first, mm, iqt, outfile);
    fclose(outfile);
  }
  else {
    REprintf("*** Couldn't open temporary file %s\n", tmp);
    *n = 0;
  }

  /* Now return memory to system */

  while (first) {
    f = first;
    first = first->next;
    del_family(f);
  }
  return;

  /* Memory overflow */

overflow:
  warn("Memory overflow while or after expanding family", f);

}
Example #5
0
int main(int argc, char** argv){
	if(tomahawk::utility::IsBigEndian()){
		std::cerr << tomahawk::utility::timestamp("ERROR") << "Tomahawk does not support big endian systems..." << std::endl;
		return(1);
	}

	if(argc == 1){
		tomahawk::ProgramMessage();
		tomahawk::ProgramHelpDetailed();
		return(1);
	}

	// Literal string input line
	tomahawk::LITERAL_COMMAND_LINE = tomahawk::TOMAHAWK_PROGRAM_NAME;
	for(int i = 1; i < argc; ++i)
		tomahawk::LITERAL_COMMAND_LINE += " " + std::string(&argv[i][0]);

	if(strcmp(&argv[1][0], "import") == 0){
		return(import(argc, argv));

	}

	else if(strcmp(&argv[1][0], "calc") == 0){
		return(calc(argc, argv));

	} else if(strcmp(&argv[1][0], "calc-single") == 0 || strcmp(&argv[1][0], "scalc") == 0){
		return(scalc(argc, argv));
	}

	else if(strcmp(&argv[1][0], "view") == 0){
		return(view(argc, argv));

	}

	else if(strncmp(&argv[1][0], "sort", 4) == 0){
		return(sort(argc, argv));

	}

	else if(strncmp(&argv[1][0], "concat", 6) == 0){
		return(concat(argc, argv));

	}
	else if(strncmp(&argv[1][0], "stats", 5) == 0){
		return(stats(argc, argv));

	}
	else if(strncmp(&argv[1][0], "aggregate", 8) == 0){
		return(aggregate(argc, argv));
	}
	else if(strncmp(&argv[1][0], "haplotype", 9) == 0){
		return(haplotype(argc, argv));
	}
	else if(strncmp(&argv[1][0], "relationship", 9) == 0){
		return(relationship(argc, argv));
	}
	else if(strncmp(&argv[1][0], "decay", 5) == 0){
		return(decay(argc, argv));
	}
	else if(strcmp(&argv[1][0], "--version") == 0 || strcmp(&argv[1][0], "version") == 0){
		tomahawk::ProgramMessage(false);
		return(0);

	} else if(strcmp(&argv[1][0], "--help") == 0 || strcmp(&argv[1][0], "help") == 0){
		tomahawk::ProgramMessage();
		tomahawk::ProgramHelpDetailed();
		return(0);

	} else {
		tomahawk::ProgramMessage();
		tomahawk::ProgramHelpDetailed();
		std::cerr << tomahawk::utility::timestamp("ERROR") << "Illegal command" << std::endl;
		return(1);
	}
	return(1);
}