Returns the GA4GH protocol representation of this ReadGroup.
512904
def toProtocolElement(self):
        
        # TODO this is very incomplete, but we don't have the
        # implementation to fill out the rest of the fields currently
        readGroup = protocol.ReadGroup()
        readGroup.id = self.getId()
        readGroup.created = self._creationTime
        readGroup.updated = self._updateTime
        dataset = self.getParentContainer().getParentContainer()
        readGroup.dataset_id = dataset.getId()
        readGroup.name = self.getLocalId()
        readGroup.predicted_insert_size = pb.int(self.getPredictedInsertSize())
        referenceSet = self._parentContainer.getReferenceSet()
        readGroup.sample_name = pb.string(self.getSampleName())
        readGroup.biosample_id = pb.string(self.getBiosampleId())
        if referenceSet is not None:
            readGroup.reference_set_id = referenceSet.getId()
        readGroup.stats.CopyFrom(self.getStats())
        readGroup.programs.extend(self.getPrograms())
        readGroup.description = pb.string(self.getDescription())
        readGroup.experiment.CopyFrom(self.getExperiment())
        self.serializeAttributes(readGroup)
        return readGroup
693847
def get
      gtype = self[:gtype]
      fundamental = ::GObject::g_type_fundamental gtype
      result = nil

      case gtype
      when GBOOL_TYPE
        result = ::GObject::g_value_get_boolean(self) != 0 ? true : false

      when GINT_TYPE
        result = ::GObject::g_value_get_int self

      when GUINT64_TYPE
        result = ::GObject::g_value_get_uint64 self

      when GDOUBLE_TYPE
        result = ::GObject::g_value_get_double self

      when GSTR_TYPE
        result = ::GObject::g_value_get_string self

      when Vips::REFSTR_TYPE
        len = Vips::SizeStruct.new
        result = ::Vips::vips_value_get_ref_string self, len

      when Vips::ARRAY_INT_TYPE
        len = Vips::IntStruct.new
        array = Vips::vips_value_get_array_int self, len
        result = array.get_array_of_int32 0, len[:value]

      when Vips::ARRAY_DOUBLE_TYPE
        len = Vips::IntStruct.new
        array = Vips::vips_value_get_array_double self, len
        result = array.get_array_of_double 0, len[:value]

      when Vips::ARRAY_IMAGE_TYPE
        len = Vips::IntStruct.new
        array = Vips::vips_value_get_array_image self, len
        result = array.get_array_of_pointer 0, len[:value]
        result.map! do |pointer|
          ::GObject::g_object_ref pointer
          Vips::Image.new pointer
        end

      when Vips::BLOB_TYPE
        len = Vips::SizeStruct.new
        array = Vips::vips_value_get_blob self, len
        result = array.get_bytes 0, len[:value]

      else
        case fundamental
        when GFLAGS_TYPE
          result = ::GObject::g_value_get_flags self

        when GENUM_TYPE
          enum_value = ::GObject::g_value_get_enum(self)
          result = GValue.to_nick self[:gtype], enum_value

        when GOBJECT_TYPE
          obj = ::GObject::g_value_get_object self
          # g_value_get_object() does not add a ref ... we need to add
          # one to match the unref in gobject release
          ::GObject::g_object_ref obj
          result = Vips::Image.new obj

        else
          raise Vips::Error, "unimplemented gtype for get: " +
              "#{::GObject::g_type_name gtype} (#{gtype})"

        end
      end

      # GLib::logger.debug("GObject::GValue.get") {
      #     "result = #{result.inspect[0..50]}"
      # }

      return result

    end
532509
def getVC(self):
        
        _Cr = decompose_GxE(self.fr['Cr'])
        RV = {}
        for key in list(_Cr.keys()):
            RV['var_%s' % key] = sp.array([var_CoXX(_Cr[key], self.Xr)])
        RV['var_g'] = sp.array([var_CoXX(self.fr['Cg'], self.XXh)])
        RV['var_n'] = sp.array([var_CoXX(self.fr['Cn'], sp.eye(self.XXh.shape[0]))])
        return RV
