本文整理匯總了Golang中github.com/ndaniels/mica.Exec函數的典型用法代碼示例。如果您正苦於以下問題:Golang Exec函數的具體用法?Golang Exec怎麽用?Golang Exec使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Exec函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: makeFineDmndDB
func makeFineDmndDB(seqBuf *bytes.Buffer) (string, error) {
tmpSeqFile, err := ioutil.TempFile(".", "fine-sequences-")
if err != nil {
return "", fmt.Errorf("Could not create temporary sequence file: %s\n", err)
}
err = ioutil.WriteFile(tmpSeqFile.Name(), seqBuf.Bytes(), 0666)
if err != nil {
return "", fmt.Errorf("Could not write to temporary sequence file: %s\n", err)
}
tmpDmndFile, err := ioutil.TempFile(".", "fine-dmnd-db-")
if err != nil {
return "", fmt.Errorf("Could not create temporary diamond file: %s\n", err)
}
cmd := exec.Command(
flagDmnd,
"makedb",
"--in", tmpSeqFile.Name(),
"-d", tmpDmndFile.Name())
err = mica.Exec(cmd)
if err != nil {
return "", fmt.Errorf("Could not create fine diamond database: %s\n", err)
}
err = os.RemoveAll(tmpSeqFile.Name())
if err != nil {
return "", fmt.Errorf("Could not remove temporary sequence file: %s\n", err)
}
return tmpDmndFile.Name(), nil
}
示例2: convertDmndToBlastTabular
func convertDmndToBlastTabular(daa *os.File) (*os.File, error) {
dmndOutFile, err := ioutil.TempFile(".", "dmnd-out-tab-")
if err != nil {
return nil, fmt.Errorf("Could not build temporary file for diamond output: %s", err)
}
cmd := exec.Command(
flagDmnd,
"view",
"-o", dmndOutFile.Name(),
"-a", daa.Name())
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
err = mica.Exec(cmd)
if err != nil {
return nil, fmt.Errorf("Error converting daa file to blast tabular: %s", err)
}
// err = os.Remove(daa.Name())
// if err != nil {
// return nil, fmt.Errorf("Error destroying .daa file: %s", err)
// }
return dmndOutFile, nil
}
示例3: dmndBlastXFine
func dmndBlastXFine(queries *os.File, outFilename, fineFilename string) error {
cmd := exec.Command(
flagDmnd,
"blastx",
"--sensitive",
"-d", fineFilename,
"-q", queries.Name(),
"--threads", s(flagGoMaxProcs),
"-a", outFilename,
"--compress", "0",
"-c", "1",
"--top", s(flagFineDmndMatch))
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
err := mica.Exec(cmd)
if err != nil {
return fmt.Errorf("Error using diamond to blast coarse db: %s\n", err)
}
if !flagDmndOutput {
daaFile, err := os.Open(outFilename)
if err != nil {
return fmt.Errorf("Error opening diamond output: %s\n", err)
}
tabularFile, err := convertDmndToBlastTabular(daaFile)
if err != nil {
return fmt.Errorf("Error converting diamond output: %s\n", err)
}
os.Rename(tabularFile.Name(), outFilename)
}
return nil
}
示例4: dmndBlastPCoarse
func dmndBlastPCoarse(db *mica.DB, queries *os.File) (*os.File, error) {
// diamond blastp -d nr -q reads.fna -a matches -t <temporary directory>
dmndOutFile, err := ioutil.TempFile(".", "dmnd-out-")
if err != nil {
return nil, fmt.Errorf("Could not build temporary file for diamond output: %s", err)
}
cmd := exec.Command(
flagDmnd,
"blastp",
"--sensitive",
"-d", path.Join(db.Path, mica.FileDmndCoarse),
"-q", queries.Name(),
"--threads", s(flagGoMaxProcs),
"-o", dmndOutFile.Name(),
"--compress", "0",
"-c", "1",
"--top", s(flagCoarseDmndMatch))
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
err = mica.Exec(cmd)
if err != nil {
return nil, fmt.Errorf("Error using diamond to blast coarse db: %s", err)
}
return dmndOutFile, nil
}
示例5: dmndBlastXCoarse
func dmndBlastXCoarse(db *mica.DB, queryFilename string) (string, error) {
// diamond blastp -d nr -q reads.fna -a matches -t <temporary directory>
dmndOutFilename := flagTempFileDir + "/dmnd-blastx-out-temp"
cmd := exec.Command(
flagDmnd,
"blastx",
"--sensitive",
"-d", path.Join(db.Path, mica.FileDmndCoarse),
"-q", queryFilename,
"--threads", s(flagGoMaxProcs),
"-a", dmndOutFilename,
"--compress", "0",
"--top", s(flagCoarseDmndMatch),
"--tmpdir", flagTempFileDir)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
err := mica.Exec(cmd)
if err != nil {
return "", fmt.Errorf("Error using diamond to blast coarse db: %s", err)
}
dmndOutFilename = dmndOutFilename + ".daa"
return dmndOutFilename, nil
}
示例6: blastCoarse
func blastCoarse(
db *mica.DB, stdin *bytes.Reader, stdout *bytes.Buffer) error {
flags := []string{"-db", path.Join(db.Path, mica.FileBlastCoarse),
"-outfmt", "5", "-num_iterations", s(flagIters),
"-dbsize", su(db.BlastDBSize)}
cmd := exec.Command(flagPsiBlast, flags...)
cmd.Stdin = stdin
cmd.Stdout = stdout
return mica.Exec(cmd)
}
示例7: blastCoarse
func blastCoarse(
db *mica.DB, stdin *bytes.Reader, stdout *bytes.Buffer) error {
cmd := exec.Command(
flagBlastp,
"-db", path.Join(db.Path, mica.FileBlastCoarse),
"-num_threads", s(flagGoMaxProcs),
"-outfmt", "5", "-dbsize", su(db.BlastDBSize))
cmd.Stdin = stdin
cmd.Stdout = stdout
return mica.Exec(cmd)
}
示例8: blastFine
func blastFine(
db *mica.DB, blastFineDir string, stdin *bytes.Reader) error {
// We pass our own "-db" flag to blastp, but the rest come from user
// defined flags.
flags := []string{"-db", path.Join(blastFineDir, mica.FileBlastFine),
"-num_iterations", s(flagIters),
"-dbsize", su(db.BlastDBSize)}
flags = append(flags, blastArgs...)
cmd := exec.Command(flagPsiBlast, flags...)
cmd.Stdin = stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return mica.Exec(cmd)
}
示例9: makeFineBlastDB
func makeFineBlastDB(db *mica.DB, stdin *bytes.Buffer) (string, error) {
tmpDir, err := ioutil.TempDir("", "mica-fine-search-db")
if err != nil {
return "", fmt.Errorf("Could not create temporary directory: %s\n", err)
}
cmd := exec.Command(
flagMakeBlastDB, "-dbtype", "prot",
"-title", mica.FileBlastFine,
"-in", "-",
"-out", path.Join(tmpDir, mica.FileBlastFine))
cmd.Stdin = stdin
mica.Vprintf("Created temporary fine BLAST database in %s\n", tmpDir)
return tmpDir, mica.Exec(cmd)
}