note: lots of test to support scruffy provenance
770600
public HadMember doAction(HadMember o) {
        List<QualifiedName> qq=new LinkedList<QualifiedName>();
        if (o.getEntity()!=null) {
            for (QualifiedName eid:o.getEntity()) {
                qq.add(eid);
            }
        }
        return c.newHadMember(o.getCollection(), qq);
        
       /*remember, scruffy hadmember in provn, has a null in get(0)!!
	return deprecated.convertHadMember(deprecated.doAction((o.getCollection()==null) ? null: 	                                    
	                                      o.getCollection().getRef()),
	                          ((o.getEntity()==null || (o.getEntity().isEmpty())) ?
	                        	  deprecated.doAction(null) :
	                        	  deprecated.doAction((o.getEntity().get(0)==null) ? 
	                        		     null :
	                        	             o.getEntity().get(0).getRef()))); */
    }
149985
function(meshGeom, vertAssoc, nucleotideAssoc, opts, 
                               traceIndex, chain) {
  var traces = chain.backboneTraces();
  var numVerts = _cartoonNumVerts(traces, opts.arcDetail * 4,
                                  opts.splineDetail);
  var numIndices = _cartoonNumIndices(traces, opts.arcDetail * 4,
                                      opts.splineDetail);
  // figure out which of the traces consist of nucleic acids. They require 
  // additional space for rendering the sticks.
  var nucleicAcidTraces = [];
  var vertForBaseSticks = opts.protoCyl.numVerts() + 
    2 * opts.protoSphere.numVerts();
  var indicesForBaseSticks = opts.protoCyl.numIndices() + 
    2 * opts.protoSphere.numIndices();
  for (var i = 0; i < traces.length; ++i) {
    var trace = traces[i];
    if (trace.residueAt(0).isNucleotide()) {
      nucleicAcidTraces.push(trace);
      // each DNA/RNA base gets a double-capped cylinder
      numVerts += trace.length() * vertForBaseSticks;
      numIndices += trace.length() * indicesForBaseSticks;
    }
  }
  meshGeom.addChainVertArray(chain, numVerts, numIndices);
  for (var ti = 0; ti < traces.length; ++ti) {
    traceIndex = _cartoonForSingleTrace(meshGeom, vertAssoc, traces[ti], 
                                        traceIndex, opts);
  }
  _addNucleotideSticks(meshGeom, nucleotideAssoc, nucleicAcidTraces, opts);
  return traceIndex;
}
559801
void markSeenAsFalse(FastQueue<ChessboardCorner> corners0 , FastQueue<ChessboardCorner> corners1 ) {
		nn.setPoints(corners1.toList(),false);
		// radius of the blob in the intensity image is 2*kernelRadius
		int radius = detector.shiRadius *2+1;
		for (int i = 0; i < corners0.size; i++) {
			ChessboardCorner c0 = corners0.get(i);
			nnSearch.findNearest(c0,radius,5,nnResults);
			// TODO does it ever find multiple matches?

			// Could make this smarter by looking at the orientation too
			for (int j = 0; j < nnResults.size; j++) {
				ChessboardCorner c1 = nnResults.get(j).point;

				// if the current one wasn't first then none of its children can be first
				if( !c0.first ) {
					c1.first = false;
				} else if( c1.intensity < c0.intensity ) {
					// keeping the one with the best intensity score seems to help. Formally test this idea
					c1.first = false;
				} else {
					c0.first = false;
				}
			}
		}
	}
