def run_calculations(self):
        """Collect the settings and launch the calculation."""
        statusmsg = self.statusbar.showMessage
        button_ok = self.bb_ok_cancel.button(QtGui.QDialogButtonBox.Ok)
        button_ok.setEnabled(False)
        infile = str(self.le_infile.text())
        outfile = filehandle(str(self.le_outfile.text()), 'w')
        xmax = self.dsb_1.value()
        ymax = self.dsb_2.value()
        if (xmax + ymax) == 0:
            statusmsg('Input size required!')
            button_ok.setEnabled(True)
            return
        xtgt = self.sb_1.value()
        ytgt = self.sb_2.value()
        set_loglevel(self.sl_verbosity.value())

        statusmsg('Parsing XML file...')
        spots = StatisticsSpots(infile)
        spots.set_limits(xmax=xmax, ymax=ymax)
        statusmsg('Generating bitmap...')
        bitmap = spots.gen_bitmap((xtgt, ytgt), delta=50)
        statusmsg('Writing output file...')
        savetxt(outfile, bitmap, fmt='%i')
        statusmsg('Finished writing bitmap (%i x %i).' % (xtgt, ytgt))
        button_ok.setEnabled(True)
def main_noninteractive():
    """The main routine for running non-interactively."""
    global imcftpl
    args = parse_arguments()
    set_loglevel(args.verbose)
    log.info('Running in non-interactive mode.')
    log.debug('Python FluoView package file: %s' % fv.__file__)
    base = dirname(args.mosaiclog)
    fname = basename(args.mosaiclog)
    mosaics = fv.FluoViewMosaic(join(base, fname))
    log.warn(gen_mosaic_details(mosaics))
    if args.templates is not None:
        imcftpl = args.templates
    code = imagej.gen_stitching_macro_code(mosaics, 'templates/stitching',
                                           path=base, tplpath=imcftpl)
    if not args.dryrun:
        log.info('Writing stitching macro.')
        imagej.write_stitching_macro(code, fname='stitch_all.ijm', dname=base)
        log.info('Writing tile configuration files.')
        imagej.write_all_tile_configs(mosaics, fixsep=True)
        log.info('Launching stitching macro.')
        IJ.runMacro(flatten(code))
    else:
        log.info('Dry-run was selected. Printing generated macro:')
        log.warn(flatten(code))
def main():
    """Parse the commandline and dispatch the calculations."""
    args = parse_arguments()
    set_loglevel(args.verbosity)
    spots_r = parse_coordinates(args.reference, 'reference')
    spots_c = parse_coordinates(args.candidate, 'candidate')
    (edm, pairs) = closest_pairs(spots_r, spots_c)
    if (args.csv.name != '<stdout>'):
        for pair in pairs:
            csv_write_distances(args.csv, edm, pair[0])
def main():
    """Create the junction object and do the requested tasks."""
    args = parse_arguments()
    set_loglevel(args.verbosity)

    junction = vp.CellJunction(args.p3d, args.edges)

    if args.outfile:
        junction.write_output(args.outfile, args.infile)

    if args.plot or args.export_plot:
        plot.junction(junction, args.plot, args.export_plot)
def main():
    """Parse commandline arguments and run parser."""
    args = parse_arguments()
    set_loglevel(args.verbosity)

    log.debug("Using 'olefile' version %s (%s)." %
             (olefile.__version__, olefile.__date__))

    ole = olefile.OleFileIO(args.oib)
    stream = ole.openstream(['OibInfo.txt'])
    # stream = ole.openstream(['Storage00001', 'Stream00060'])
    conv = codecs.decode(stream.read(), 'utf16')
    log.warn(conv)
def main():
    """Parse commandline arguments and run parser."""
    args = parse_arguments()
    set_loglevel(args.verbosity)

    dname = dirname(args.mosaic.name)
    fname = basename(args.mosaic.name)
    if args.out == '':
        dout = dname
    else:
        dout = args.out

    mosaic = fv.FluoViewMosaic(args.mosaic.name)
    ij.write_all_tile_configs(mosaic, fixsep=args.fixsep)
    code = ij.gen_stitching_macro_code(mosaic, 'stitching', path=dname)
    ij.write_stitching_macro(code, 'stitch_all.ijm', dout)
    def run_calculations(self):
        """Collect the settings and launch the calculation."""
        statusmsg = self.statusbar.showMessage
        button_ok = self.bb_ok_cancel.button(QtGui.QDialogButtonBox.Ok)
        button_ok.setEnabled(False)
        in_csv = str(self.le_infile.text())
        out_csv = filehandle(str(self.le_outfile.text()), 'w')
        set_loglevel(self.sl_verbosity.value())

        statusmsg('Parsing junction files...')
        junction = vp.CellJunction(in_csv)
        statusmsg('Writing output files...')
        junction.write_output(out_csv, in_csv)
        if (self.cb_option.checkState() == 2):
            statusmsg('Showing plot...')
            plot.junction(junction, True, False)
        statusmsg('Finished.')
        button_ok.setEnabled(True)
def main():
    """Parse commandline arguments and run distance calculations."""
    args = parse_arguments()
    set_loglevel(args.verbosity)
    log.warn("Calculating distances to WingJ structures...")

    if args.imsxml is not None:
        coords = ix.ImarisXML(args.imsxml).coordinates_2d("Position")
    elif args.ijroi is not None:
        coords = read_csv_com(args.ijroi)
        coords *= args.pixelsize
    else:
        # this shouldn't happen with argparse, but you never know...
        raise AttributeError("no reference file given!")

    wingj = WingJStructure(args.directory, args.pixelsize)
    wingj.min_dist_csv_export(coords, args.directory)

    log.warn("Finished.")
