示例#1
0
string SRAssembler:: get_index_fasta_file_name(int round){
	if (round > 1){
		if (assembly_round < round)
		    return get_contig_file_name(round-1);
		else {
			string joined_file = tmp_dir + "/output_matched_joined.fasta";
			string cmd;
			for (unsigned i=0;i<this->libraries.size();i++){
				string left_file = tmp_dir + "/output_matched_left_" + int2str(i) + ".fasta";
				string right_file = tmp_dir + "/output_matched_right_" + int2str(i) + ".fasta";
				if (libraries[i].get_file_extension() == "fastq") {
					fastq2fasta(tmp_dir + "/output_matched_left_" + int2str(i) + ".fastq", left_file);
					if (libraries[i].get_paired_end())
						fastq2fasta(tmp_dir + "/output_matched_right_" + int2str(i) + ".fastq", right_file);
				}
				if (libraries[i].get_paired_end()){
					cmd = "cat " + left_file + " " + right_file + " >> " + joined_file;
					logger->debug(cmd);
					run_shell_command(cmd);
				}else
					cmd = "cat " + left_file + " >> " + joined_file;
					logger->debug(cmd);
					run_shell_command(cmd);
			}
			return joined_file;
		}
	}
	return query_file;
}
示例#2
0
文件: app.c 项目: goedson/old-gnotime
void
cur_proj_set (GttProject *proj)
{
	/* Due to the way the widget callbacks work,
	 * we may be called recursively ... */
	if (cur_proj == proj) return;

	log_proj(NULL);
	gtt_project_timer_stop (cur_proj);
	gtt_status_icon_stop_timer (proj);
	run_shell_command (cur_proj, FALSE);

	GttProject *old_prj = cur_proj;
	if (proj) 
	{
		if (timer_is_running ())
		{
			stop_main_timer ();
		}
		cur_proj = proj;
		gtt_project_timer_start (proj);
		gtt_status_icon_start_timer (proj);
		run_shell_command (cur_proj, TRUE);
		start_idle_timer ();
		start_main_timer ();
	}
	else
	{
		if (timer_is_running ())
		{
			stop_main_timer ();
		}
		cur_proj = NULL;
		start_no_project_timer ();
	}
	log_proj(proj);

	if (old_prj)
	{
		gtt_projects_tree_update_project_data (projects_tree, old_prj);
	}

	if (cur_proj)
	{
		gtt_projects_tree_update_project_data (projects_tree, cur_proj);
	}

	/* update GUI elements */
	menu_set_states();
	toolbar_set_states();
	if (proj)
	{
		prop_dialog_set_project(proj);
		notes_area_set_project (global_na, proj);
	}
	update_status_bar();
}
示例#3
0
static void exec_proxy_cmd(void *user_data_cmd) {
	const char *cmd = user_data_cmd;
	char *usershell;

	usershell = m_strdup(get_user_shell());
	run_shell_command(cmd, ses.maxfd, usershell);
	dropbear_exit("Failed to run '%s'\n", cmd);
}
示例#4
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.");
}
示例#5
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;
}
示例#6
0
void GSQAligner::do_spliced_alignment(const string& genomic_file, const string& type, const string& query_file, const string& species, const Params& params, const string& output_file, const string& hit_contig_file){
	string param_list = "";
	for ( Params::const_iterator it = params.begin(); it != params.end(); ++it ){
		param_list += " -" + it->first + " " + it->second;
	}
	string type_str = "E";
	string species_str = species_names[species];
	if (species_str == "")
		species_str = "generic";
	if (type == "protein")
		type_str = "Q";
	string cmd = "GeneSeqer -L " + genomic_file + " -" + type_str + " " + query_file + " -species " + species_str + " " + param_list + " -o " + output_file + " >> " + logger->get_log_file() + " 2>&1";
	logger->debug(cmd);
	run_shell_command(cmd);
	//get_aligned_contigs(genomic_file, hit_contig_file, output_file);
}
示例#7
0
文件: cgdbrc.c 项目: denizt/cgdb
int command_do_shell(int param)
{
    return run_shell_command(NULL);
}
示例#8
0
u_char         *
var_extensible_relocatable(struct variable *vp,
                           oid * name,
                           size_t * length,
                           int exact,
                           size_t * var_len, WriteMethod ** write_method)
{

    int             i;
    int             len;
    struct extensible *exten = 0;
    static long     long_ret;
    static char     errmsg[STRMAX];
    char            *cp, *cp1;
    struct variable myvp;
    oid             tname[MAX_OID_LEN];

    memcpy(&myvp, vp, sizeof(struct variable));

    long_ret = *length;
    for (i = 1; i <= (int) numrelocs; i++) {
        exten = get_exten_instance(relocs, i);
        if (!exten)
            continue;
        if ((int) exten->miblen == (int) vp->namelen - 1) {
            memcpy(myvp.name, exten->miboid, exten->miblen * sizeof(oid));
            myvp.namelen = exten->miblen;
            *length = vp->namelen;
            memcpy(tname, vp->name, vp->namelen * sizeof(oid));
            if (!header_simple_table
                (&myvp, tname, length, -1, var_len, write_method, -1))
                break;
            else
                exten = NULL;
        }
    }
    if (i > (int) numrelocs || exten == NULL) {
        *length = long_ret;
        *var_len = 0;
        *write_method = NULL;
        return (NULL);
    }

    *length = long_ret;
    if (header_simple_table(vp, name, length, exact, var_len, write_method,
                            ((vp->magic == ERRORMSG) ? MAXMSGLINES : 1)))
        return (NULL);

    switch (vp->magic) {
    case MIBINDEX:
        long_ret = name[*length - 1];
        return ((u_char *) (&long_ret));
    case ERRORNAME:            /* name defined in config file */
        *var_len = strlen(exten->name);
        return ((u_char *) (exten->name));
    case SHELLCOMMAND:
        *var_len = strlen(exten->command);
        return ((u_char *) (exten->command));
    case ERRORFLAG:            /* return code from the process */
        len = sizeof(exten->output);
        if (exten->type == EXECPROC)
            exten->result = run_exec_command( exten->command, NULL,
                                              exten->output, &len);
	else
            exten->result = run_shell_command(exten->command, NULL,
                                              exten->output, &len);
        long_ret = exten->result;
        return ((u_char *) (&long_ret));
    case ERRORMSG:             /* first line of text returned from the process */
        len = sizeof(exten->output);
        if (exten->type == EXECPROC)
            exten->result = run_exec_command( exten->command, NULL,
                                              exten->output, &len);
	else
            exten->result = run_shell_command(exten->command, NULL,
                                              exten->output, &len);

        /*
         *  Pick the output string apart into individual lines,
         *  and extract the one being asked for....
         */
        cp1 = exten->output;
        for (i = 1; i != (int) name[*length - 1]; i++) {
            cp = strchr(cp1, '\n');
            if (!cp) {
	        *var_len = 0;
	        /* wait_on_exec(exten);		??? */
	        return NULL;
	    }
	    cp1 = ++cp;
	}
        /*
         *  ... and quit if we've run off the end of the output
         */
        if (!*cp1) {
            *var_len = 0;
	    return NULL;
	}
        cp = strchr(cp1, '\n');
        if (cp)
            *cp = 0;
        strlcpy(errmsg, cp1, sizeof(errmsg));
        *var_len = strlen(errmsg);
        if (errmsg[*var_len - 1] == '\n')
            errmsg[--(*var_len)] = '\0';
        return ((u_char *) (errmsg));
    case ERRORFIX:
        *write_method = fixExecError;
        long_return = 0;
        return ((u_char *) & long_return);

    case ERRORFIXCMD:
        *var_len = strlen(exten->fixcmd);
        return ((u_char *) exten->fixcmd);
    }
    return NULL;
}
示例#9
0
u_char         *
var_extensible_shell(struct variable * vp,
                     oid * name,
                     size_t * length,
                     int exact,
                     size_t * var_len, WriteMethod ** write_method)
{

    static struct extensible *exten = 0;
    static long     long_ret;
    int len;

    if (header_simple_table
        (vp, name, length, exact, var_len, write_method, numextens))
        return (NULL);

    if ((exten = get_exten_instance(extens, name[*length - 1]))) {
        switch (vp->magic) {
        case MIBINDEX:
            long_ret = name[*length - 1];
            return ((u_char *) (&long_ret));
        case ERRORNAME:        /* name defined in config file */
            *var_len = strlen(exten->name);
            return ((u_char *) (exten->name));
        case SHELLCOMMAND:
            *var_len = strlen(exten->command);
            return ((u_char *) (exten->command));
        case ERRORFLAG:        /* return code from the process */
            len = sizeof(exten->output);
            if (exten->type == EXECPROC) {
                exten->result = run_exec_command( exten->command, NULL,
                                                  exten->output, &len);
	    } else {
                exten->result = run_shell_command(exten->command, NULL,
                                                  exten->output, &len);
	    }
            long_ret = exten->result;
            return ((u_char *) (&long_ret));
        case ERRORMSG:         /* first line of text returned from the process */
            len = sizeof(exten->output);
            if (exten->type == EXECPROC) {
                exten->result = run_exec_command( exten->command, NULL,
                                                  exten->output, &len);
	    } else {
                exten->result = run_shell_command(exten->command, NULL,
                                                  exten->output, &len);
	    }
            *var_len = strlen(exten->output);
            if (exten->output[*var_len - 1] == '\n')
                exten->output[--(*var_len)] = '\0';
            return ((u_char *) (exten->output));
        case ERRORFIX:
            *write_method = fixExecError;
            long_return = 0;
            return ((u_char *) & long_return);

        case ERRORFIXCMD:
            *var_len = strlen(exten->fixcmd);
            return ((u_char *) exten->fixcmd);
        }
        return NULL;
    }
    return NULL;
}
示例#10
0
文件: tcllib.c 项目: Nazg-Gul/fm
/**
 *
 * File associations hook
 * For details see about hook's on user documentation
 */