1176706
def _from_jd_schematic(jd, method):
    ''''''
    if jd < EPOCH:
        raise ValueError("Can't convert days before the French Revolution")

    # days since Epoch
    J = trunc(jd) + 0.5 - EPOCH

    y0, y1, y2, y3, y4, y5 = 0, 0, 0, 0, 0, 0
    intercal_cycle_days = leap_suppression_days = over_cycle_days = None

    # Use the every-four-years method below year 17
    if (J <= DAYS_IN_YEAR * 12 + 3 and
            method in (100, 'romme')) or (J <= DAYS_IN_YEAR * 17 + 4 and method in (128, 'madler')):
        method = 4

    # set p and r in Hatcher algorithm
    if method in (4, 'continuous'):
        # Leap years: 15, 19, 23, ...
        # Reorganize so that leap day is last day of cycle
        J = J + 365
        y5 = - 1

    elif method in (100, 'romme'):
        # Year 15 is not a leap year
        # Year 16 is leap, then multiples of 4, not multiples of 100, yes multiples of 400
        y5 = 12
        J = J - DAYS_IN_YEAR * 12 - 3

        leap_suppression_yrs = 100.
        leap_suppression_days = 36524  # LEAP_CYCLE_DAYS * 25 - 1

        intercal_cycle_yrs = 400.
        intercal_cycle_days = 146097  # leap_suppression_days * 4 + 1

        over_cycle_yrs = 4000.
        over_cycle_days = 1460969  # intercal_cycle_days * 10 - 1

    elif method in (128, 'madler'):
        # Year 15 is a leap year, then year 20 and multiples of 4, not multiples of 128
        y5 = 16
        J = J - DAYS_IN_YEAR * 16 - 4

        leap_suppression_yrs = 128
        leap_suppression_days = 46751  # 32 * leap_cycle_days - 1

    else:
        raise ValueError("Unknown leap year method. Try: continuous, romme, madler or equinox")

    if over_cycle_days:
        y0 = trunc(J / over_cycle_days) * over_cycle_yrs
        J = J % over_cycle_days

    if intercal_cycle_days:
        y1 = trunc(J / intercal_cycle_days) * intercal_cycle_yrs
        J = J % intercal_cycle_days

    if leap_suppression_days:
        y2 = trunc(J / leap_suppression_days) * leap_suppression_yrs
        J = J % leap_suppression_days

    y3 = trunc(J / LEAP_CYCLE_DAYS) * LEAP_CYCLE_YEARS

    if J % LEAP_CYCLE_DAYS == LEAP_CYCLE_DAYS - 1:
        J = 1460
    else:
        J = J % LEAP_CYCLE_DAYS

    # 0 <= J <= 1460
    # J needs to be 365 here on leap days ONLY

    y4 = trunc(J / DAYS_IN_YEAR)

    if J == DAYS_IN_YEAR * 4:
        y4 = y4 - 1
        J = 365.0
    else:
        J = J % DAYS_IN_YEAR

    year = y0 + y1 + y2 + y3 + y4 + y5

    month = trunc(J / 30.)
    J = J - month * 30

    return year + 1, month + 1, trunc(J) + 1
940601
function ECSignature (r, s) {
  typeforce(types.tuple(types.BigInt, types.BigInt), arguments)

  /** @type {BigInteger} */ this.r = r
  /** @type {BigInteger} */ this.s = s
}
387030
private void CheckCIELab(IfdTags metadata, int n) {
    // BitsPerSample
    if (!metadata.containsTagId(TiffTags.getTagId("BitsPerSample"))) {
      validation.addErrorLoc("Missing BitsPerSample", "IFD" + n);
    } else {
      for (abstractTiffType vi : metadata.get(TiffTags.getTagId("BitsPerSample")).getValue()) {
        if (vi.toInt() != 8) {
          validation.addError("Invalid BitsPerSample", "IFD" + n, vi.toInt());
          break;
        }
      }
    }
  }
956157
def assessOligo(seq):
    '''
    

    '''
    hairpin_out = calcHairpin(seq)
    homodimer_out = calcHomodimer(seq)
    return (hairpin_out, homodimer_out)
559790
def _ancestry_line(self):
        '''
        
        '''
        b = self._get_backers()

        while len(b) == 1:
            yield b[0]
            if not hasattr(b[0], '_get_backers'):
                break
            b = b[0]._get_backers()
583827
def verify(dataset, publication_date, source, refernce_url):
    """"""

    config = ApiConfig()
    client = ApiClient(config.host, config.app_id, config.app_secret)
    client.check_correct_host()
    client.verify(dataset, publication_date, source, refernce_url)
