Original GEMINI specific data loader, only works with hg19/GRCh37.
179880
def create_gemini_db_orig(gemini_vcf, data, gemini_db=None, ped_file=None):
    
    if not gemini_db:
        gemini_db = "%s.db" % utils.splitext_plus(gemini_vcf)[0]
    if not utils.file_exists(gemini_db):
        if not vcfutils.vcf_has_variants(gemini_vcf):
            return None
        with file_transaction(data, gemini_db) as tx_gemini_db:
            gemini = config_utils.get_program("gemini", data["config"])
            load_opts = ""
            if "gemini_allvariants" not in dd.get_tools_on(data):
                load_opts += " --passonly"
            # For small test files, skip gene table loading which takes a long time
            if _is_small_vcf(gemini_vcf):
                load_opts += " --skip-gene-tables"
            if "/test_automated_output/" in gemini_vcf:
                load_opts += " --test-mode"
            # Skip CADD or gerp-bp if neither are loaded
            gemini_dir = install.get_gemini_dir(data)
            for skip_cmd, check_file in [("--skip-cadd", "whole_genome_SNVs.tsv.compressed.gz")]:
                if not os.path.exists(os.path.join(gemini_dir, check_file)):
                    load_opts += " %s" % skip_cmd
            # skip gerp-bp which slows down loading
            load_opts += " --skip-gerp-bp "
            num_cores = data["config"]["algorithm"].get("num_cores", 1)
            tmpdir = os.path.dirname(tx_gemini_db)
            eanns = _get_effects_flag(data)
            # Apply custom resource specifications, allowing use of alternative annotation_dir
            resources = config_utils.get_resources("gemini", data["config"])
            gemini_opts = " ".join([str(x) for x in resources["options"]]) if resources.get("options") else ""
            exports = utils.local_path_export()
            cmd = ("{exports} {gemini} {gemini_opts} load {load_opts} "
                   "-v {gemini_vcf} {eanns} --cores {num_cores} "
                   "--tempdir {tmpdir} {tx_gemini_db}")
            cmd = cmd.format(**locals())
            do.run(cmd, "Create gemini database for %s" % gemini_vcf, data)
            if ped_file:
                cmd = [gemini, "amend", "--sample", ped_file, tx_gemini_db]
                do.run(cmd, "Add PED file to gemini database", data)
    return gemini_db
872285
def load_bbg_generic(sid_or_accessor, start=None, end=None):
    
    end = end and pd.to_datetime(end) or pd.datetime.now()
    start = start and pd.to_datetime(start) or end + pd.datetools.relativedelta(years=-1)

    FLDS = ['PX_OPEN', 'PX_HIGH', 'PX_LOW', 'PX_LAST']
    RENAME = {'PX_OPEN': 'open', 'PX_HIGH': 'high', 'PX_LOW': 'low', 'PX_LAST': 'close'}
    accessor = _resolve_accessor(sid_or_accessor)
    sid = accessor.sid
    pxframe = accessor.get_historical(FLDS, start=start, end=end).rename(columns=RENAME)
    pxs = InstrumentPrices(pxframe)
    return Instrument(sid, pxs, multiplier=1.)
1016763
def _recv_ff(self, data):
        """"""
        self.rx_timer.cancel()
        if self.rx_state != ISOTP_IDLE:
            warning("RX state was reset because first frame was received")
            self.rx_state = ISOTP_IDLE

        if len(data) < 7:
            return 1
        self.rx_ll_dl = len(data)

        # get the FF_DL
        self.rx_len = (six.indexbytes(data, 0) & 0x0f) * 256 + six.indexbytes(
            data, 1)
        ff_pci_sz = 2

        # Check for FF_DL escape sequence supporting 32 bit PDU length
        if self.rx_len == 0:
            # FF_DL = 0 => get real length from next 4 bytes
            self.rx_len = six.indexbytes(data, 2) << 24
            self.rx_len += six.indexbytes(data, 3) << 16
            self.rx_len += six.indexbytes(data, 4) << 8
            self.rx_len += six.indexbytes(data, 5)
            ff_pci_sz = 6

        # copy the first received data bytes
        data_bytes = data[ff_pci_sz:]
        self.rx_idx = len(data_bytes)
        self.rx_buf = data_bytes

        # initial setup for this pdu reception
        self.rx_sn = 1
        self.rx_state = ISOTP_WAIT_DATA

        # no creation of flow control frames
        if not self.listen_mode:
            # send our first FC frame
            load = self.ea_hdr
            load += struct.pack("BBB", N_PCI_FC, self.rxfc_bs, self.rxfc_stmin)
            self.can_send(load)

        # wait for a CF
        self.rx_bs = 0
        self.rx_timer.set_timeout(self.cf_timeout, self._rx_timer_handler)

        return 0