int
_file_associations_hook (dynstruct_t *__callData)
{
  extension_action_t *ext;
  wchar_t *executecmd, *filename, *cwd;

  if (dynstruct_get_field_val (__callData, L"filename",
                               (void **) &filename) != DYNST_OK)
    {
      message_box (L"Hook `open-file-hook' error",
                   L"variable `filename' not found", MB_OK|MB_CRITICAL);

      return HOOK_FAILURE;
    }

  filename = escape_string (filename);

  if (_get_file_associations (filename, (void *) &ext) != TCL_OK)
    {
      executecmd = filename;
    }
  else
    {
      if (dynstruct_get_field_val (__callData, L"cwd",
                                   (void **) &cwd) != DYNST_OK)
        {
          message_box (L"Hook `open-file-hook' error",
                       L"variable `cwd' not found", MB_OK|MB_CRITICAL);

          return HOOK_FAILURE;
        }

      if (!ext->opener)
        {
          wchar_t msg[1024];

          swprintf (msg, BUF_LEN (msg),
                    _(L"There is no command specified to open file \"%ls\""),
                    filename);

          MESSAGE_ERROR (msg);
          return HOOK_FAILURE;
        }

      cwd = escape_string (cwd);

      executecmd = prepare_exec_command (ext->opener, filename, cwd);

      SAFE_FREE (filename);
      SAFE_FREE (cwd);
    }

  if (run_shell_command (executecmd) == -1)
    {
      return HOOK_FAILURE;
    }

  SAFE_FREE (executecmd);

  return HOOK_SUCCESS;
}
示例#11
0
int
run_exec_command( char *command, char *input,
                  char *output,  int  *out_len)	/* Or realloc style ? */
{
#if HAVE_EXECV
    int ipipe[2];
    int opipe[2];
    int i;
    int pid;
    int result;
    char **argv;
    int argc;

    DEBUGMSGTL(("run:exec", "running '%s'\n", command));
    pipe(ipipe);
    pipe(opipe);
    if ((pid = fork()) == 0) {
        /*
         * Child process
         */

        /*
         * Set stdin/out/err to use the pipe
         *   and close everything else
         */
        close(0);
        dup(  ipipe[0]);
	close(ipipe[1]);

        close(1);
        dup(  opipe[1]);
        close(opipe[0]);
        close(2);
        dup(1);
        for (i = getdtablesize()-1; i>2; i--)
            close(i);

        /*
         * Set up the argv array and execute it
         * This is being run in the child process,
         *   so will release resources when it terminates.
         */
        argv = tokenize_exec_command( command, &argc );
        execv( argv[0], argv );
        perror( argv[0] );
        exit(1);	/* End of child */

    } else if (pid > 0) {
        char            cache[NETSNMP_MAXCACHESIZE];
        char           *cache_ptr;
        ssize_t         count, cache_size, offset = 0;
        int             waited = 0, numfds;
        fd_set          readfds;
        struct timeval  timeout;

        /*
         * Parent process
         */

        /*
	 * Pass the input message (if any) to the child,
         * wait for the child to finish executing, and read
         *    any output into the output buffer (if provided)
         */
	close(ipipe[0]);
	close(opipe[1]);
	if (input) {
	   write(ipipe[1], input, strlen(input));
	   close(ipipe[1]);	/* or flush? */
        }
	else close(ipipe[1]);

        /*
         * child will block if it writes a lot of data and
         * fills up the pipe before exiting, so we read data
         * to keep the pipe empty.
         */
        if (output && ((NULL == out_len) || (0 == *out_len))) {
            DEBUGMSGTL(("run:exec",
                        "invalid params; no output will be returned\n"));
            output = NULL;
        }
        if (output) {
            cache_ptr = output;
            cache_size = *out_len - 1;
        } else {
            cache_ptr = cache;
            cache_size = sizeof(cache);
        }

        /*
         * xxx: some of this code was lifted from get_exec_output
         * in util_funcs.c. Probably should be moved to a common
         * routine for both to use.
         */
        DEBUGMSGTL(("verbose:run:exec","  waiting for child %d...\n", pid));
        numfds = opipe[0] + 1;
        i = NETSNMP_MAXREADCOUNT;
        for (; i; --i) {
            /*
             * set up data for select
             */
            FD_ZERO(&readfds);
            FD_SET(opipe[0],&readfds);
            timeout.tv_sec = 1;
            timeout.tv_usec = 0;

            DEBUGMSGTL(("verbose:run:exec", "    calling select\n"));
            count = select(numfds, &readfds, NULL, NULL, &timeout);
            if (count == -1) {
                if (EAGAIN == errno)
                    continue;
                else {
                    DEBUGMSGTL(("verbose:run:exec", "      errno %d\n",
                                errno));
                    setPerrorstatus("read");
                    break;
                }
            } else if (0 == count) {
                DEBUGMSGTL(("verbose:run:exec", "      timeout\n"));
                continue;
            }

            if (! FD_ISSET(opipe[0], &readfds)) {
                DEBUGMSGTL(("verbose:run:exec", "    fd not ready!\n"));
                continue;
            }

            /*
             * read data from the pipe, optionally saving to output buffer
             */
            count = read(opipe[0], &cache_ptr[offset], cache_size);
            DEBUGMSGTL(("verbose:run:exec",
                        "    read %d bytes\n", (int)count));
            if (0 == count) {
                int rc;
                /*
                 * we shouldn't get no data, because select should
                 * wait til the fd is ready. before we go back around,
                 * check to see if the child exited.
                 */
                DEBUGMSGTL(("verbose:run:exec", "    no data!\n"));
                if ((rc = waitpid(pid, &result, WNOHANG)) <= 0) {
                    if (rc < 0) {
                        snmp_log_perror("waitpid");
                        break;
                    } else
                        DEBUGMSGTL(("verbose:run:exec",
                                    "      child not done!?!\n"));;
                } else {
                    DEBUGMSGTL(("verbose:run:exec", "      child done\n"));
                    waited = 1; /* don't wait again */
                    break;
                }
            }
            else if (count > 0) {
                /*
                 * got some data. fix up offset, if needed.
                 */
                if(output) {
                    offset += count;
                    cache_size -= count;
                    if (cache_size <= 0) {
                        DEBUGMSGTL(("verbose:run:exec",
                                    "      output full\n"));
                        break;
                    }
                    DEBUGMSGTL(("verbose:run:exec",
                                "    %d left in buffer\n", (int)cache_size));
                }
            }
            else if ((count == -1) && (EAGAIN != errno)) {
                /*
                 * if error, break
                 */
                DEBUGMSGTL(("verbose:run:exec", "      errno %d\n",
                            errno));
                setPerrorstatus("read");
                break;
            }
        }
        DEBUGMSGTL(("verbose:run:exec", "  done reading\n"));
        if (output)
            DEBUGMSGTL(("run:exec", "  got %d bytes\n", *out_len));
            
        /*
         * close pipe to signal that we aren't listenting any more.
         */
        close(opipe[0]);

        /*
         * if we didn't wait successfully above, wait now.
         * xxx-rks: seems like this is a waste of the agent's
         * time. maybe start a time to wait(WNOHANG) once a second,
         * and late the agent continue?
         */
        if ((!waited) && (waitpid(pid, &result, 0) < 0 )) {
            snmp_log_perror("waitpid");
            return -1;
        }

        /*
         * null terminate any output
         */
        if (output) {
	    output[offset] = 0;
	    *out_len = offset;
        }
        DEBUGMSGTL(("run:exec","  child %d finished. result=%d\n",
                    pid,result));

	return WEXITSTATUS(result);

    } else {
        /*
         * Parent process - fork failed
         */
        snmp_log_perror("fork");
	close(ipipe[0]);
	close(ipipe[1]);
	close(opipe[0]);
	close(opipe[1]);
	return -1;
    }
    
#else
    /*
     * If necessary, fall back to using 'system'
     */
    DEBUGMSGTL(("run:exec", "running shell command '%s'\n", command));
    return run_shell_command( command, input, output, out_len );
#endif
}
示例#12
0
/*
 *  Trap handler for invoking a suitable script
 */
