示例#1
0
 config_handler::config_handler(argos::index::Index* the_index)
 : the_index_(the_index)
 , idx_name(get_index_name(the_index))
 , logger(Logger::getInstance("main"))
 , acc(Logger::getInstance(std::string("access.")+idx_name))
 , err(Logger::getInstance(std::string("error.")+idx_name))
 {}
示例#2
0
void SRAssembler::merge_mapped_files(int round){
	for (unsigned int lib_idx=0;lib_idx<this->libraries.size();lib_idx++){
		Library lib = this->libraries[lib_idx];
		logger->debug("Merge files...");
		//copy reads we have so far, for debugging
		string left_files = tmp_dir + "/output_matched_left_" + int2str(round) + "_" + int2str(lib_idx + 1) + "_*";
		string cmd = "cat " + left_files + " >> " + lib.get_matched_left_read_name();
		logger->debug(cmd);
		run_shell_command(cmd);
		cmd = "rm -f " + left_files;
		logger->debug(cmd);
		run_shell_command(cmd);
		if (lib.get_paired_end()) {
			string right_files = tmp_dir + "/output_matched_right_" + int2str(round) + "_" + int2str(lib_idx + 1) + "_*";
			cmd = "cat " + right_files + " >> " + lib.get_matched_right_read_name();
			logger->debug(cmd);
			run_shell_command(cmd);
			cmd = "rm -f " + right_files;
			logger->debug(cmd);
			run_shell_command(cmd);
		}
		//cmd = "cat " + tmp_dir + "/output_matched_joined_" + int2str(round) + "_" + int2str(lib_idx) + "* > " + tmp_dir + "/output_matched_joined_" + int2str(round) + "_" + int2str(lib_idx) + ".fasta";
		if (round > 1)
			run_shell_command("cp " + lib.get_matched_left_read_name() + " " + lib.get_matched_left_read_name(round));
		if (lib.get_paired_end() && round > 1)
			run_shell_command("cp " + lib.get_matched_right_read_name() + " " + lib.get_matched_right_read_name(round));
	}
	string cmd = "rm -f " + get_index_name(round) + ".*";;
	logger->debug(cmd);
	run_shell_command(cmd);
	logger->debug("done.");
}
示例#3
0
off_t bi_tree_search(FILE *bindexfile, FILE *indexfile, char *seqname){
  char *tmp=NULL;
  off_t maxposition, minposition=-1, target;
  off_t fposition;
  int sw;
  size_t size;
  /* int no_found_count=0; */

  /* set position */
  fseeko(bindexfile, (off_t)0, SEEK_SET);

  /* measure data size */
  /*  tmp=(char *)malloc(MAXLETTER_FIRSTPIC_B);*/
  uhmin_fgets(&tmp,MAXLETTER_FIRSTPIC_B-1,bindexfile);

  size=strlen(tmp);
  /* measure file length */
  fseeko(bindexfile, (off_t)0, SEEK_END);
  /*  printf("Max File Position: %lld\n", ftello(bindexfile)); */ /* debug */
  maxposition=ftello(bindexfile)/size;

  /* seek sequence */
  target=(minposition+maxposition)/2;
  fseeko(bindexfile,target*(off_t)size,SEEK_SET);

  while(1){
    if(tmp!=NULL){free(tmp); tmp=NULL;}
    fposition=get_index_name(bindexfile,indexfile,&tmp);
    sw=compare(tmp,seqname);
    /* fprintf(stderr,"comp: [%s],  %d \n",tmp, sw); */ /* debug */
    if (sw==0) break;
    else if (sw<0) maxposition=target;
    else minposition=target;
    if (maxposition-minposition==1) break;
    
    target=(maxposition+minposition)/2  ;
    /*printf("current %ld, jump %ld\n",ftello(bindexfile),target*size-ftello(bindexfile));*/
    if (fseeko(bindexfile,target*(off_t)size,SEEK_SET)!=0) break;
  }

  if(tmp!=NULL){free(tmp); tmp=NULL;} 
  if (sw==0) {
    /*fprintf(stderr,"successfully find sequence \n%s\n",tmp);*/
  }else {
    fprintf(stderr,"could not find the sequence %s.\n",seqname);
    return -1;
  }
  return fposition;
}
示例#4
0
int SRAssembler::do_alignment(int round, int lib_idx, int idx) {
	Library lib = this->libraries[lib_idx];
	logger->info("Aligning: round = " + int2str(round) + " Lib (" + int2str(lib_idx+1) + "/" + int2str(this->libraries.size()) + "), Reads (" + int2str(idx) + "/" + int2str(lib.get_num_parts()) + ")");
	Aligner* aligner = get_aligner(round);
	string program_name = aligner->get_program_name();
	if (round == 1)
		program_name += "_init";
	Params params = this->read_param_file(program_name);
	aligner->do_alignment(get_index_name(round), get_type(round), get_match_length(round), get_mismatch_allowed(round), lib.get_split_file_name(idx, aligner->get_format()), params, get_output_file_name(round, lib_idx, idx));
	int ret = aligner->parse_output(get_output_file_name(round, lib_idx, idx), mapped_reads, lib.get_split_file_name(idx, lib.get_format()), lib.get_matched_left_read_name(round, idx), lib.get_matched_right_read_name(round, idx), fastq_format,  lib.get_format());
	string cmd = "rm -f " +  get_output_file_name(round, lib_idx, idx);
	save_mapped_reads(round);
	run_shell_command(cmd);
	return ret;
}
示例#5
0
void SRAssembler::create_index(int round) {
	Aligner* aligner = get_aligner(round);
	aligner->create_index(get_index_name(round), get_type(round), get_index_fasta_file_name(round));
}