#!/usr/bin/python

"""Tests the volpy filament parser."""

# TODO: this is not doing any useful automated tests yet, integrate a
# run_test() function and add some useful datasets!
# For the time being, this just serves as an example how to test the modules'
# functionality.

from log import set_loglevel
import fluoview
from os.path import dirname

reload(fluoview)
set_loglevel(3)
basedir = 'TESTDATA/fluoview/'

testfile = basedir + 'minimal_1mosaic_15pct/' + 'MATL_Mosaic.log'

mosaic_exp = fluoview.FluoViewMosaic(testfile)
mdc = mosaic_exp[0]
mdc.dim
mdc.get_overlap()
mdc.storage
oifds = mdc.subvol[3]
oifds.get_dimensions()
oifds.position
oifds.storage

Example #10
0

TAG_RE = re.compile(r'<[^>]+>')
def remove_tags(text):
        return TAG_RE.sub('', text)

def escape_xml(s):
    s = s.replace('&', '&amp;')
    s = s.replace('"', '&quot;')
    s = s.replace('\'', '&apos;')
    s = s.replace('<', '&lt;')
    s = s.replace('>', '&gt;')
    return s

if __name__ == '__main__':
    log.set_loglevel(6)
    
    g2p = G2p()

    root = minidom.Document() 

    xml = root.createElement('result')
    root.appendChild(xml)

    #cmudict_help = minidom.parseString("<help>"+PhonemeSet+"</help>").firstChild
    cmudict_help = root.createElement('help')
    link = root.createElement('a')
    link.setAttribute('href', "http://www.speech.cs.cmu.edu/cgi-bin/cmudict")
    cmudict_help.appendChild(link)
    link = root.createElement('a')
    link.setAttribute('href', "https://en.wikipedia.org/wiki/ARPABET")
Example #11
0
def main():
    parser = argparse.ArgumentParser()

    parser.add_argument(
        'output_dir', help='output directory for backup'
    )
    parser.add_argument(
        '-d', '--debug', action='store_true', 
        help='run in debug mode and output verbose logging'
    )
    parser.add_argument(
        '-p', '--per-page', default=500, type=int, nargs='?',
        help='number of photos per page'
    )
    parser.add_argument(
        '-s', '--search-dirs', nargs='*',
        help='list of directories to search'
    )

    args = parser.parse_args()

    loglevel = logging.INFO
    if args.debug:
        loglevel = logging.DEBUG
        log.set_loglevel(loglevel)

    touchr = ZooomrTouchr(args.output_dir, args.search_dirs)

    ## create outputdir if it does not exist
    if not os.path.exists(args.output_dir):
        os.makedirs(args.output_dir)

    resp = touchr.zapi.people_getPhotos(
        user_id=touchr.zapi.nsid, 
        per_page=args.per_page
    )
    total_photos = int(resp.find('photos').get('total'))
    total_pages = int(resp.find('photos').get('pages'))

    logger.info("Downloading %d photos on %d pages.", total_photos, total_pages)

    def extra_photo_ids(xml):
        dct = [] 
        for photo_elem in xml.findall('photos/photo'):
            dct.append(photo_elem.get('id'))

        return dct 

    ## process initial page in 'resp'
    photo_ids = extra_photo_ids(resp)

    ## process following pages
    for page_idx in range(2, total_pages+1):
        resp = touchr.zapi.people_getPhotos(
            user_id=touchr.zapi.nsid, 
            page=page_idx, 
            per_page=args.per_page
        )
        photo_ids.extend(extra_photo_ids(resp))

    assert(len(photo_ids) == total_photos)

    logger.debug('List of photo IDs: %s', photo_ids)

    for photo_id in photo_ids:
        download_data = touchr.download_photo(photo_id)

        if download_data is not None:
            filename, metadata = download_data

            ## store metadata in photo
            touchr.meta_handler.store_metadata(
                os.path.join(touchr.output_dir, filename),
                metadata
            )

    if os.path.getsize(ERROR_LOG) > 0:
        logger.info(
            'errors during processing. see %s.log for details.',
            ERROR_LOG
        )
    else:
        logger.info('Yeah!!! All photos backuped successfully.')
from volpy import Filament
from log import set_loglevel, set_filehandler


def run_test(fin, fout, flog):
    set_filehandler(flog, no_stderr=True, mode='w')
    flmnt = Filament(fin)

    output = open(fout, 'w')
    output.write(str(flmnt.get_coords()))
    print 'Parsed %i points from "%s"' % \
        (len(flmnt.get_coords()), fin)
    print('Written results to "%s"' % fout)

set_loglevel(2)
basedir = 'TESTDATA/filaments/'

infile = basedir + 'testdata-filaments-small.csv'
outfile = basedir + 'result_filaments-small.coords.txt'
logfile = basedir + 'result_filaments-small.stderr.txt'
run_test(infile, outfile, logfile)

infile = basedir + 'testdata-filaments-manual.csv'
outfile = basedir + 'result_filaments-manual.coords.txt'
logfile = basedir + 'result_filaments-manual.stderr.txt'
run_test(infile, outfile, logfile)

infile = basedir + 'testdata-junction-wt-001.csv'
outfile = basedir + 'result_junction-wt-001.coords.txt'
logfile = basedir + 'result_junction-wt-001.stderr.txt'