int   command_handler( netsnmp_pdu           *pdu,
                       netsnmp_transport     *transport,
                       netsnmp_trapd_handler *handler)
{
#ifndef USING_UTILITIES_EXECUTE_MODULE
    NETSNMP_LOGONCE((LOG_WARNING,
                     "support for run_shell_command not available\n"));
    return NETSNMPTRAPD_HANDLER_FAIL;
#else
    u_char         *rbuf = NULL;
    size_t          r_len = 64, o_len = 0;
    int             oldquick;

    DEBUGMSGTL(( "snmptrapd", "command_handler\n"));
    DEBUGMSGTL(( "snmptrapd", "token = '%s'\n", handler->token));
    if (handler && handler->token && *handler->token) {
	netsnmp_pdu    *v2_pdu = NULL;
	if (pdu->command == SNMP_MSG_TRAP)
	    v2_pdu = convert_v1pdu_to_v2(pdu);
	else
	    v2_pdu = pdu;
        oldquick = snmp_get_quick_print();
        snmp_set_quick_print(1);

        /*
	 * Format the trap and pass this string to the external command
	 */
        if ((rbuf = (u_char *) calloc(r_len, 1)) == NULL) {
            snmp_log(LOG_ERR, "couldn't display trap -- malloc failed\n");
            return NETSNMPTRAPD_HANDLER_FAIL;	/* Failed but keep going */
        }

        /*
         *  If there's a format string registered for this trap, then use it.
         *  Otherwise use the standard execution format setting.
         */
        if (handler && handler->format && *handler->format) {
            DEBUGMSGTL(( "snmptrapd", "format = '%s'\n", handler->format));
            realloc_format_trap(&rbuf, &r_len, &o_len, 1,
                                             handler->format,
                                             v2_pdu, transport);
        } else {
	    if ( pdu->command == SNMP_MSG_TRAP && exec_format1 ) {
                DEBUGMSGTL(( "snmptrapd", "exec v1 = '%s'\n", exec_format1));
                realloc_format_trap(&rbuf, &r_len, &o_len, 1,
                                             exec_format1, pdu, transport);
	    } else if ( pdu->command != SNMP_MSG_TRAP && exec_format2 ) {
                DEBUGMSGTL(( "snmptrapd", "exec v2/3 = '%s'\n", exec_format2));
                realloc_format_trap(&rbuf, &r_len, &o_len, 1,
                                             exec_format2, pdu, transport);
	    } else {
                DEBUGMSGTL(( "snmptrapd", "execute format\n"));
                realloc_format_trap(&rbuf, &r_len, &o_len, 1, EXECUTE_FORMAT,
                                             v2_pdu, transport);
            }
	}

        /*
         *  and pass this formatted string to the command specified
         */
        run_shell_command(handler->token, (char*)rbuf, NULL, NULL);   /* Not interested in output */
        snmp_set_quick_print(oldquick);
        if (pdu->command == SNMP_MSG_TRAP)
            snmp_free_pdu(v2_pdu);
        free(rbuf);
    }
    return NETSNMPTRAPD_HANDLER_OK;
#endif /* !def USING_UTILITIES_EXECUTE_MODULE */
}
示例#13
0
void SRAssembler::do_preprocessing(int lib_idx, int file_part){
	Library lib = this->libraries[lib_idx];

	logger->info("preprocessing lib " + int2str(lib_idx + 1) + ", reads file (" + int2str(file_part) + "/" + int2str(lib.get_num_parts()) + ")");
	char suffixc[3];
	suffixc[0] = (char)(((file_part-1) / 26) + 97);
	suffixc[1] = (char)(((file_part-1) % 26) + 97);
	suffixc[2] = '\0';
	string suffix(suffixc);
	string left_src_read = lib.get_prefix_split_src_file(lib.get_left_read()) + suffix;
	string right_src_read = "";
	if (lib.get_paired_end())
	    right_src_read = lib.get_prefix_split_src_file(lib.get_right_read()) + suffix;
	ifstream left_file(left_src_read.c_str());
	ifstream right_file;
	if (lib.get_paired_end()){
		right_file.open(right_src_read.c_str(), ios_base::in);
	}
	string left_header = "";
	string right_header = "";
	string left_seq = "";
	string right_seq = "";
	string left_qual = "";
	string right_qual = "";
	string plus;
	ofstream split_read_fasta_file;
	ofstream split_read_fastq_file;
	split_read_fasta_file.open(lib.get_split_file_name(file_part, FORMAT_FASTA).c_str(), ios_base::out);
	if (lib.get_format() == FORMAT_FASTQ)
	    split_read_fastq_file.open(lib.get_split_file_name(file_part, FORMAT_FASTQ).c_str(), ios_base::out);
	while (getline(left_file, left_header)) {
		// get read data point, which includes 4 lines
		string lead_chr = (lib.get_format() == FORMAT_FASTQ)? "@" : ">";
		if (left_header.substr(0,1) == lead_chr){
		 //save left-end reads
			getline(left_file, left_seq);
			if (lib.get_format() == FORMAT_FASTQ) {
				getline(left_file, plus);
				getline(left_file, left_qual);
			}
			if (lib.get_paired_end()){
				 //save right-end reads
				 while (getline(right_file, right_header))
					 if (right_header.substr(0,1) == lead_chr)
						 break;
				 getline(right_file, right_seq);
				 if (lib.get_format() == FORMAT_FASTQ) {
					 getline(right_file, plus);
					 getline(right_file, right_qual);
				 }
			}
			if (lib.get_format() == FORMAT_FASTQ) {
				split_read_fastq_file << left_header << endl
									  << left_seq << endl
									  << "+" << endl
									  << left_qual << endl;
			}
			split_read_fasta_file << ">" << left_header.substr(1) << endl << left_seq << endl;
			if (lib.get_paired_end()){
				if (lib.get_format() == FORMAT_FASTQ) {
					split_read_fastq_file << right_header << endl
								 << right_seq << endl
								 << "+" << endl
								 << right_qual << endl;
				}
				split_read_fasta_file << ">" << right_header.substr(1) << endl << right_seq << endl;
			}
		 }
	}
	split_read_fasta_file.close();
	if (lib.get_format() == FORMAT_FASTQ)
		split_read_fastq_file.close();
	left_file.close();
	if (lib.get_paired_end())
		right_file.close();
	string cmd = "rm " + left_src_read + " " + right_src_read;
	run_shell_command(cmd);
}