projects
/
htsworkflow.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6043e55
)
clean up the logic for deciding the output filename when using stdin
author
Diane Trout
<diane@caltech.edu>
Mon, 22 Dec 2008 20:43:32 +0000
(20:43 +0000)
committer
Diane Trout
<diane@caltech.edu>
Mon, 22 Dec 2008 20:43:32 +0000
(20:43 +0000)
as the input
scripts/makebed
patch
|
blob
|
history
diff --git
a/scripts/makebed
b/scripts/makebed
index 4878697b603970d0ab950d273493041884f82e7a..64ba518b1a91e54812938dce8fb813a51e38bf93 100755
(executable)
--- a/
scripts/makebed
+++ b/
scripts/makebed
@@
-45,6
+45,9
@@
def make_parser():
return parser
def main(command_line=None):
return parser
def main(command_line=None):
+ instream = None
+ outstream = None
+
if command_line is None:
command_line = sys.argv[1:]
if command_line is None:
command_line = sys.argv[1:]
@@
-63,22
+66,25
@@
def main(command_line=None):
parser.error('%s was not found' % (options.inname))
return 1
parser.error('%s was not found' % (options.inname))
return 1
+ # figure out name for output file
if options.outname is None:
# if outname wasn't defined, and we're reading from stdout
if instream is sys.stdin:
# write to stdout
outstream = sys.stdout
else:
if options.outname is None:
# if outname wasn't defined, and we're reading from stdout
if instream is sys.stdin:
# write to stdout
outstream = sys.stdout
else:
- # if there's a name write to name.b
de
+ # if there's a name write to name.b
ed
options.outname = os.path.splitext(options.inname)[0]+'.bed'
print >>sys.stderr, "defaulting to outputname", options.outname
elif options.outname == '-':
outstream = sys.stdout
options.outname = os.path.splitext(options.inname)[0]+'.bed'
print >>sys.stderr, "defaulting to outputname", options.outname
elif options.outname == '-':
outstream = sys.stdout
- elif os.path.exists(options.outname):
- parser.error("not overwriting %s" % (options.outname))
- return 1
- else:
- outstream = open(options.outname, 'w')
+
+ if outstream is None:
+ if os.path.exists(options.outname):
+ parser.error("not overwriting %s" % (options.outname))
+ return 1
+ else:
+ outstream = open(options.outname, 'w')
if options.flowcell is not None and options.lane is not None:
# get our name/description out of the database
if options.flowcell is not None and options.lane is not None:
# get our name/description out of the database