Divide out the transcripts.  allow junction tolerance if wanted
357778
def parse(self,tolerance=0,downsample=None,evidence=2,use_gene_names=False):
      """"""
      g = Graph()
      nodes = [Node(x) for x in self._transcripts]
      for n in nodes: g.add_node(n)
      for i in range(0,len(nodes)):
         for j in range(0,len(nodes)):
            if i == j: continue
            jov = nodes[i].payload.junction_overlap(nodes[j].payload,tolerance)
            sub = jov.is_subset()
            if not sub: continue
            if sub == 1:
               g.add_edge(Edge(nodes[i],nodes[j]))
               g.add_edge(Edge(nodes[j],nodes[i]))
            if sub == 2:
               g.add_edge(Edge(nodes[i],nodes[j]))
      g.merge_cycles()
      roots = g.roots
      groups = []
      for r in roots:
         g2 = g.get_root_graph(r)
         c = CompatibleGraph(g2,tolerance,downsample,evidence,use_gene_names=use_gene_names)
         groups.append(c)
      return groups
717764
function compressRun() {
    if (runLen > 1 && offset) {
      let ri = bi - runLen;
      diff[ri] = [offset, runLen];
      for (ri++; ri < bi; ri++) {
        delete diff[ri];
      }
    }
  }
902575
function splitUpParagraph(segment, resultStr, stack, tokens, tokenIndex) {
	let startOfWord = resultStr.indexOf(stack[0].complete) + 1;
	let textBeforeSelected = resultStr.slice(0, startOfWord);
	let startToken = tokens[2][tokenIndex];
	let selected = resultStr.slice(startOfWord + segment.length - 1, resultStr.indexOf(segment));
	let endToken = tokens[3][tokenIndex];
	let textAfterSelected = resultStr.slice(resultStr.indexOf(segment) + segment.length - 1);
	return textBeforeSelected + startToken + selected + endToken + textAfterSelected;
}
1228095
void assignExclusiveSegments(List<MemorySegment> segments) {
		checkState(this.initialCredit == 0, "Bug in input channel setup logic: exclusive buffers have " +
			"already been set for this input channel.");

		checkNotNull(segments);
		checkArgument(segments.size() > 0, "The number of exclusive buffers per channel should be larger than 0.");

		this.initialCredit = segments.size();
		this.numRequiredBuffers = segments.size();

		synchronized (bufferQueue) {
			for (MemorySegment segment : segments) {
				bufferQueue.addExclusiveBuffer(new NetworkBuffer(segment, this), numRequiredBuffers);
			}
		}
	}
861782
def split_input(cls, mapper_spec):
    """"""
    filelists = mapper_spec.params[cls.FILES_PARAM]
    max_values_count = mapper_spec.params.get(cls.MAX_VALUES_COUNT_PARAM, -1)
    max_values_size = mapper_spec.params.get(cls.MAX_VALUES_SIZE_PARAM, -1)
    return [cls([0] * len(files), max_values_count, max_values_size)
            for files in filelists]
326473
def _fix_mutect_output(orig_file, config, out_file, is_paired):
    
    out_file_noc = out_file.replace(".vcf.gz", ".vcf")
    none_index = -1
    with file_transaction(config, out_file_noc) as tx_out_file:
        with open_gzipsafe(orig_file) as in_handle:
            with open(tx_out_file, 'w') as out_handle:
                for line in in_handle:
                    if not is_paired and line.startswith("#CHROM"):
                        parts = line.rstrip().split("\t")
                        none_index = parts.index("none")
                        del parts[none_index]
                        line = "\t".join(parts) + "\n"
                    elif line.startswith("##FORMAT=<ID=FA"):
                        line = line.replace("=FA", "=FREQ")
                    elif not line.startswith("#"):
                        if none_index > 0:
                            parts = line.rstrip().split("\t")
                            del parts[none_index]
                            line = "\t".join(parts) + "\n"
                        line = line.replace("FA", "FREQ")
                    out_handle.write(line)
    return bgzip_and_index(out_file_noc, config)
