資源簡介
一款非常快速的生信分析軟件,是gatk完美的替代者。這里提供一個文件共大家分享。
代碼片段和文件信息
#!/usr/bin/env?python
#?vim:?ts=4?sw=4?expandtab
import?getopt
import?os?os.path
import?sys?subprocess
import?tempfile?math
_install_dir?=?os.path.realpath(os.path.join(os.path.dirname(__file__)?‘..‘))
_install_dir?=?os.environ.get(‘SENTIEON_INSTALL_DIR‘?_install_dir)
_paths?=?{?‘gnuplot.sh‘:?‘gnuplot.sh‘?}
for?kf?in?_paths.items():
????for?d?in?(‘bin‘?‘libexec‘):
????????p?=?os.path.join(os.path.join(_install_dir?d)?f)
????????if?os.path.exists(p):
????????????_paths[k]?=?p
????????????break
def?is_number(s):
????try:
????????float(s)
????????return?True
????except?ValueError:
????????return?False
#?output?to?pdf
class?GPWriter:
????def?__init__(self?out_gp?output?kwargs):
????????self.gpf?=?open(out_gp?‘w‘)
????????self.pagenum?=?1
????????self.output?=?output
????????self.output_format?=?kwargs.get(‘output_format‘?‘pdf‘)
????????if?self.output_format?==?‘png‘:
????????????self.gpf.write(‘set?terminal?pngcairo?size?12in?8in?enhanced\n‘)
????????else:
????????????self.gpf.write(‘set?terminal?pdf?size?10in?7.5in?enhanced\n‘)
????????????self.gpf.write(‘set?output?\“%s\“\n‘?%?self.getOutput())
????????self.tmpdir?=?kwargs.get(‘tmpdir‘?‘/tmp‘)
????????self.tmpfiles?=?[]
????????self.enableLogo?=?kwargs.get(‘logo‘?‘true‘)?==?‘true‘
????????self.logoOn?=?False
????def?getOutput(self):
????????if?self.output_format?==?‘png‘:
????????????return?‘%s-%02d.png‘%(self.output?self.pagenum)
????????else:
????????????return?self.output
????def?resetOutput(self):
????????if?self.output_format?==?‘png‘:
????????????self.gpf.write(‘set?output?\“%s\“\n‘?%?self.getOutput())
????????self.pagenum?+=?1????????
????#?print?log?only?once?per?page?for?multiplot
????#?need?turn?off?after?the?first?graph?for?multiplot
????def?printLogo(self):
????????if?not?self.enableLogo:
????????????return
????????self.gpf.write(‘set?label?1?“powered?by?Sentieon^{/*0.75?TM}“?at?screen?0.980.01?right?font?“sans10“?tc?rgb?“#00008B“\n‘)?#darkblue
????????self.logoOn?=?True
????def?unprintLogo(self):
????????if?self.logoOn:
????????????self.gpf.write(‘unset?label?1\n‘)
????????self.logoOn?=?False
????def?setScreenMargin(self):
????????self.gpf.write(‘set?lmargin?at?screen?0.1\nset?rmargin?at?screen?0.9\nset?bmargin?at?screen?0.1\nset?tmargin?at?screen?0.9\n‘)
????def?close(self):
????????self.gpf.close()
????def?clean(self):
????????for?a?in?self.tmpfiles:
????????????try:
????????????????os.remove(a)
????????????except?OSError:
????????????????pass
????def?check_plot_file(self?what?key?v):
????????found?=?False
????????linenum?=?0
????????with?open(v)?as?f:
????????????for?line?in?f:
????????????????linenum?=?linenum?+?1
????????????????if?not?found:
????????????????????if?line.startswith(key):
????????????????????????found?=?True
????????????????????????break
????????if?linenum?>?0?and?not?found:
????????????raise?Exception(“Incorrect?%s?plot?file?%s“%(what?v))
????????return?found
def?sharedLabelConvention(xlabel?ylabel?k?n?direction):
????if?n?==?1
評論
共有 條評論