Overlaps samples in 'midBuffer' with the samples in 'pInput'
760997
function(pInputPos) {
            var pInput = this._inputBuffer.vector;
            pInputPos += this._inputBuffer.startIndex;

            var pOutput = this._outputBuffer.vector,
                pOutputPos = this._outputBuffer.endIndex,
                i,
                cnt2,
                fTemp,
                fScale,
                fi,
                pInputOffset,
                pOutputOffset;

            fScale = 1 / this.overlapLength;
            for (i = 0; i < this.overlapLength; i++) {
                fTemp = (this.overlapLength - i) * fScale;
                fi = i * fScale;
                cnt2 = 2 * i;
                pInputOffset = cnt2 + pInputPos;
                pOutputOffset = cnt2 + pOutputPos;
                pOutput[pOutputOffset + 0] =
                    pInput[pInputOffset + 0] * fi +
                    this.pMidBuffer[cnt2 + 0] * fTemp;
                pOutput[pOutputOffset + 1] =
                    pInput[pInputOffset + 1] * fi +
                    this.pMidBuffer[cnt2 + 1] * fTemp;
            }
        }
915480
def _preallocate_samples(self):
        
        self.prealloc_samples_ = []
        for i in range(self.num_prealloc_samples_):
            self.prealloc_samples_.append(self.sample())
422978
def _overlapping_channels(self, wavelengths):
        

        sizes = self.meta["channel_sizes"]
        min_a, max_a = wavelengths.min(), wavelengths.max()

        matched_channel_names = []
        for i, (name, size) in enumerate(zip(self.channel_names, sizes)):
            si = sum(sizes[:i])
            min_b, max_b = self.wavelengths[[si, si + size - 1]]
            if max_a > min_b and min_a < max_b:
                matched_channel_names.append(name)

        return matched_channel_names
943352
function() {
            var i, cnt2, temp;

            for (i = 0; i < this.overlapLength; i++) {
                temp = i * (this.overlapLength - i);
                cnt2 = i * 2;
                this.pRefMidBuffer[cnt2] = this.pMidBuffer[cnt2] * temp;
                this.pRefMidBuffer[cnt2 + 1] = this.pMidBuffer[cnt2 + 1] * temp;
            }
        }
371880
def overlap(intv1, intv2):
    """"""
    return max(0, min(intv1[1], intv2[1]) - max(intv1[0], intv2[0]))
881313
function(data) {
    if (thisTables.options.stdin) {
      thisTables.guessBuffers.push(data);
    }

    bar.tick(data.length);
  }
390604
def overlapping_in_bed( fname, r_chr, r_start, r_stop ):
    
    rval = []
    for line in open( fname ):
        if line.startswith( "#" ) or line.startswith( "track" ):
            continue
        fields = line.split()
        chr, start, stop = fields[0], int( fields[1] ), int( fields[2] )
        if chr == r_chr and start < r_stop and stop >= r_start:
            rval.append( ( chr, max( start, r_start ), min( stop, r_stop ) ) )
    return rval
397896
def ad_unif_fix(samples, pinf):
    
    n = samples
    c = .01265 + .1757 / n
    if pinf < c:
        return (((.0037 / n + .00078) / n + .00006) / n) * g1(pinf / c)
    elif pinf < .8:
        return ((.01365 / n + .04213) / n) * g2((pinf - c) / (.8 - c))
    else:
        return g3(pinf) / n
1282530
def SampleStop(self):
    """"""
    if self._start_cpu_time is not None:
      self.total_cpu_time += time.clock() - self._start_cpu_time
217924
def merge_split_alignments(samples, run_parallel):
    
    ready = []
    file_key = "work_bam"
    to_merge = collections.defaultdict(list)
    for data in (xs[0] for xs in samples):
        if data.get("combine"):
            out_key = tz.get_in(["combine", file_key, "out"], data)
            if not out_key:
                out_key = data["rgnames"]["lane"]
            to_merge[out_key].append(data)
        else:
            ready.append([data])
    ready_merge = []
    hla_merges = []
    for mgroup in to_merge.values():
        cur_data = mgroup[0]
        del cur_data["align_split"]
        for x in mgroup[1:]:
            cur_data["combine"][file_key]["extras"].append(x[file_key])
        ready_merge.append([cur_data])
        cur_hla = None
        for d in mgroup:
            hla_files = tz.get_in(["hla", "fastq"], d)
            if hla_files:
                if not cur_hla:
                    cur_hla = {"rgnames": {"sample": dd.get_sample_name(cur_data)},
                               "config": cur_data["config"], "dirs": cur_data["dirs"],
                               "hla": {"fastq": []}}
                cur_hla["hla"]["fastq"].append(hla_files)
        if cur_hla:
            hla_merges.append([cur_hla])
    if not tz.get_in(["config", "algorithm", "kraken"], data):
        # kraken requires fasta filenames from data['files'] as input.
        # We don't want to remove those files if kraken qc is required.
        _save_fastq_space(samples)
    merged = run_parallel("delayed_bam_merge", ready_merge)
    hla_merge_raw = run_parallel("merge_split_alignments", hla_merges)
    hla_merges = {}
    for hla_merge in [x[0] for x in hla_merge_raw]:
        hla_merges[dd.get_sample_name(hla_merge)] = tz.get_in(["hla", "fastq"], hla_merge)

    # Add stable 'align_bam' target to use for retrieving raw alignment
    out = []
    for data in [x[0] for x in merged + ready]:
        if data.get("work_bam"):
            data["align_bam"] = data["work_bam"]
        if dd.get_sample_name(data) in hla_merges:
            data["hla"]["fastq"] = hla_merges[dd.get_sample_name(data)]
        else:
            hla_files = glob.glob(os.path.join(dd.get_work_dir(data), "align",
                                               dd.get_sample_name(data), "hla", "*.fq"))
            if hla_files:
                data["hla"]["fastq"] = hla_files
        out.append([data])
    return out
