예제 #1
0
파일: main.go 프로젝트: mkrull/wingo
func socketFilePath() string {
	c := cmd.New("wingo", "--show-socket")
	if err := c.Run(); err != nil {
		log.Fatal(err)
	}
	return strings.TrimSpace(c.BufStdout.String())
}
예제 #2
0
파일: hhsearch.go 프로젝트: TuftsBCB/apps
// Run will execute HHsearch using the given configuration, database and query
// file path. The query can be a path to a fasta file, A3M file or HHM file.
// (As per the '-i' flag for hhsearch.)
func (conf HHSearchConfig) Run(db Database, query string) (*hhr.HHR, error) {
	hhrFile, err := ioutil.TempFile("", "bcbgo-hhr")
	if err != nil {
		return nil, err
	}
	defer os.Remove(hhrFile.Name())
	defer hhrFile.Close()

	args := []string{
		"-cpu", fmt.Sprintf("%d", conf.CPUs),
		"-i", query,
		"-d", db.ResolveHHSearch(),
		"-o", hhrFile.Name(),
	}

	c := cmd.New(conf.Exec, args...)
	if conf.Verbose {
		fmt.Fprintf(os.Stderr, "\n%s\n", c)
		c.Cmd.Stdout = os.Stdout
		c.Cmd.Stderr = os.Stderr
	}
	if err := c.Run(); err != nil {
		return nil, err
	}
	return hhr.Read(hhrFile)
}
예제 #3
0
파일: hhmake.go 프로젝트: TuftsBCB/apps
// Run will execute HHmake using the given configuration and query file path.
// The query should be a file path pointing to an MSA file (fasta, a2m or
// a3m) or an hhm file. It should NOT be just a single sequence.
//
// If you need to build an HHM from a single sequence, use the convenience
// function BuildHHM.
func (conf HHMakeConfig) Run(query string) (*hmm.HHM, error) {
	hhmFile, err := ioutil.TempFile("", "bad-bcbgo-hhm")
	if err != nil {
		return nil, err
	}
	defer os.Remove(hhmFile.Name())
	defer hhmFile.Close()

	emission := strings.Fields(fmt.Sprintf(
		"-pcm %d -pca %f -pcb %f -pcc %f",
		conf.PCM, conf.PCA, conf.PCB, conf.PCC))
	transition := strings.Fields(fmt.Sprintf(
		"-gapb %f -gapd %f -gape %f -gapf %f -gapg %f -gapi %f",
		conf.GapB, conf.GapD, conf.GapE, conf.GapF, conf.GapG, conf.GapI))

	args := []string{
		"-i", query,
		"-o", hhmFile.Name(),
	}
	args = append(args, emission...)
	args = append(args, transition...)

	c := cmd.New(conf.Exec, args...)
	if conf.Verbose {
		fmt.Fprintf(os.Stderr, "\n%s\n", c)
		c.Cmd.Stdout = os.Stdout
		c.Cmd.Stderr = os.Stderr
	}
	if err := c.Run(); err != nil {
		return nil, err
	}
	return hmm.ReadHHM(hhmFile)
}
예제 #4
0
// emailLines sends a chunk of lines via email.
func emailLines(lines []string) {
	var c *cmd.Command
	subj := fmt.Sprintf("%s%s", flagSubjectPrefix, fullProgram)

	if flagSendMail == "mailx" {
		c = cmd.New(flagSendMail, "-s", subj, flagTo)
		fmt.Fprint(c.BufStdin, strings.Join(lines, ""))
	} else {
		c = cmd.New(flagSendMail, "-t")
		date := time.Now().Format("Mon, 02 Jan 2006 15:04:05 -0700")
		fmt.Fprintf(c.BufStdin,
			`Subject: %s
From: %s
To: %s
Date: %s

%s`, subj, flagTo, flagTo, date, strings.Join(lines, ""))
	}

	if err := c.Run(); err != nil {
		log.Printf("Error sending mail '%s -t': %s.", flagSendMail, err)
	}
}
예제 #5
0
파일: main.go 프로젝트: csigo/config
// runSingleCmdOrFatal runs a command line, and fatal if either
// return code is not 0, or stderr is not empty.
// It returns stdout.
func runSingleCmdOrFatal(line string) string {
	// trim the command line
	line = strings.Trim(line, " \t")
	tokens := regexSplitWhite.Split(line, -1)
	if len(tokens) < 1 {
		log.Fatalf("can't execute an empty command line\n")
	}
	command := cmd.New(tokens[0], tokens[1:]...)
	err := command.Run()
	if err != nil {
		log.Fatalf("error running command '%s': %s\n", line, err)
	}
	bs := command.BufStdout.Bytes()
	str := string(bs[:len(bs)])
	// trim \n
	return strings.TrimRight(str, "\n\r")
}
예제 #6
0
파일: hhblits.go 프로젝트: TuftsBCB/apps
// Run will execute HHblits using the given configuration, database and query
// file path. The query can be a path to a fasta file, A3M file or HHM file.
// (As per the '-i' flag for hhblits.)
func (conf HHBlitsConfig) Run(db Database, query string) (*hhr.HHR, error) {
	// If the database is old style, it cannot be used with hhblits.
	if db.isOldStyle() {
		return nil, fmt.Errorf("An old-style database '%s' cannot be used "+
			"with hhblits. It can only be used with hhsearch.", db)
	}

	hhrFile, err := ioutil.TempFile("", "bcbgo-hhr")
	if err != nil {
		return nil, err
	}
	defer os.Remove(hhrFile.Name())
	defer hhrFile.Close()

	args := []string{
		"-cpu", fmt.Sprintf("%d", conf.CPUs),
		"-i", query,
		"-d", db.Resolve(),
		"-n", fmt.Sprintf("%d", conf.Iterations),
		"-mact", fmt.Sprintf("%f", conf.MAct),
		"-o", hhrFile.Name(),
	}
	if len(conf.OutA3M) > 0 {
		args = append(args, []string{"-oa3m", conf.OutA3M}...)
	}

	c := cmd.New(conf.Exec, args...)
	if conf.Verbose {
		fmt.Fprintf(os.Stderr, "\n%s\n", c)
		c.Cmd.Stdout = os.Stdout
		c.Cmd.Stderr = os.Stderr
	}
	if err := c.Run(); err != nil {
		return nil, err
	}
	return hhr.Read(hhrFile)
}