895599
def _refine_j(seq, species):
        '''
        
        '''
        jgerm = germlines.get_germline(seq['j_gene']['full'], species)
        aln = global_alignment(seq['vdj_nt'], jgerm)
        append = ''
        for s, g in zip(aln.aligned_query[::-1], aln.aligned_target[::-1]):
            if s != '-':
                break
            else:
                append += g
        seq['vdj_nt'] = seq['vdj_nt'] + append[::-1]
656027
def _check_dna(self, dna):
        
        valid_chars = set(self.GENETIC_MATERIAL_OPTIONS)
        assert all(char in valid_chars for char in dna)
676385
def estimateHeritabilities(self, K, verbose=False):
        
        
        # Fit single trait model
        varg  = SP.zeros(self.P)
        varn  = SP.zeros(self.P)
        fixed = SP.zeros((1,self.P))
        
        for p in range(self.P):
            y = self.Y[:,p:p+1]
            lmm = limix.CLMM()
            lmm.setK(K)
            lmm.setSNPs(SP.ones((K.shape[0],1)))
            lmm.setPheno(y)
            lmm.setCovs(SP.zeros((K.shape[0],1)))
            lmm.setVarcompApprox0(-20, 20, 1000)
            lmm.process()
            delta = SP.exp(lmm.getLdelta0()[0,0])
            Vtot  = SP.exp(lmm.getLSigma()[0,0])
    
            varg[p] = Vtot
            varn[p] = delta*Vtot
            fixed[:,p] = lmm.getBetaSNP()
    
            if verbose: print(p)
    
        sth = {}
        sth['varg']  = varg
        sth['varn']  = varn
        sth['fixed'] = fixed

        return sth
1236314
def _check(sample, data):
    """"""
    if dd.get_chip_method(sample).lower() == "atac":
        return [sample]
    if dd.get_phenotype(sample) == "input":
        return None
    for origin in data:
        if dd.get_batch(sample) in (dd.get_batches(origin[0]) or []) and dd.get_phenotype(origin[0]) == "input":
            sample["work_bam_input"] = origin[0].get("work_bam")
            return [sample]
    return [sample]
1185722
private String footprint(Test test) {
		StringBuilder sb = new StringBuilder();
		
		sb
			.append(test.getCategory())
			.append(test.getName())
			.append(test.getFlags());
		
		for (String tag : test.getTags()) {
			sb.append(tag);
		}
		
		for (String ticket : test.getTickets()) {
			sb.append(ticket);
		}
		
		for (Map.Entry<String, String> entry : test.getData().entrySet()) {
			sb.append(entry.getKey()).append(entry.getValue());
		}
	
		return FootprintGenerator.footprint(sb.toString());
	}
372161
public boolean groupIdAndArtifactMatches(String ivyNotationAsString) {
		String[] parts = ivyNotationFrom(ivyNotationAsString);
		String groupId = parts[0];
		String artifactId = parts[1];
		if (groupId == null) {
			return this.artifactId.equals(artifactId);
		}
		return this.groupId.equals(groupId) && this.artifactId.equals(artifactId);
	}
293581
private String getDataSource(Set<Provenance> provenances)
	{
		if(provenances.isEmpty()) return "N/A";
		
		Set<String> dsNames = new TreeSet<String>();
		for (Provenance provenance : provenances)
		{
			String name = provenance.getDisplayName();
			if(name == null) 
				name = provenance.getStandardName();
			if(name == null && !provenance.getName().isEmpty()) 
				name = provenance.getName().iterator().next();
			if (name != null && name.length() > 0)
				dsNames.add(name.toLowerCase());
		}
		
		return StringUtils.join(dsNames, ";");
	}
382111
def _has_bcftools_germline_stats(data):
    
    stats_file = tz.get_in(["summary", "qc"], data)
    if isinstance(stats_file, dict):
        stats_file = tz.get_in(["variants", "base"], stats_file)
    if not stats_file:
        stats_file = ""
    return stats_file.find("bcftools_stats_germline") > 0