1325237
static TimingInterval merge(Iterable<TimingInterval> intervals, int maxSamples, long start)
    {
        ThreadLocalRandom rnd = ThreadLocalRandom.current();
        long operationCount = 0, partitionCount = 0, rowCount = 0, errorCount = 0;
        long maxLatency = 0, totalLatency = 0;
        List<SampleOfLongs> latencies = new ArrayList<>();
        long end = 0;
        long pauseStart = 0, pauseEnd = Long.MAX_VALUE;
        for (TimingInterval interval : intervals)
        {
            if (interval != null)
            {
                end = Math.max(end, interval.end);
                operationCount += interval.operationCount;
                maxLatency = Math.max(interval.maxLatency, maxLatency);
                totalLatency += interval.totalLatency;
                partitionCount += interval.partitionCount;
                rowCount += interval.rowCount;
                errorCount += interval.errorCount;
                latencies.addAll(Arrays.asList(interval.sample));
                if (interval.pauseLength > 0)
                {
                    pauseStart = Math.max(pauseStart, interval.pauseStart);
                    pauseEnd = Math.min(pauseEnd, interval.pauseStart + interval.pauseLength);
                }
            }
        }

        if (pauseEnd < pauseStart || pauseStart <= 0)
        {
            pauseEnd = pauseStart = 0;
        }

        return new TimingInterval(start, end, maxLatency, pauseStart, pauseEnd - pauseStart, partitionCount, rowCount,
                                  totalLatency, operationCount, errorCount, SampleOfLongs.merge(rnd, latencies, maxSamples));

    }
983643
def sample_dropout_mask(x, dropout_probability=.5, columns=None, stream=None, target=None,
                        dropout_mask=None, dropout_prob_array=None):
    

    assert x.flags.c_contiguous

    if columns is not None:
        assert len(columns) == 2
        x_tmp = x
        x = extract_columns(x, columns[0], columns[1])

    shape = x.shape

    if dropout_prob_array is None:
        dropout_prob_array = gpuarray.empty(shape, x.dtype, allocator=memory_pool.allocate)
    sampler.fill_uniform(dropout_prob_array, stream)

    if dropout_mask is None:
        dropout_mask = gpuarray.empty(shape, np.int8, allocator=memory_pool.allocate)

    if target is None: target = x
    
    all_kernels['sample_dropout_mask'](
        x, target, dropout_mask, dropout_prob_array,
        np.float32(dropout_probability))

    if columns is not None:
        insert_columns(x, x_tmp, columns[0])

    return dropout_mask
962417
def _remove_overlaps(in_file, out_dir, data):
    
    out_file = os.path.join(out_dir, "%s-nooverlaps%s" % utils.splitext_plus(os.path.basename(in_file)))
    if not utils.file_uptodate(out_file, in_file):
        with file_transaction(data, out_file) as tx_out_file:
            with open(in_file) as in_handle:
                with open(tx_out_file, "w") as out_handle:
                    prev_line = None
                    for line in in_handle:
                        if prev_line:
                            pchrom, pstart, pend = prev_line.split("\t", 4)[:3]
                            cchrom, cstart, cend = line.split("\t", 4)[:3]
                            # Skip if chromosomes match and end overlaps start
                            if pchrom == cchrom and int(pend) > int(cstart):
                                pass
                            else:
                                out_handle.write(prev_line)
                        prev_line = line
                    out_handle.write(prev_line)
    return out_file
219445
def _to_image_partial_overlap(self, image):
        

        # find the overlap of the mask on the output image shape
        slices_large, slices_small = self._overlap_slices(image.shape)

        if slices_small is None:
            return None    # no overlap

        # insert the mask into the output image
        image[slices_large] = self.data[slices_small]

        return image
258814
public static void down(GrayU8 input , int sampleWidth , GrayI8 output ) {
		if( sampleWidth == 2 ) {
			if(BoofConcurrency.USE_CONCURRENT ) {
				ImplAverageDownSample2_MT.down(input, output);
			} else {
				ImplAverageDownSample2.down(input, output);
			}
		} else {
			if(BoofConcurrency.USE_CONCURRENT ) {
				ImplAverageDownSampleN_MT.down(input, sampleWidth, output);
			} else {
				ImplAverageDownSampleN.down(input, sampleWidth, output);
			}
		}
	}
121838
def analyze_overs(self1):
      """"""
      #check for full overlap first
      self1.dif1 = [self1.overs[i][0]-self1.overs[i-1][0] for i in range(1,len(self1.overs))]
      self1.dif2 = [self1.overs[i][1]-self1.overs[i-1][1] for i in range(1,len(self1.overs))]
      #see if it starts and ends on first or last junction
      self1.start1 = self1.overs[0][0] == 0
      self1.start2 = self1.overs[0][1] == 0
      self1.end1 = self1.overs[-1][0] == len(self1.tx_obj1.exons)-1
      self1.end2 = self1.overs[-1][1] == len(self1.tx_obj2.exons)-1
      return
881969
def overlapbatch(args):
    
    p = OptionParser(overlap.__doc__)
    opts, args = p.parse_args(args)
    if len(args) != 2:
        sys.exit(not p.print_help())

    ctgfasta, poolfasta = args
    f = Fasta(ctgfasta)
    for k, rec in f.iteritems_ordered():
        fastafile = k + ".fasta"
        fw = open(fastafile, "w")
        SeqIO.write([rec], fw, "fasta")
        fw.close()

        overlap([fastafile, poolfasta])