925592
def restart_with_reloader(self):
        
        while True:
            LOGGER.info('Restarting with %s reloader' % self.name)
            args = _get_args_for_reloading()
            new_environ = os.environ.copy()
            new_environ[PULSAR_RUN_MAIN] = 'true'
            exit_code = subprocess.call(args, env=new_environ, close_fds=False)
            if exit_code != EXIT_CODE:
                return exit_code
91611
def view(ctx, host, port, debug, pattern, family_file, family_type,
         variant_source, root, no_browser, phenomizer):
    
    main_loop = (not debug) or (os.environ.get('WERKZEUG_RUN_MAIN') == 'true')
    root = root or ctx.obj.get('root') or os.path.expanduser("~/.puzzle")
    phenomizer_auth = phenomizer or ctx.obj.get('phenomizer_auth')
    BaseConfig.PHENOMIZER_AUTH = True if ctx.obj.get('phenomizer_auth') else False
    BaseConfig.STORE_ENABLED = True

    if variant_source is None:
        logger.info("Root directory is: {}".format(root))

        db_path = os.path.join(root, 'puzzle_db.sqlite3')
        logger.info("db path is: {}".format(db_path))
        if not os.path.exists(db_path):
            logger.warn("database not initialized, run 'puzzle init'")
            ctx.abort()

        if os.path.isfile(root):
            logger.error("'root' can't be a file")
            ctx.abort()

        store = SqlStore(db_path, phenomizer_auth=phenomizer_auth)
        for case_obj in store.cases():
            if case_obj.variant_mode == 'gemini':
                if not GEMINI:
                    logger.error("Need to have gemini instaled to view gemini database")
                    ctx.abort()

    else:
        logger.info("Using in memory database")
        tmpdir = tempfile.mkdtemp()
        tmpdb = os.path.join(tmpdir, 'puzzle.sqlite3')
        logger.info("building database: {}".format(tmpdb))
        store = SqlStore("sqlite:///{}".format(tmpdb),
                         phenomizer_auth=phenomizer_auth)
        if main_loop:
            store.set_up()
            cases = []
            if os.path.isfile(variant_source):
                file_type = get_file_type(variant_source)
                #Test if gemini is installed
                if file_type == 'unknown':
                    logger.error("File has to be vcf or gemini db")
                    ctx.abort()
                elif file_type == 'gemini':
                    #Check if gemini is installed
                    if not GEMINI:
                        logger.error("Need to have gemini installed to use gemini plugin")
                        ctx.abort()
                variant_type = get_variant_type(variant_source)
                cases = get_cases(
                    variant_source=variant_source,
                    case_lines=family_file,
                    case_type=family_type,
                    variant_type=variant_type,
                    variant_mode=file_type
                )
            else:
                for file in path(variant_source).walkfiles(pattern):
                    file_type = get_file_type(file)
                    if file_type != 'unknown':
                        variant_type = get_variant_type(file)
                        #Test if gemini is installed
                        if file_type == 'gemini':
                            if not GEMINI:
                                logger.error("Need to have gemini installed to use gemini plugin")
                                ctx.abort()

                        for case in get_cases(
                            variant_source=file,
                            case_type=family_type,
                            variant_type=variant_type,
                            variant_mode=file_type):

                            cases.append(case)

            for case_obj in cases:
                if store.case(case_obj.case_id) is not None:
                    logger.warn("{} already exists in the database"
                                .format(case_obj.case_id))
                    continue

                # extract case information
                logger.debug("adding case: {}".format(case_obj.case_id))
                store.add_case(case_obj, vtype=case_obj.variant_type, mode=case_obj.variant_mode)

    logger.debug("Plugin setup was succesfull")
    BaseConfig.PUZZLE_BACKEND = store
    BaseConfig.UPLOAD_DIR = os.path.join(root, 'resources')

    app = create_app(config_obj=BaseConfig)

    if no_browser is False:
        webbrowser.open_new_tab("http://{}:{}".format(host, port))

    app.run(host=host, port=port, debug=debug)
