Beispiel #1
0
// 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)
}
Beispiel #2
0
// 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)
}