1293966
def toProtocolElement(self):
        
        protocolElement = protocol.VariantAnnotationSet()
        protocolElement.id = self.getId()
        protocolElement.variant_set_id = self._variantSet.getId()
        protocolElement.name = self.getLocalId()
        protocolElement.analysis.CopyFrom(self.getAnalysis())
        self.serializeAttributes(protocolElement)
        return protocolElement
296645
def toProtocolElement(self):
        
        variantSet = self.getParentContainer()
        gaCallSet = protocol.CallSet(
            biosample_id=self.getBiosampleId())
        if variantSet.getCreationTime():
            gaCallSet.created = variantSet.getCreationTime()
        if variantSet.getUpdatedTime():
            gaCallSet.updated = variantSet.getUpdatedTime()
        gaCallSet.id = self.getId()
        gaCallSet.name = self.getLocalId()
        gaCallSet.variant_set_ids.append(variantSet.getId())
        self.serializeAttributes(gaCallSet)
        return gaCallSet
836935
def _gam(self):
        
        log10gmin = np.log10(self.Eemin / mec2).value
        log10gmax = np.log10(self.Eemax / mec2).value
        return np.logspace(
            log10gmin, log10gmax, int(self.nEed * (log10gmax - log10gmin))
        )
306090
def gwcalctyp(self):
        """"""
        dig0 = str(self._SIGMA_TYPES[self.type])
        dig1 = str(self._SC_MODES[self.sc_mode])
        return dig1.strip() + dig0.strip()
1297778
def getGroupsURL(certfile, group):
    """"""

    GMS = "https://" + _SERVER + _GMS

    certfile.seek(0)
    buf = certfile.read()

    x509 = crypto.load_certificate(crypto.FILETYPE_PEM, buf)
    sep = ""
    dn = ""
    parts = []
    for i in x509.get_issuer().get_components():
        #print i
        if i[0] in parts:
            continue
        parts.append(i[0])
        dn = i[0] + "=" + i[1] + sep + dn
        sep = ","

    return GMS + "/" + group + "/" + urllib.quote(dn)
