Count the total unique coverage junction for junctions in a set of
    SJ.out.tab files.
960517
def _total_jxn_counts(fns):
    """"""
    df = pd.read_table(fns[0], header=None, names=COLUMN_NAMES)
    df.index = (df.chrom + ':' + df.start.astype(int).astype(str) + '-' +
                df.end.astype(int).astype(str))
    counts = df.unique_junction_reads
    for fn in fns[1:]:
        df = pd.read_table(fn, header=None, names=COLUMN_NAMES)
        df.index = (df.chrom + ':' + df.start.astype(int).astype(str) + '-' +
                    df.end.astype(int).astype(str))
        counts = counts.add(df.unique_junction_reads, fill_value=0)
    return counts
1157197
static protected int countSharedNeighbors(DBIDs neighbors1, DBIDs neighbors2) {
    int intersection = 0;
    DBIDIter iter1 = neighbors1.iter();
    DBIDIter iter2 = neighbors2.iter();
    while(iter1.valid() && iter2.valid()) {
      final int comp = DBIDUtil.compare(iter1, iter2);
      if(comp == 0) {
        intersection++;
        iter1.advance();
        iter2.advance();
      }
      else if(comp < 0) {
        iter1.advance();
      }
      else // iter2 < iter1
      {
        iter2.advance();
      }
    }
    return intersection;
  }
1085850
def total_align_count(bam_filepath):
    ''''''
    count = 0
    for line in idxstats(bam_filepath):
        if line:
            chrom, _, mapped, unmapped = line.strip().split('\t')
            if chrom != '*':
                count += int(mapped) + int(unmapped)
    return count
118029
public int countOccupiedMapSlots() {
    int mapSlotsCount = 0;
    for (Iterator<TaskStatus> it = taskReports.iterator(); it.hasNext();) {
      TaskStatus ts = (TaskStatus) it.next();
      if (ts.getIsMap() && isTaskRunning(ts)) {
        mapSlotsCount += ts.getNumSlots();
      }
    }
    return mapSlotsCount;
  }
118538
public int countMapTasks() {
    int mapCount = 0;
    for (Iterator<TaskStatus> it = taskReports.iterator(); it.hasNext();) {
      TaskStatus ts = (TaskStatus) it.next();
      if (ts.getIsMap() && isTaskRunning(ts)) {
        mapCount++;
      }
    }
    return mapCount;
  }
319271
def componentCount(self):
        
        return sum([self.columnCountForRow(x) for x in range(self.rowCount())])
1282511
def _run_collect_allelic_counts(pos_file, pos_name, work_dir, data):
    
    out_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data), "structural", "counts"))
    out_file = os.path.join(out_dir, "%s-%s-counts.tsv" % (dd.get_sample_name(data), pos_name))
    if not utils.file_exists(out_file):
        with file_transaction(data, out_file) as tx_out_file:
            params = ["-T", "CollectAllelicCounts", "-L", pos_file, "-I", dd.get_align_bam(data),
                      "-R", dd.get_ref_file(data), "-O", tx_out_file]
            _run_with_memory_scaling(params, tx_out_file, data)
    return out_file
1309593
def _offsetscounts(self):
        """"""
        if self.is_contiguous:
            offset, bytecount = self.is_contiguous
            return [offset], [bytecount]
        if self.is_tiled:
            return self.dataoffsets, self.databytecounts
        return clean_offsetscounts(self.dataoffsets, self.databytecounts)
735429
def total_coverage
      unless @project.nil?
        @total_coverage ||= begin
          total_project_lines = 0
          total_project_lines_tested = 0
          @project.coverage_files.each do |coverage_file|
            total_project_lines_tested += coverage_file.num_lines_tested
            total_project_lines += coverage_file.num_lines_testable
          end
          @total_coverage = (total_project_lines_tested / total_project_lines.to_f) * 100.0
        end
      end
    end
226771
def common_segment_count(path, value):
    """"""
    i = 0
    if len(path) <= len(value):
        for x1, x2 in zip(path, value):
            if x1 == x2:
                i += 1
            else:
                return 0
    return i
