Esempio n. 1
0
// 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)
}
Esempio n. 2
0
func main() {
	hhmFile := util.Arg(0)
	start := util.ParseInt(util.Arg(1))
	end := util.ParseInt(util.Arg(2))

	fhhm := util.OpenFile(hhmFile)

	qhhm, err := hmm.ReadHHM(fhhm)
	util.Assert(err)

	util.Assert(hmm.WriteHHM(os.Stdout, qhhm.Slice(start, end)))
}
Esempio n. 3
0
func (m MapConfig) MapFromHHM(pdbDb PDBDatabase, seqDb hhsuite.Database,
	queryFasta string, queryHHM string) (*FragmentMap, error) {

	qseq, err := getOneFastaSequence(queryFasta)
	if err != nil {
		return nil, err
	}

	fquery, err := os.Open(queryHHM)
	if err != nil {
		return nil, err
	}
	defer fquery.Close()

	qhhm, err := hmm.ReadHHM(fquery)
	if err != nil {
		return nil, err
	}
	return m.computeMap(pdbDb, qseq, qhhm)
}