333838
function splitStr2Obj(source) {
    var result = {};
    each(
        source.split(','),
        function (key) {
            result[key] = key;
        }
    );
    return result;
}
1204061
@Transformer
    public static String[] divide(Object o, String sep) {
        return str(o).split(sep);
    }
665967
def cut_into_parts(self):
        # pylint: disable=too-many-branches, too-many-locals, too-many-statements
        
        # User must have set a spare if he needed one
        logger.info("Splitting the configuration into parts:")
        nb_parts = 0
        for realm in self.realms:
            no_spare_schedulers = realm.schedulers
            if not no_spare_schedulers:
                if realm.potential_schedulers:
                    no_spare_schedulers = [realm.potential_schedulers[0]]
            nb_schedulers = len(no_spare_schedulers)
            nb_parts += nb_schedulers
            if nb_schedulers:
                logger.info("  %d scheduler(s) for the realm %s", nb_schedulers, realm.get_name())
            else:
                logger.warning("  no scheduler for the realm %s", realm.get_name())

        if nb_parts == 0:
            nb_parts = 1

        # We create dummy configurations for schedulers:
        # they are clone of the master configuration but without hosts and
        # services (because they are splitted between these configurations)
        logger.info("Splitting the configuration into %d parts...", nb_parts)
        self.parts = {}
        for part_index in range(0, nb_parts):
            self.parts[part_index] = Config()

            # Now we copy all properties of conf into the new ones
            for prop, entry in sorted(list(Config.properties.items())):
                # Do not copy the configuration instance id nor name!
                if prop in ['instance_id', 'config_name']:
                    continue
                # Only the one that are managed and used
                if entry.managed and not isinstance(entry, UnusedProp):
                    val = getattr(self, prop, None)
                    setattr(self.parts[part_index], prop, val)

            # Set the cloned configuration name
            self.parts[part_index].config_name = "%s (%d)" % (self.config_name, part_index)
            logger.debug("- cloning configuration: %s -> %s",
                         self.parts[part_index].config_name, self.parts[part_index])

            # Copy the configuration objects lists. We need a deepcopy because each configuration
            # will have some new groups... but we create a new uuid
            self.parts[part_index].uuid = get_a_new_object_id()

            types_creations = self.__class__.types_creations
            for o_type in types_creations:
                (_, clss, inner_property, _, clonable) = types_creations[o_type]
                if not clonable:
                    logger.debug("  . do not clone: %s", inner_property)
                    continue
                # todo: Indeed contactgroups should be managed like hostgroups...
                if inner_property in ['hostgroups', 'servicegroups']:
                    new_groups = []
                    for group in getattr(self, inner_property):
                        new_groups.append(group.copy_shell())
                    setattr(self.parts[part_index], inner_property, clss(new_groups))
                elif inner_property in ['hosts', 'services']:
                    setattr(self.parts[part_index], inner_property, clss([]))
                else:
                    setattr(self.parts[part_index], inner_property, getattr(self, inner_property))
                logger.debug("  . cloned %s: %s -> %s", inner_property,
                             getattr(self, inner_property),
                             getattr(self.parts[part_index], inner_property))

            # The elements of the others conf will be tag here
            self.parts[part_index].other_elements = {}

            # No scheduler has yet accepted the configuration
            self.parts[part_index].is_assigned = False
            self.parts[part_index].scheduler_link = None
            self.parts[part_index].push_flavor = ''
        # Once parts got created, the current configuration has some 'parts'
        # self.parts is the configuration split into parts for the schedulers

        # Just create packs. There can be numerous ones
        # In pack we've got hosts and service and packs are in the realms
        logger.debug("Creating packs for realms...")
        self.create_packs()
        # Once packs got created, all the realms have some 'packs'

        logger.info("Realms:")
        for realm in self.realms:
            logger.info(" - realm: %s", realm)
            for idx in realm.packs:
                logger.info("   - pack: %s / %d hosts (%s)",
                            idx, len(realm.packs[idx]), ','.join([self.hosts[host_id].get_name()
                                                                  for host_id in realm.packs[idx]]))

        # We have packs for realms and elements into configurations, let's merge this...
        logger.info("Realms:")
        offset = 0
        for realm in self.realms:
            logger.info(" Realm: %s", realm)
            for idx in realm.packs:
                logger.info(" - pack: %s / %d hosts", idx, len(realm.packs[idx]))
                if not realm.packs[idx]:
                    logger.info(" - no hosts are declared in this realm pack.")
                    # continue
                try:
                    instance_id = self.parts[idx + offset].instance_id
                    for host_id in realm.packs[idx]:
                        host = self.hosts[host_id]
                        self.parts[idx + offset].hosts.add_item(host)
                        for service_id in host.services:
                            service = self.services[service_id]
                            self.parts[idx + offset].services.add_item(service)
                    # Now the conf can be linked with the realm
                    realm.parts.update({instance_id: self.parts[idx + offset]})
                    # offset += 1
                except KeyError:
                    logger.info(" - no configuration part is affected "
                                "because of mismatching hosts packs / schedulers count. "
                                "Probably too much schedulers for the hosts count!")

            offset += len(realm.packs)
            del realm.packs

        # We've nearly have hosts and services. Now we want real hosts (Class)
        # And we want groups too
        for part_index in self.parts:
            cfg = self.parts[part_index]

            # Fill host groups
            for ori_hg in self.hostgroups:
                hostgroup = cfg.hostgroups.find_by_name(ori_hg.get_name())
                mbrs_id = []
                for host in ori_hg.members:
                    if host != '':
                        mbrs_id.append(host)
                for host in cfg.hosts:
                    if host.uuid in mbrs_id:
                        hostgroup.members.append(host.uuid)

            # And also relink the hosts with the valid hostgroups
            for host in cfg.hosts:
                orig_hgs = host.hostgroups
                nhgs = []
                for ohg_id in orig_hgs:
                    ohg = self.hostgroups[ohg_id]
                    nhg = cfg.hostgroups.find_by_name(ohg.get_name())
                    nhgs.append(nhg.uuid)
                host.hostgroups = nhgs

            # Fill servicegroup
            for ori_sg in self.servicegroups:
                servicegroup = cfg.servicegroups.find_by_name(ori_sg.get_name())
                mbrs = ori_sg.members
                mbrs_id = []
                for service in mbrs:
                    if service != '':
                        mbrs_id.append(service)
                for service in cfg.services:
                    if service.uuid in mbrs_id:
                        servicegroup.members.append(service.uuid)

            # And also relink the services with the valid servicegroups
            for host in cfg.services:
                orig_hgs = host.servicegroups
                nhgs = []
                for ohg_id in orig_hgs:
                    ohg = self.servicegroups[ohg_id]
                    nhg = cfg.servicegroups.find_by_name(ohg.get_name())
                    nhgs.append(nhg.uuid)
                host.servicegroups = nhgs

        # Now we fill other_elements by host (service are with their host
        # so they are not tagged)
        logger.info("Configuration parts:")
        for part_index in self.parts:
            for host in self.parts[part_index].hosts:
                for j in [j for j in self.parts if j != part_index]:  # So other than i
                    self.parts[part_index].other_elements[host.get_name()] = part_index
            logger.info("- part: %d - %s, %d hosts", part_index, self.parts[part_index],
                        len(self.parts[part_index].hosts))