694056
def _xdr_read_asset(unpacker):
    """"""
    asset = messages.StellarAssetType(type=unpacker.unpack_uint())

    if asset.type == ASSET_TYPE_ALPHA4:
        asset.code = unpacker.unpack_fstring(4)
        asset.issuer = _xdr_read_address(unpacker)

    if asset.type == ASSET_TYPE_ALPHA12:
        asset.code = unpacker.unpack_fstring(12)
        asset.issuer = _xdr_read_address(unpacker)

    return asset
1332759
def write(self):
        

        data = [
            struct.pack("<4sBBqIIi", b"OggS", self.version, self.__type_flags,
                        self.position, self.serial, self.sequence, 0)
        ]

        lacing_data = []
        for datum in self.packets:
            quot, rem = divmod(len(datum), 255)
            lacing_data.append(b"\xff" * quot + chr_(rem))
        lacing_data = b"".join(lacing_data)
        if not self.complete and lacing_data.endswith(b"\x00"):
            lacing_data = lacing_data[:-1]
        data.append(chr_(len(lacing_data)))
        data.append(lacing_data)
        data.extend(self.packets)
        data = b"".join(data)

        # Python's CRC is swapped relative to Ogg's needs.
        # crc32 returns uint prior to py2.6 on some platforms, so force uint
        crc = (~zlib.crc32(data.translate(cdata.bitswap), -1)) & 0xffffffff
        # Although we're using to_uint_be, this actually makes the CRC
        # a proper le integer, since Python's CRC is byteswapped.
        crc = cdata.to_uint_be(crc).translate(cdata.bitswap)
        data = data[:22] + crc + data[26:]
        return data
470936
def gemini_writer(self, f_handle):
        
        f_handle.write(GEMINI_HEADER)
        # Date__(UT)__HR:MN Date_________JDUT     R.A.___(ICRF/J2000.0)___DEC dRA*cosD d(DEC)/dt
        #          1         2         3         4         5         6         7         8         9
        # 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
        # ' 2019-Jan-30 00:00     01 46 56.46 +10 28 54.9 01 47 56.17 +10 34 27.6    3.520

        for coordinate in self.coordinates:
            date = coordinate.obstime.datetime.strftime('%Y-%b-%d %H:%M')[:17]
            f_handle.write(" {:16} {:17.9f}    {:27} {:+8.5f} {:+8.5f}\n".format(date,
                                                                                 coordinate.obstime.jd,
                                                                                 coordinate.to_string('hmsdms',
                                                                                                      sep=' ',
                                                                                                      precision=4,
                                                                                                      pad=True)[:27],
                                                                                 float(coordinate.dra),
                                                                                 float(coordinate.ddec)),
                           )
        f_handle.write(GEMINI_FOOTER)
        return