1024973
public OggData getData(InputStream input) throws IOException {
		if (input == null) {
			throw new IOException("Failed to read OGG, source does not exist?");
		}
		ByteArrayOutputStream dataout = new ByteArrayOutputStream();
		
//		SyncState oy = new SyncState(); // sync and verify incoming physical bitstream
//		StreamState os = new StreamState(); // take physical pages, weld into a logical stream of packets
//		Page og = new Page(); // one Ogg bitstream page.  Vorbis packets are inside
//		Packet op = new Packet(); // one raw packet of data for decode
//
//		Info vi = new Info(); // struct that stores all the static vorbis bitstream settings
//		Comment vc = new Comment(); // struct that stores all the bitstream user comments
//		DspState vd = new DspState(); // central working state for the packet->PCM decoder
//		Block vb = new Block(vd); // local working space for packet->PCM decode
//
//		byte[] buffer;
//		int bytes = 0;
//
//		boolean bigEndian = ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN);
//		// Decode setup
//
//		oy.init(); // Now we can read pages
//
//		while (true) { // we repeat if the bitstream is chained
//			int eos = 0;
//
//			// grab some data at the head of the stream.  We want the first page
//			// (which is guaranteed to be small and only contain the Vorbis
//			// stream initial header) We need the first page to get the stream
//			// serialno.
//
//			// submit a 4k block to libvorbis' Ogg layer
//			int index = oy.buffer(4096);
//			
//			buffer = oy.data;
//			try {
//				bytes = input.read(buffer, index, 4096);
//			} catch (Exception e) {
//				Log.error("Failure reading in vorbis");
//				Log.error(e);
//				System.exit(0);
//			}
//			oy.wrote(bytes);
//
//			// Get the first page.
//			if (oy.pageout(og) != 1) {
//				// have we simply run out of data?  If so, we're done.
//				if (bytes < 4096)
//					break;
//
//				// error case.  Must not be Vorbis data
//				Log.error("Input does not appear to be an Ogg bitstream.");
//				System.exit(0);
//			}
//
//			// Get the serial number and set up the rest of decode.
//			// serialno first; use it to set up a logical stream
//			os.init(og.serialno());
//
//			// extract the initial header from the first page and verify that the
//			// Ogg bitstream is in fact Vorbis data
//
//			// I handle the initial header first instead of just having the code
//			// read all three Vorbis headers at once because reading the initial
//			// header is an easy way to identify a Vorbis bitstream and it's
//			// useful to see that functionality seperated out.
//
//			vi.init();
//			vc.init();
//			if (os.pagein(og) < 0) {
//				// error; stream version mismatch perhaps
//				Log.error("Error reading first page of Ogg bitstream data.");
//				System.exit(0);
//			}
//
//			if (os.packetout(op) != 1) {
//				// no page? must not be vorbis
//				Log.error("Error reading initial header packet.");
//				System.exit(0);
//			}
//
//			if (vi.synthesis_headerin(vc, op) < 0) {
//				// error case; not a vorbis header
//				Log.error("This Ogg bitstream does not contain Vorbis audio data.");
//				System.exit(0);
//			}
//
//			// At this point, we're sure we're Vorbis.  We've set up the logical
//			// (Ogg) bitstream decoder.  Get the comment and codebook headers and
//			// set up the Vorbis decoder
//
//			// The next two packets in order are the comment and codebook headers.
//			// They're likely large and may span multiple pages.  Thus we reead
//			// and submit data until we get our two pacakets, watching that no
//			// pages are missing.  If a page is missing, error out; losing a
//			// header page is the only place where missing data is fatal. */
//
//			int i = 0;
//			while (i < 2) {
//				while (i < 2) {
//
//					int result = oy.pageout(og);
//					if (result == 0)
//						break; // Need more data
//					// Don't complain about missing or corrupt data yet.  We'll
//					// catch it at the packet output phase
//
//					if (result == 1) {
//						os.pagein(og); // we can ignore any errors here
//						// as they'll also become apparent
//						// at packetout
//						while (i < 2) {
//							result = os.packetout(op);
//							if (result == 0)
//								break;
//							if (result == -1) {
//								// Uh oh; data at some point was corrupted or missing!
//								// We can't tolerate that in a header.  Die.
//								Log.error("Corrupt secondary header.  Exiting.");
//								System.exit(0);
//							}
//							vi.synthesis_headerin(vc, op);
//							i++;
//						}
//					}
//				}
//				// no harm in not checking before adding more
//				index = oy.buffer(4096);
//				buffer = oy.data;
//				try {
//					bytes = input.read(buffer, index, 4096);
//				} catch (Exception e) {
//					Log.error("Failed to read Vorbis: ");
//					Log.error(e);
//					System.exit(0);
//				}
//				if (bytes == 0 && i < 2) {
//					Log.error("End of file before finding all Vorbis headers!");
//					System.exit(0);
//				}
//				oy.wrote(bytes);
//			}
//
//			convsize = 4096 / vi.channels;
//
//			// OK, got and parsed all three headers. Initialize the Vorbis
//			//  packet->PCM decoder.
//			vd.synthesis_init(vi); // central decode state
//			vb.init(vd); // local state for most of the decode
//			// so multiple block decodes can
//			// proceed in parallel.  We could init
//			// multiple vorbis_block structures
//			// for vd here
//
//			float[][][] _pcm = new float[1][][];
//			int[] _index = new int[vi.channels];
//			// The rest is just a straight decode loop until end of stream
//			while (eos == 0) {
//				while (eos == 0) {
//
//					int result = oy.pageout(og);
//					if (result == 0)
//						break; // need more data
//					if (result == -1) { // missing or corrupt data at this page position
//						Log.error("Corrupt or missing data in bitstream; continuing...");
//					} else {
//						os.pagein(og); // can safely ignore errors at
//						// this point
//						while (true) {
//							result = os.packetout(op);
//
//							if (result == 0)
//								break; // need more data
//							if (result == -1) { // missing or corrupt data at this page position
//								// no reason to complain; already complained above
//							} else {
//								// we have a packet.  Decode it
//								int samples;
//								if (vb.synthesis(op) == 0) { // test for success!
//									vd.synthesis_blockin(vb);
//								}
//
//								// **pcm is a multichannel float vector.  In stereo, for
//								// example, pcm[0] is left, and pcm[1] is right.  samples is
//								// the size of each channel.  Convert the float values
//								// (-1.<=range<=1.) to whatever PCM format and write it out
//
//								while ((samples = vd.synthesis_pcmout(_pcm,
//										_index)) > 0) {
//									float[][] pcm = _pcm[0];
//									//boolean clipflag = false;
//									int bout = (samples < convsize ? samples
//											: convsize);
//
//									// convert floats to 16 bit signed ints (host order) and
//									// interleave
//									for (i = 0; i < vi.channels; i++) {
//										int ptr = i * 2;
//										//int ptr=i;
//										int mono = _index[i];
//										for (int j = 0; j < bout; j++) {
//											int val = (int) (pcm[i][mono + j] * 32767.);
//											//			      short val=(short)(pcm[i][mono+j]*32767.);
//											//			      int val=(int)Math.round(pcm[i][mono+j]*32767.);
//											// might as well guard against clipping
//											if (val > 32767) {
//												val = 32767;
//												//clipflag = true;
//											}
//											if (val < -32768) {
//												val = -32768;
//												//clipflag = true;
//											}
//											if (val < 0)
//												val = val | 0x8000;
//				
//											if (bigEndian) {
//												convbuffer[ptr] = (byte) (val >>> 8);
//												convbuffer[ptr + 1] = (byte) (val);
//											} else {
//												convbuffer[ptr] = (byte) (val);
//												convbuffer[ptr + 1] = (byte) (val >>> 8);
//											}
//											ptr += 2 * (vi.channels);
//										}
//									}
//
//									dataout.write(convbuffer, 0, 2 * vi.channels * bout);
//
//									vd.synthesis_read(bout); // tell libvorbis how
//									// many samples we
//									// actually consumed
//								}
//							}
//						}
//						if (og.eos() != 0)
//							eos = 1;
//					}
//				}
//				if (eos == 0) {
//					index = oy.buffer(4096);
//					if (index >= 0) {
//						buffer = oy.data;
//						try {
//							bytes = input.read(buffer, index, 4096);
//						} catch (Exception e) {
//							Log.error("Failure during vorbis decoding");
//							Log.error(e);
//							return null;
//						}
//					} else {
//						bytes = 0;
//					}
//					oy.wrote(bytes);
//					if (bytes == 0)
//						eos = 1;
//				}
//			}
//
//			// clean up this logical bitstream; before exit we see if we're
//			// followed by another [chained]
//
//			os.clear();
//
//			// ogg_page and ogg_packet structs always point to storage in
//			// libvorbis.  They're never freed or manipulated directly
//
//			vb.clear();
//			vd.clear();
//			vi.clear(); // must be called last
//		}
//
//		// OK, clean up the framer
//		oy.clear();
//		OggData ogg = new OggData();
//		ogg.channels = vi.channels;
//		ogg.rate = vi.rate;

		OggInputStream oggInput = new OggInputStream(input);
		
		boolean done = false;
		while (!oggInput.atEnd()) {
			dataout.write(oggInput.read());
		}
	
		OggData ogg = new OggData();
		ogg.channels = oggInput.getChannels();
		ogg.rate = oggInput.getRate();
		
		byte[] data = dataout.toByteArray();
		ogg.data = ByteBuffer.allocateDirect(data.length);
		ogg.data.put(data);
		ogg.data.rewind();
		
		return ogg;
	}
