Example #1
0
 def __init__(self, opts):
     if not os.path.exists(opts.jar):
         raise ValueError, 'jar file does not exist'
     self.jar = opts.jar
     self.tmp_dir = opts.tmp_dir
     self.log_suffix = opts.suffix_tmpl % (timestamp(), 'log')
     self.maxjheap = opts.maxjheap
     self.output_dir = os.path.dirname(opts.output)
     self.runs = []
     self.logs = []
 def __init__(self, opts):
     if not os.path.exists(opts.jar):
         raise ValueError, "jar file does not exist"
     self.jar = opts.jar
     self.tmp_dir = opts.tmp_dir
     self.log_suffix = opts.suffix_tmpl % (timestamp(), "log")
     self.maxjheap = opts.maxjheap
     self.output_dir = os.path.dirname(opts.output)
     self.runs = []
     self.logs = []
Example #3
0
    op.add_option('-n', '--title', default='')
    op.add_option('-v', '--verbose', action='store_true')

    opts, args = op.parse_args()
    assert opts.input <> None
    assert os.path.isfile(opts.input)
    assert os.path.isfile(opts.jar)

    if not os.path.exists(opts.tmp_dir): os.makedirs(opts.tmp_dir)

    suffix_tmpl = 'rgTempFixMate_%s.%s'
    opts.suffix_tmpl = suffix_tmpl

    # Picard tools always produces bam files. Naming accordingly...
    ifd, intermediate_filename = tempfile.mkstemp(suffix=suffix_tmpl %
                                                  (timestamp(), 'bam'),
                                                  dir=opts.tmp_dir)

    fm = fixMate(opts)
    fm.run(os.path.abspath(opts.input), output_file=intermediate_filename)

    if opts.verbose:
        for run, log in zip(fm.runs, fm.logs):
            print 'Call to \n%s\n produced the following output:\n%s' % (run,
                                                                         log)

    intermediate = Bam(intermediate_filename)

    # Picard tool produced intermediate bam file. Depending on the
    # desired format, we either just move to final location or create
    # a sam version of it.
    op.add_option("-n", "--title", default="")
    op.add_option("-v", "--verbose", action="store_true")

    opts, args = op.parse_args()
    assert opts.input <> None
    assert os.path.isfile(opts.input)
    assert os.path.isfile(opts.jar)

    if not os.path.exists(opts.tmp_dir):
        os.makedirs(opts.tmp_dir)

    suffix_tmpl = "rgTempFixMate_%s.%s"
    opts.suffix_tmpl = suffix_tmpl

    # Picard tools always produces bam files. Naming accordingly...
    ifd, intermediate_filename = tempfile.mkstemp(suffix=suffix_tmpl % (timestamp(), "bam"), dir=opts.tmp_dir)

    fm = fixMate(opts)
    fm.run(os.path.abspath(opts.input), output_file=intermediate_filename)

    if opts.verbose:
        for run, log in zip(fm.runs, fm.logs):
            print "Call to \n%s\n produced the following output:\n%s" % (run, log)

    intermediate = Bam(intermediate_filename)

    # Picard tool produced intermediate bam file. Depending on the
    # desired format, we either just move to final location or create
    # a sam version of it.
    if opts.newformat == "sam":
        sam_file = intermediate.to_sam(os.path.abspath(opts.output))