Skip to content

Commit

Permalink
few updates to scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mfiers committed May 31, 2012
1 parent fd29bb6 commit b1c67ed
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
9 changes: 7 additions & 2 deletions bin/fastaInfo
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ parser.add_option('-S', dest='statsSimple',
action='store_true')
parser.set_defaults(graphengine="R")
parser.add_option('-g', dest='graphengine',
help='either "R" or "gnuplot" is used to generated the graphs')
help='either "R", "gnuplot" or "none" is used to generated the graphs')
parser.set_defaults(histogramsteps=50)
parser.add_option('-b', dest='histogramsteps', type="int",
help='no of bins to use in the histograms')
Expand Down Expand Up @@ -128,7 +128,7 @@ if options.stats:
for x in args:
dd[x] = []

funcs = ['length', 'fracn', 'id', 'scaf10', 'scaf100', 'gcfrac', 'ncount']
funcs = ['length', 'fracn', 'id', 'scaf10', 'scaf1', 'scaf100', 'gcfrac', 'ncount']

def f_id(name, seq):
return name.split()[0]
Expand All @@ -152,8 +152,13 @@ def f_gcfrac(name, seq):
t = seq.count('t')
return float(g+c) / (g + c + a + t)

scaf1rex = re.compile(r'n{1,}')
scaf10rex = re.compile(r'n{10,}')
scaf100rex = re.compile(r'n{100,}')

def f_scaf1(name,seq):
return len(scaf10rex.split(seq))

def f_scaf10(name,seq):
return len(scaf10rex.split(seq))

Expand Down
28 changes: 24 additions & 4 deletions bin/moar
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,36 @@

import os
import sys
import argparse
import subprocess as sp

base = os.path.abspath(os.getcwd())
parser = argparse.ArgumentParser(description='run recursively')
parser.add_argument('--bg', dest='background', action='store_true',
default=False,
help='run in the background')
parser.add_argument('-d', dest='depth', default=0, help='depth: 1 means run only in first ' +
'level subdirs, 2 only in second level, and so on', type=int)
parser.add_argument('command', nargs='+')
args = parser.parse_args()

cl = " ".join(args.command).strip()
if args.background and cl[-1] != '&':
cl = '( ' + cl + ' )& '

print 'executing:', cl

if base[-1] == '/': base = base[:-1]

cl = " ".join(sys.argv[1:])
print 'executing:'
print cl
for path, dirs, files in os.walk(base):
toRemove = [x for x in dirs if x[0] in ['.', '_']]
[dirs.remove(x) for x in toRemove]
print 'executing in %s' % path
localpath = path.replace(base, '')
level = len(localpath.split('/')) - 1

if args.depth and args.depth != level:
continue
print 'executing in %s' % localpath

P = sp.Popen(cl, cwd=path, shell=True)
P.wait()

0 comments on commit b1c67ed

Please sign in to comment.