304632
def get_msgbuf(self):
        ''''''
        values = []
        for i in range(len(self.fmt.columns)):
            if i >= len(self.fmt.msg_mults):
                continue
            mul = self.fmt.msg_mults[i]
            name = self.fmt.columns[i]
            if name == 'Mode' and 'ModeNum' in self.fmt.columns:
                name = 'ModeNum'
            v = self.__getattr__(name)
            if mul is not None:
                v /= mul
            values.append(v)
        return struct.pack("BBB", 0xA3, 0x95, self.fmt.type) + struct.pack(self.fmt.msg_struct, *values)
298522
def bytes(self):
        """"""
        flagByte = 0x00
        messageType = 0
        if self._messageType is not None:
            messageType = self._messageType << 5
        extendedBit = 0 if self._extended is None else self._extended << 4
        hopsMax = 0 if self._hopsMax is None else self._hopsMax
        hopsLeft = 0 if self._hopsLeft is None else (self._hopsLeft << 2)
        flagByte = flagByte | messageType | extendedBit | hopsLeft | hopsMax
        return bytes([flagByte])
734169
public java.lang.String getGroup() {
    java.lang.Object ref = group_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      if (bs.isValidUtf8()) {
        group_ = s;
      }
      return s;
    }
  }
1259152
def get_bgp_config(self, group="", neighbor=""):
        

        bgp_config = {}

        def build_prefix_limit(af_table, limit, prefix_percent, prefix_timeout):
            prefix_limit = {}
            inet = False
            inet6 = False
            preifx_type = "inet"
            if isinstance(af_table, list):
                af_table = str(af_table)
            if "ipv4" in af_table.lower():
                inet = True
            if "ipv6" in af_table.lower():
                inet6 = True
                preifx_type = "inet6"
            if len(af_table.split()) == 2:
                safi = "unicast"
            else:
                safi = af_table.split()[-1]
            if inet or inet6:
                prefix_limit = {
                    preifx_type: {
                        safi: {
                            "limit": limit,
                            "teardown": {
                                "threshold": prefix_percent,
                                "timeout": prefix_timeout,
                            },
                        }
                    }
                }
            return prefix_limit

        # Get BGP config using ciscoconfparse because some old devices dont support "| sec bgp"
        cfg = self.get_config(retrieve="running")
        cfg = cfg["running"].splitlines()
        bgp_config_text = napalm.base.helpers.cisco_conf_parse_objects(
            "router bgp", cfg
        )
        bgp_asn = napalm.base.helpers.regex_find_txt(
            r"router bgp (\d+)", bgp_config_text, default=0
        )
        # Get a list of all neighbors and groups in the config
        all_neighbors = set()
        all_groups = set()
        bgp_group_neighbors = {}
        all_groups.add("_")
        for line in bgp_config_text:
            if " neighbor " in line:
                if re.search(IP_ADDR_REGEX, line) is not None:
                    all_neighbors.add(re.search(IP_ADDR_REGEX, line).group())
                elif re.search(IPV6_ADDR_REGEX_2, line) is not None:
                    all_neighbors.add(re.search(IPV6_ADDR_REGEX_2, line).group())
                else:
                    bgp_group = re.search(r" neighbor [^\s]+", line).group()
                    bgp_group = bgp_group.split()[1]
                    all_groups.add(bgp_group)

        # Get the neighrbor level config for each neighbor
        for bgp_neighbor in all_neighbors:
            # If neighbor_filter is passed in, only continue for that neighbor
            if neighbor:
                if bgp_neighbor != neighbor:
                    continue
            afi_list = napalm.base.helpers.cisco_conf_parse_parents(
                r"\s+address-family.*", bgp_neighbor, bgp_config_text
            )
            afi = afi_list[0]
            # Skipping neighbors in VRFs for now
            if "vrf" in str(afi_list):
                continue
            else:
                neighbor_config = napalm.base.helpers.cisco_conf_parse_objects(
                    bgp_neighbor, bgp_config_text
                )
            # For group_name- use peer-group name, else VRF name, else "_" for no group
            group_name = napalm.base.helpers.regex_find_txt(
                " peer-group ([^']+)", neighbor_config, default="_"
            )
            # Start finding attributes for the neighbor config
            description = napalm.base.helpers.regex_find_txt(
                r" description ([^\']+)\'", neighbor_config
            )
            peer_as = napalm.base.helpers.regex_find_txt(
                r" remote-as (\d+)", neighbor_config, default=0
            )
            prefix_limit = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix (\d+) \d+ \w+ \d+", neighbor_config, default=0
            )
            prefix_percent = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ (\d+) \w+ \d+", neighbor_config, default=0
            )
            prefix_timeout = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ \d+ \w+ (\d+)", neighbor_config, default=0
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            password = napalm.base.helpers.regex_find_txt(
                r"password (?:[0-9] )?([^\']+\')", neighbor_config
            )
            nhs = bool(
                napalm.base.helpers.regex_find_txt(r" next-hop-self", neighbor_config)
            )
            route_reflector_client = bool(
                napalm.base.helpers.regex_find_txt(
                    r"route-reflector-client", neighbor_config
                )
            )

            # Add the group name to bgp_group_neighbors if its not there already
            if group_name not in bgp_group_neighbors.keys():
                bgp_group_neighbors[group_name] = {}

            # Build the neighbor dict of attributes
            bgp_group_neighbors[group_name][bgp_neighbor] = {
                "description": description,
                "remote_as": peer_as,
                "prefix_limit": build_prefix_limit(
                    afi, prefix_limit, prefix_percent, prefix_timeout
                ),
                "export_policy": export_policy,
                "import_policy": import_policy,
                "local_address": local_address,
                "local_as": local_as,
                "authentication_key": password,
                "nhs": nhs,
                "route_reflector_client": route_reflector_client,
            }

        # Get the peer-group level config for each group
        for group_name in bgp_group_neighbors.keys():
            # If a group is passed in params, only continue on that group
            if group:
                if group_name != group:
                    continue
            # Default no group
            if group_name == "_":
                bgp_config["_"] = {
                    "apply_groups": [],
                    "description": "",
                    "local_as": 0,
                    "type": "",
                    "import_policy": "",
                    "export_policy": "",
                    "local_address": "",
                    "multipath": False,
                    "multihop_ttl": 0,
                    "remote_as": 0,
                    "remove_private_as": False,
                    "prefix_limit": {},
                    "neighbors": bgp_group_neighbors.get("_", {}),
                }
                continue
            neighbor_config = napalm.base.helpers.cisco_conf_parse_objects(
                group_name, bgp_config_text
            )
            multipath = False
            afi_list = napalm.base.helpers.cisco_conf_parse_parents(
                r"\s+address-family.*", group_name, neighbor_config
            )
            for afi in afi_list:
                afi_config = napalm.base.helpers.cisco_conf_parse_objects(
                    afi, bgp_config_text
                )
                multipath = bool(
                    napalm.base.helpers.regex_find_txt(r" multipath", str(afi_config))
                )
                if multipath:
                    break
            description = napalm.base.helpers.regex_find_txt(
                r" description ([^\']+)\'", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            multihop_ttl = napalm.base.helpers.regex_find_txt(
                r"ebgp-multihop {\d+}", neighbor_config, default=0
            )
            peer_as = napalm.base.helpers.regex_find_txt(
                r" remote-as (\d+)", neighbor_config, default=0
            )
            remove_private_as = bool(
                napalm.base.helpers.regex_find_txt(
                    r"remove-private-as", neighbor_config
                )
            )
            prefix_limit = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix (\d+) \d+ \w+ \d+", neighbor_config, default=0
            )
            prefix_percent = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ (\d+) \w+ \d+", neighbor_config, default=0
            )
            prefix_timeout = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ \d+ \w+ (\d+)", neighbor_config, default=0
            )
            bgp_type = "external"
            if local_as:
                if local_as == peer_as:
                    bgp_type = "internal"
            elif bgp_asn == peer_as:
                bgp_type = "internal"

            bgp_config[group_name] = {
                "apply_groups": [],  # on IOS will always be empty list!
                "description": description,
                "local_as": local_as,
                "type": bgp_type,
                "import_policy": import_policy,
                "export_policy": export_policy,
                "local_address": local_address,
                "multipath": multipath,
                "multihop_ttl": multihop_ttl,
                "remote_as": peer_as,
                "remove_private_as": remove_private_as,
                "prefix_limit": build_prefix_limit(
                    afi, prefix_limit, prefix_percent, prefix_timeout
                ),
                "neighbors": bgp_group_neighbors.get(group_name, {}),
            }
        return bgp_config