1029527
private static MultiLineString splitLineWithPoint(LineString line, Point pointToSplit, double tolerance) {
        return FACTORY.createMultiLineString(splitLineStringWithPoint(line, pointToSplit, tolerance));
    }
873093
function concat(divider, sourcePath, relativePaths, done) {
  var writeDivider = false;
  each(relativePaths, function(relativePath, next) {
    var absoluteSourcePath = path.resolve(sourcePath, relativePath);
    var readStream = fs.createReadStream(absoluteSourcePath);
    if (writeDivider) process.stdout.write(divider);
    writeDivider = true;
    readStream.on('close', next).on('error', next).pipe(process.stdout);
  }, done);
}
955050
def remove_transcript(self,tx_id):
    
    txs = self.get_transcripts()
    if tx_id not in [x.id for x in txs]:
      return
    tx = [x for x in txs if x.id==tx_id][0]
    for n in [x for x in self.g.get_nodes()]:
      if tx_id not in [y.id for y in n.payload]:
        continue
      n.payload.remove(tx)
      if len(n.payload)==0:
        self.g.remove_node(n)
761609
def split_input(self, input_filepath):
        """"""
        with open(input_filepath, 'r') as input_file:
            input_file_str = input_file.read()
            merge_file_str, parsetree_str = input_file_str.split('ParentedTree', 1)
            return merge_file_str, 'ParentedTree' + parsetree_str