1147667
private int getDoubleBondedSulfurCount(IAtomContainer ac, IAtom atom) {
        List<IAtom> neighbours = ac.getConnectedAtomsList(atom);
        IBond bond;
        int sdbcounter = 0;
        for (IAtom neighbour : neighbours) {
            if (neighbour.getSymbol().equals("S")) {
                if (atom.getFormalCharge() == 1 && neighbour.getFormalCharge() == -1) {
                    sdbcounter += 1;
                }
                bond = ac.getBond(neighbour, atom);
                if (!neighbour.getFlag(CDKConstants.ISAROMATIC)) {
                    if (bond.getOrder() == IBond.Order.DOUBLE) {
                        sdbcounter += 1;
                    }
                }
            }
        }
        return sdbcounter;
    }
801292
def _indicator_multitraj(ss, i, j):
    
    iseqs = ss[i]
    res = []
    for iseq in iseqs:
        x = np.zeros(len(iseq))
        I = np.where(iseq == j)
        x[I] = 1.0
        res.append(x)
    return res
55851
def count_uniquelymapping_reads(self, file_name, paired_end):
        
        param = " -c -F256"
        if file_name.endswith("sam"):
            param += " -S"
        return self.samtools_view(file_name, param=param)
673922
def _get_nblock_regions(in_file, min_n_size, ref_regions):
    
    out_lines = []
    called_contigs = set([])
    with utils.open_gzipsafe(in_file) as in_handle:
        for line in in_handle:
            contig, start, end, ctype = line.rstrip().split()
            called_contigs.add(contig)
            if (ctype in ["REF_N", "NO_COVERAGE", "EXCESSIVE_COVERAGE", "LOW_COVERAGE"] and
                  int(end) - int(start) > min_n_size):
                out_lines.append("%s\t%s\t%s\n" % (contig, start, end))
    for refr in ref_regions:
        if refr.chrom not in called_contigs:
            out_lines.append("%s\t%s\t%s\n" % (refr.chrom, 0, refr.stop))
    return pybedtools.BedTool("\n".join(out_lines), from_string=True)
236944
private boolean checkEdgeCount( SquareGrid grid ) {

		int left = 0, right = grid.columns-1;
		int top = 0, bottom = grid.rows-1;

		for (int row = 0; row < grid.rows; row++) {
			boolean skip = grid.get(row,0) == null;

			for (int col = 0; col < grid.columns; col++) {
				SquareNode n = grid.get(row,col);
				if( skip ) {
					if ( n != null )
						return false;
				} else {
					boolean horizontalEdge =  col == left || col == right;
					boolean verticalEdge =  row == top || row == bottom;

					boolean outer = horizontalEdge || verticalEdge;
					int connections = n.getNumberOfConnections();

					if( outer ) {
						if( horizontalEdge && verticalEdge ) {
							if( connections != 1 )
								return false;
						} else if( connections != 2 )
							return false;
					} else {
						if( connections != 4 )
							return false;
					}
				}
				skip = !skip;
			}
		}
		return true;
	}
441157
def total_num_lines(self):
        

        return sum([len(summary.measured_lines) for summary
                    in self._diff_violations().values()])
936516
def junction2bed(junction_file):
    
    base, _ = os.path.splitext(junction_file)
    out_file = base + "-minimized.bed"
    if file_exists(out_file):
        return out_file
    if not file_exists(junction_file):
        return None
    with file_transaction(out_file) as tx_out_file:
        with open(junction_file) as in_handle:
            with open(tx_out_file, "w") as out_handle:
                 for line in in_handle:
                    tokens = line.split()
                    chrom, sj1, sj2 = tokens[0:3]
                    if int(sj1) > int(sj2):
                        tmp = sj1
                        sj1 = sj2
                        sj2 = tmp
                    out_handle.write("\t".join([chrom, sj1, sj1]) + "\n")
                    out_handle.write("\t".join([chrom, sj2, sj2]) + "\n")
        minimize = bed.minimize(tx_out_file)
        minimize.saveas(tx_out_file)
    return out_file