534560
public byte[] generateGossipHello() {
		if (cachedHelloMessage != null) {
			return cachedHelloMessage;
		}
		try {
			FastBuildTree root = new FastBuildTree(4);
			root.putUnsafe("ver", ServiceBroker.PROTOCOL_VERSION);
			root.putUnsafe("sender", nodeID);
			if (useHostname) {
				root.putUnsafe("host", getHostName());
			} else {
				root.putUnsafe("host", InetAddress.getLocalHost().getHostAddress());
			}
			root.putUnsafe("port", reader.getCurrentPort());
			cachedHelloMessage = serialize(PACKET_GOSSIP_HELLO_ID, root);
		} catch (Exception error) {
			throw new MoleculerError("Unable to create HELLO message!", error, "MoleculerError", "unknown", false, 500,
					"UNABLE_TO_CREATE_HELLO");
		}
		return cachedHelloMessage;
	}
1208082
def convertReadAlignment(self, read, readGroupSet, readGroupId):
        
        samFile = self.getFileHandle(self._dataUrl)
        # TODO fill out remaining fields
        # TODO refine in tandem with code in converters module
        ret = protocol.ReadAlignment()
        # ret.fragmentId = 'TODO'
        ret.aligned_quality.extend(read.query_qualities)
        ret.aligned_sequence = read.query_sequence
        if SamFlags.isFlagSet(read.flag, SamFlags.READ_UNMAPPED):
            ret.ClearField("alignment")
        else:
            ret.alignment.CopyFrom(protocol.LinearAlignment())
            ret.alignment.mapping_quality = read.mapping_quality
            ret.alignment.position.CopyFrom(protocol.Position())
            ret.alignment.position.reference_name = samFile.getrname(
                read.reference_id)
            ret.alignment.position.position = read.reference_start
            ret.alignment.position.strand = protocol.POS_STRAND
            if SamFlags.isFlagSet(read.flag, SamFlags.READ_REVERSE_STRAND):
                ret.alignment.position.strand = protocol.NEG_STRAND
            for operation, length in read.cigar:
                gaCigarUnit = ret.alignment.cigar.add()
                gaCigarUnit.operation = SamCigar.int2ga(operation)
                gaCigarUnit.operation_length = length
                gaCigarUnit.reference_sequence = ""  # TODO fix this!
        ret.duplicate_fragment = SamFlags.isFlagSet(
            read.flag, SamFlags.DUPLICATE_READ)
        ret.failed_vendor_quality_checks = SamFlags.isFlagSet(
            read.flag, SamFlags.FAILED_QUALITY_CHECK)
        ret.fragment_length = read.template_length
        ret.fragment_name = read.query_name
        for key, value in read.tags:
            # Useful for inspecting the structure of read tags
            # print("{key} {ktype}: {value}, {vtype}".format(
            #     key=key, ktype=type(key), value=value, vtype=type(value)))
            protocol.setAttribute(ret.attributes.attr[key].values, value)

        if SamFlags.isFlagSet(read.flag, SamFlags.MATE_UNMAPPED):
            ret.next_mate_position.Clear()
        else:
            ret.next_mate_position.Clear()
            if read.next_reference_id != -1:
                ret.next_mate_position.reference_name = samFile.getrname(
                    read.next_reference_id)
            else:
                ret.next_mate_position.reference_name = ""
            ret.next_mate_position.position = read.next_reference_start
            ret.next_mate_position.strand = protocol.POS_STRAND
            if SamFlags.isFlagSet(read.flag, SamFlags.MATE_REVERSE_STRAND):
                ret.next_mate_position.strand = protocol.NEG_STRAND
        if SamFlags.isFlagSet(read.flag, SamFlags.READ_PAIRED):
            ret.number_reads = 2
        else:
            ret.number_reads = 1
        ret.read_number = -1
        if SamFlags.isFlagSet(read.flag, SamFlags.FIRST_IN_PAIR):
            if SamFlags.isFlagSet(read.flag, SamFlags.SECOND_IN_PAIR):
                ret.read_number = 2
            else:
                ret.read_number = 0
        elif SamFlags.isFlagSet(read.flag, SamFlags.SECOND_IN_PAIR):
            ret.read_number = 1
        ret.improper_placement = not SamFlags.isFlagSet(
            read.flag, SamFlags.READ_PROPER_PAIR)
        ret.read_group_id = readGroupId
        ret.secondary_alignment = SamFlags.isFlagSet(
            read.flag, SamFlags.SECONDARY_ALIGNMENT)
        ret.supplementary_alignment = SamFlags.isFlagSet(
            read.flag, SamFlags.SUPPLEMENTARY_ALIGNMENT)
        ret.id = readGroupSet.getReadAlignmentId(ret)
        return ret
