Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
肖潇 authored and 肖潇 committed Nov 23, 2022
0 parents commit 69bd1f2
Show file tree
Hide file tree
Showing 15 changed files with 275 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/gyy-shovill.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Batch Prokka Assemblies
Batch Prokka can help you execute prokka batch assemblies.

# Useage

You only need to specify two parameters, dataPath and outPath.

For example:

```
./batch-prokka-linux-amd64 -dataPath=/path/to/data -outPath=/path/to/out
```

The file name format example of the source file has been given in the [data directory](data).

# Cross platform

You can use this program directly on Linux, Windows and Mac, as long as your device has [Prokka](https://github.com/tseemann/prokka) installed.

[window](batch-prokka-windows-amd64)

[mac](batch-prokka-mac-amd64)

[linux](batch-prokka-linux-amd64)


Binary file added batch-prokka-linux-amd64
Binary file not shown.
Binary file added batch-prokka-mac-amd64
Binary file not shown.
Binary file added batch-prokka-windows-amd64
Binary file not shown.
Empty file added data/adv.fa
Empty file.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module gyy-prokka

go 1.16
1 change: 1 addition & 0 deletions logfile.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2021/06/10 11:16:25 参数都要填噢!!
144 changes: 144 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
package main

import (
"bufio"
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"sort"
"strings"
"time"
)

func main() {
var outPath string
var dataPath string

flag.StringVar(&outPath, "outPath", "", "prokka output file path")
flag.StringVar(&dataPath, "dataPath", "", "prokka source file path")

flag.Parse()
if (len(outPath) == 0 || len(dataPath) == 0) {
logger("missing params !!")
return
}

var files []string
files, err := GetAllFile(dataPath, files)
if err != nil {
logger("read file error")
return
}

for _, file := range files {
length := strings.Index(file, ".")
outPutDirSeg := file[0:length]
desPath := outPath + "/" + outPutDirSeg + "_prokka"
_, err := os.Stat(desPath)

if os.IsNotExist(err) {
//ret := getGenArray(outPutDirSeg, files)
//file1 := ret[0]
//file2 := ret[1]

cmd := "prokka --compliant " + dataPath + "/" + file + " --outdir " + desPath

logger(cmd)
Command(cmd)
}

}



}

func Command(cmd string) error {
c := exec.Command("bash", "-c", cmd)
stdout, err := c.StdoutPipe()
if err != nil {
return err
}
go func() {
reader := bufio.NewReader(stdout)
for {
readString, err := reader.ReadString('\n')
if err != nil || err == io.EOF {
break
}
fmt.Print(readString)
}
}()
return c.Run()
}

func getGenArray(seg string, files []string) ([]string) {
var ret []string
for _, file := range files {
length := strings.Index(file, "_")
outPutDirSeg := file[0:length]
if seg == outPutDirSeg {
ret = append(ret, file)
}
}

sort.Sort(sort.StringSlice(ret))

return ret
}

func GetAllFile(pathname string, s []string) ([]string, error) {
rd, err := ioutil.ReadDir(pathname)
if err != nil {
fmt.Println("read dir fail:", err)
return s, err
}
for _, fi := range rd {
if fi.IsDir() {
fullDir := pathname + "/" + fi.Name()
s, err = GetAllFile(fullDir, s)
if err != nil {
fmt.Println("read dir fail:", err)
return s, err
}
} else {
//仅返回文件名
//fullName := pathname + "/" + fi.Name()
fullName := fi.Name()
s = append(s, fullName)
}
}
return s, nil
}

func logger(logthis string) {
filePath := "logfile.log"
fmt.Println(logthis)
_, err := os.Stat(filePath)
if os.IsNotExist(err) {
_, err := os.Create(filePath)
if err != nil {
fmt.Println(err)
}

}
file, err := os.OpenFile(filePath, os.O_WRONLY | os.O_TRUNC, 0666)
// file, err := os.OpenFile(filePath, os.O_WRONLY | os.O_APPEND, 0666)
if err != nil {
fmt.Printf("open file err=%v\n", err)
return
}

defer file.Close()

now := time.Now()
time := now.Format("2006/01/02 15:04:05")
str := fmt.Sprintf("%v %v ", time, logthis)
writer := bufio.NewWriter(file)
writer.WriteString(str)

writer.Flush()
}
Empty file added test.php
Empty file.

0 comments on commit 69bd1f2

Please sign in to comment.