539333
def _load_different_url_payload(self, cdx, headers_record,
                                    failed_files, cdx_loader):
        

        ref_target_uri = (headers_record.rec_headers.
                          get_header('WARC-Refers-To-Target-URI'))

        target_uri = headers_record.rec_headers.get_header('WARC-Target-URI')

        # if no target uri, no way to find the original
        if not ref_target_uri:
            raise ArchiveLoadFailed(self.MISSING_REVISIT_MSG)

        ref_target_date = (headers_record.rec_headers.
                           get_header('WARC-Refers-To-Date'))

        if not ref_target_date:
            ref_target_date = cdx['timestamp']
        else:
            ref_target_date = iso_date_to_timestamp(ref_target_date)

        digest = cdx.get('digest', '-')

        try:
            orig_cdx_lines = self.load_cdx_for_dupe(ref_target_uri,
                                                    ref_target_date,
                                                    digest,
                                                    cdx_loader)
        except NotFoundException:
            raise ArchiveLoadFailed(self.MISSING_REVISIT_MSG)

        for orig_cdx in orig_cdx_lines:
            try:
                payload_record = self._resolve_path_load(orig_cdx, False,
                                                         failed_files)
                return payload_record

            except ArchiveLoadFailed as e:
                pass

        raise ArchiveLoadFailed(self.MISSING_REVISIT_MSG)
291180
def _load32(ins):
    
    output = _32bit_oper(ins.quad[2])
    output.append('push de')
    output.append('push hl')
    return output
300976
def serial_connect(self):
		
		self.serial_get()
		try:
			self.serial_connection.start()
		except c1218.errors.C1218IOError as error:
			self.logger.error('serial connection has been opened but the meter is unresponsive')
			raise error
		self._serial_connected = True
		return True
892375
def sphgen(self, force_rerun=False):
        
        log.debug('{}: running sphere generation...'.format(self.id))

        if not self.dms_path:
            return ValueError('Please run dms_maker')

        sph = op.join(self.dock_dir, '{}_receptor.sph'.format(self.id))
        insph = op.join(self.dock_dir, 'INSPH')

        if ssbio.utils.force_rerun(flag=force_rerun, outfile=sph):
            with open(insph, "w") as f:
                f.write("{}\n".format(self.dms_path))
                f.write("R\n")
                f.write("X\n")
                f.write("0.0\n")
                f.write("4.0\n")
                f.write("1.4\n")
                f.write("{}\n".format(sph))

            os.chdir(self.dock_dir)
            cmd = "sphgen_cpp"
            os.system(cmd)
            os.remove(insph)

        if ssbio.utils.is_non_zero_file(sph):
            self.sphgen_path = sph
            log.debug('{}: successful sphgen execution'.format(self.sphgen_path))
        else:
            log.critical('{}: sphgen_cpp failed to run on dms file'.format(self.dms_path))
614743
def get_gemini_files(data):
    
    try:
        from gemini import annotations, config
    except ImportError:
        return {}
    return {"base": config.read_gemini_config()["annotation_dir"],
            "files": annotations.get_anno_files().values()}
1103290
def load_remote_molecule(url, format=None):
    '''

    '''
    filename, headers = urlretrieve(url)
    return load_molecule(filename, format=format)
65944
def flash_spi_attach(self, hspi_arg):
        
        # last 3 bytes in ESP_SPI_ATTACH argument are reserved values
        arg = struct.pack('<I', hspi_arg)
        if not self.IS_STUB:
            # ESP32 ROM loader takes additional 'is legacy' arg, which is not
            # currently supported in the stub loader or esptool.py (as it's not usually needed.)
            is_legacy = 0
            arg += struct.pack('BBBB', is_legacy, 0, 0, 0)
        self.check_command("configure SPI flash pins", ESP32ROM.ESP_SPI_ATTACH, arg)
1275782
function(cfg) {
// DynoFarm overrides
  if (cfg && cfg.redis) {
    if (cfg.redis.host) {
      redisHost = cfg.redis.host;
    }
    if (cfg.redis.port) {
      redisPort = cfg.redis.port;
    }
    if (cfg.redis.password) {
      redisPassword = cfg.redis.password;
    }
  }

  var client = redis.createClient(redisPort, redisHost);
  if (redisPassword) {
    client.auth(redisPassword);
  }
  return client;
}
21606
public static void checkMechanism(Oid mech)
	throws GSSException {
	if (mech != null && !mech.equals(GSSConstants.MECH_OID)) {
	    throw new GSSException(GSSException.BAD_MECH);
	}
    }