212278
def get_gaf_format(self):
        
        sep = '\t'
        return sep.join(
            [self.gene, self.db_ref, self.term.id, self.evidence,
             '|'.join(self.db_ref), '|'.join(self.with_)])
288683
def from_bytes(OverwinterTx, byte_string):
        '''
        
        '''
        header = byte_string[0:4]
        group_id = byte_string[4:8]

        if header != b'\x03\x00\x00\x80' or group_id != b'\x70\x82\xc4\x03':
            raise ValueError(
                'Bad header or group ID. Expected {} and {}. Got: {} and {}'
                .format(b'\x03\x00\x00\x80'.hex(),
                        b'\x70\x82\xc4\x03'.hex(),
                        header.hex(),
                        group_id.hex()))

        tx_ins = []
        tx_ins_num = shared.VarInt.from_bytes(byte_string[8:])

        current = 8 + len(tx_ins_num)
        for _ in range(tx_ins_num.number):
            tx_in = TxIn.from_bytes(byte_string[current:])
            current += len(tx_in)
            tx_ins.append(tx_in)

        tx_outs = []
        tx_outs_num = shared.VarInt.from_bytes(byte_string[current:])

        current += len(tx_outs_num)
        for _ in range(tx_outs_num.number):
            tx_out = TxOut.from_bytes(byte_string[current:])
            current += len(tx_out)
            tx_outs.append(tx_out)

        lock_time = byte_string[current:current + 4]
        current += 4
        expiry_height = byte_string[current:current + 4]
        current += 4

        if current == len(byte_string):
            # No joinsplits
            tx_joinsplits = tuple()
            joinsplit_pubkey = None
            joinsplit_sig = None
        else:
            tx_joinsplits = []
            tx_joinsplits_num = shared.VarInt.from_bytes(byte_string[current:])
            current += len(tx_outs_num)
            for _ in range(tx_joinsplits_num.number):
                tx_joinsplit = z.SproutJoinsplit.from_bytes(
                    byte_string[current:])
                current += len(tx_joinsplit)
                tx_joinsplits.append(tx_joinsplit)

            joinsplit_pubkey = byte_string[current:current + 32]
            current += 32
            joinsplit_sig = byte_string[current:current + 64]

        return OverwinterTx(
            tx_ins=tx_ins,
            tx_outs=tx_outs,
            lock_time=lock_time,
            expiry_height=expiry_height,
            tx_joinsplits=tx_joinsplits,
            joinsplit_pubkey=joinsplit_pubkey,
            joinsplit_sig=joinsplit_sig)