想调用linux下的awk命令....一个一个+有点乱 。。。。
酱紫的...
```python
mutationid2=os.popen('''awk -F"\t" 'NR>1{
var["Missense_Mutation"]="Missense_Mutation";
var["Nonsense_Mutation"]="Nonsense_Mutation";
var["Nonstop_Mutation"]="Nonstop_Mutation";
var["Splice_Site"]="Splice_Site";
var["In_Frame_Del"]="In_Frame_Del";
var["Frame_Shift_Del"]="Frame_Shift_Del";
var["In_Frame_Ins"]="In_Frame_Ins";
var["Frame_Shift_Ins"]="Frame_Shift_Ins";
if($9 in var){
print $0;
}
}' %s |awk -F"\t" '{if($5!="MT" && $5!="X" && $5!="Y" && $1!="Hugo_Symbol" && $10=="SNP"){print $1":"$5":"$6}}' |sort -ru '''%i(maflist)).read().strip().split("\n")
```
maflist是几百个文件...
想用go做一个一样功能的
基本上实现了...原来··可以的,小白伤不起啊...,话说就调用一个系统命令要这么多行...
```go
package main
import (
"fmt"
"io/ioutil"
"os/exec"
)
func main() {
var maflist string = "~/softtest/advance/script/maf/RSS2.somatic.snvindel.maf ~/softtest/advance/script/maf/RSS4.somatic.snvindel.maf ~/softtest/advance/script/maf/RSS1.somatic.snvindel.maf ~/softtest/advance/script/maf/RSS3.somatic.snvindel.maf ~/softtest/advance/script/maf/RSS5.somatic.snvindel.maf"
var a string =`awk -F"\t"
NR>1{var["Missense_Mutation"]="Missense_Mutation";var["Nonsense_Mutation"]="Nonsense_Mutation";var["Nonstop_Mutation"]="Nonstop_Mutation";var["Splice_Site"]="Splice_Site";var["In_Frame_Del"]="In_Frame_Del";var["Frame_Shift_Del"]="Frame_Shift_Del";var["In_Frame_Ins"]="In_Frame_Ins";var["Frame_Shift_Ins"]="Frame_Shift_Ins";if($9 in var){print $0;}}' `+ maflist +` |awk -F"\t" '{if($5!="MT" && $5!="X" && $5!="Y" && $1!="Hugo_Symbol" && $10=="SNP"){print $1":"$5":"$6}}' |sort -ru`
cmd := exec.Command("/bin/sh", "-c",a)
stdout, err:= cmd.StdoutPipe()
if err != nil {
fmt.Println("StdoutPipe: " + err.Error())
return
}
stderr, err := cmd.StderrPipe()
if err != nil {
fmt.Println("StderrPipe: ", err.Error())
return
}
if err := cmd.Start(); err != nil {
fmt.Println("Start: ", err.Error())
return
}
bytesErr, err := ioutil.ReadAll(stderr)
if err != nil {
fmt.Println("ReadAll stderr: ", err.Error())
return
}
if len(bytesErr) != 0 {
fmt.Printf("stderr is not nil: %s", bytesErr)
return
}
bytes, err := ioutil.ReadAll(stdout)
if err != nil {
fmt.Println("ReadAll stdout: ", err.Error())
return
}
if err := cmd.Wait(); err != nil {
fmt.Println("Wait: ", err.Error())
return
}
fmt.Printf("stdout: %s", bytes)
}
```
#1