646759
def batch_message_from_parts(cls, messages):
        '''
        '''
        # Comma-separate the messages and wrap the lot in square brackets
        middle = b', '.join(messages)
        if not middle:
            raise ProtocolError.empty_batch()
        return b''.join([b'[', middle, b']'])
672325
def split(self, text):
        """"""
        text = cleanup(text)
        return self.sent_detector.tokenize(text.strip())
240289
def split_impute_jobs(args, filename):
    
    max_snp_count = args.snps_per_job

    if args.impute_count:
        impute_count = args.impute_count
    else:
        impute_count = 1

    ExitIf("mvmany doesn't support splitting IMPUTE jobs into pieces at this time", max_snp_count > 1)

    job_list = {}
    gen_files = []
    for line in open(filename):
        gen_files.append(".".join(line.strip().split()[-1].split("/")[-1].split(".")[0:-1]))


    file_count = len(gen_files)
    job_count = int(math.ceil(float(file_count) / impute_count))

    for job_num in range(job_count):
        job_idx = job_num * impute_count + 1
        job_string = "--impute-offset %d --impute-count %d" % (job_idx, impute_count)
        job_name = "job%04d-%s" % (job_num+1, gen_files[job_idx -1])
        job_list[job_name] = job_string
        print job_string

    return job_list

    # For now, let's not deal with the complexity of splitting chromosomes in IMPUTE
    poscol = 2
    cur = None
    last_pos = None
    job_string = ""
    job_name = ""

    file_index = 0
    for line in open(filename):
        chr, genfile = line.strip().split()

        if max_snp_count > 0:
            locus_index = 0
            last_pos = 1
            for locus in open(genfile):
                if locus_index >= max_snp_count - 1:
                    rsid, pos = locus.split()[1:2]
                    job_name = "chr%d_%d" % (chr, last_pos)
                    job_string = "--chr %s --from-bp %d --to-bp %d" % (chr, last_pos, pos)
                    last_pos = pos + 1
                    job_list[job_name] = job_string
                    locus_index = 0

                if cur is None:
                    cur = pos

    for line in sys_call("cut -f 1,%d %s" % (poscol, chrom_file)):
        chrom, pos = [int(x) for x in line.split()]
        if cur is None:     # First line observed
            cur = chrom
            job_string = "--chr %d --from-bp %d" % (chrom, pos)
            job_name = "Chr%d_%d-" % (chrom, pos)
            snp_count = 0
        elif cur != cur:    # Changed chromosome
            job_string += " --to-bp %d" % (last_pos)
            job_name += str(last_pos)
            job_list[job_name] = job_string
            cur = chrom
            job_string = "--chr %d --from-bp %d" % (chrom, pos)
            job_name = "Chr%d_%d-" % (chrom, pos)
            snp_count = 0
                            # create new job based on snp count
        elif snp_count < max_snp_count:
            snp_count += 1
        else:
            job_string += " --to-bp %d" % (last_pos)
            job_name += str(last_pos)
            job_list[job_name] = job_string
            job_string = "--chr %d --from-bp" % (chrom, pos)
            job_name = "Chr%d_%d-" % (chrom, pos)
            snp_count = 0

        last_pos = pos
    if job_string != "":
        job_string += " --to-bp %d" % (last_pos)
        job_name += str(last_pos)
        job_list[job_name] = job_string

    return job_list
1184710
def _emplace_transcript(transcripts, parent):
    """"""
    transcripts.sort(key=lambda t: (len(t), t.get_attribute('ID')))
    pt = transcripts.pop()
    parent.children = [pt]