//TEMPLATE FUNCTION DepthFromMaxValue template<class Type> inline int RealAllowableLeastDepth(ImageDisplay::Matrix<Type>& matrix) { ImageDisplay::Matrix<Type>::iterator it = std::max_element(matrix.begin(), matrix.end()); double MaxValue = (double)(*it); Enforce(MaxValue>0, "Matrix data is empty or all negative"); int bit = ceil(log(MaxValue+1)/log(2.0));//plus 1 means: for value 1024 depth should be 11 return bit; }
std::vector<Doublet> Higgs::Doublets(boca::Event const& event, std::function<boost::optional<Doublet>(Doublet&)> const& function) const { INFO0; auto jets = event.Jets(); auto jet_range = MomentumRange{Id::higgs, Id::higgs}; auto doublets = UnorderedPairs(jet_range.SofterThanMax(jets), [&](boca::Jet const & jet_1, boca::Jet const & jet_2) { auto doublet = Doublet{jet_1, jet_2}; if (!jet_range.BelowUpperBound(doublet)) throw boca::Problematic(); if (auto optional = function(doublet)) return *optional; throw boca::Problematic(); }); for (auto const & jet : jet_range.HarderThanMin(jets)) { auto doublet = Doublet{}; doublet.Enforce(jet); if (auto optional = function(doublet)) doublets.emplace_back(*optional); } return doublets; }
void MerlinParameters::Read(int argc, char ** argv, int start) { ParameterList::Read(argc, argv, start); globalRandom.Reset(random_seed); // The number of analysis steps between markers must be positive if (FamilyAnalysis::steps_per_interval < 0) FamilyAnalysis::steps_per_interval = 0; // Memory usage limit should be positive if (maxMegabytes < 0) maxMegabytes = 0; // The bit limit for analysis should be positive if (FamilyAnalysis::maxBits < 0) FamilyAnalysis::maxBits = 0; // The number of sampled haplotypes should be positive if (FamilyAnalysis::sampledHaplotypes < 0) FamilyAnalysis::sampledHaplotypes = 0; // Clustering distance must be positive if (clusterDistance < 0.0) clusterDistance = _NAN_; // Clustering r-squared must be between 0 and 1 if (clusterRsquared < 0.0) clusterRsquared = 0.0; if (clusterRsquared > 1.0) clusterRsquared = 1.0; // Limited range of options available with error modelling if (FuzzyInheritanceTree::perAlleleError != 0.0 || FuzzyInheritanceTree::perGenotypeError != 0.0 || fitErrorRate) { char * reason = "The --%s option is disabled when error modeling is enabled"; Enforce(clusterDistance, _NAN_, reason, "distance"); Enforce(clusterRsquared, _NAN_, reason, "rsq"); Enforce(clusterFile, "", reason, "clusters"); } // Limited range of options in two-point mode if (FamilyAnalysis::twopoint) { char * reason = "The %s option is disabled during " "singlepoint analysis.\n"; // No between marker analyses Enforce(FamilyAnalysis::steps_per_interval, 0, reason, "--steps"); Enforce(FamilyAnalysis::minDistance, _NAN_, reason, "--minStep"); Enforce(FamilyAnalysis::maxDistance, _NAN_, reason, "--maxStep"); Enforce(FamilyAnalysis::grid, _NAN_, reason, "--grid"); // No error checking Enforce(FamilyAnalysis::findErrors, false, reason, "--flag"); // No haplotyping Enforce(FamilyAnalysis::bestHaplotype, false, reason, "--best"); Enforce(FamilyAnalysis::sampledHaplotypes, 0, reason, "--sample"); Enforce(FamilyAnalysis::allHaplotypes, false, reason, "--all"); // Positions along chromosome not meaningful Enforce(FamilyAnalysis::useMarkerNames, true, "The --markerNames option is automatically enabled during singlepoint analysis\n"); } // Limited range of options when using imaginary components for recombination fraction if (MerlinCore::imaginaryTheta < 0.0) MerlinCore::imaginaryTheta = 0.0; if (MerlinCore::imaginaryTheta > 0.0) { const char * reason = "The %s option is disabled when complex " "recombination fractions are in use\n"; // No error checking Enforce(FamilyAnalysis::findErrors, false, reason, "--flag"); // No haplotyping Enforce(FamilyAnalysis::bestHaplotype, false, reason, "--best"); Enforce(FamilyAnalysis::sampledHaplotypes, 0, reason, "--sample"); Enforce(FamilyAnalysis::allHaplotypes, false, reason, "--all"); } if (FamilyAnalysis::allHaplotypes) { char * reason = "The --%s option is disabled when listing all haplotypes\n"; Enforce(clusterDistance, _NAN_, reason, "distance"); Enforce(clusterRsquared, _NAN_, reason, "rsq"); Enforce(clusterFile, "", reason, "clusters"); } // Limited range of options when using simwalk2 if (FamilyAnalysis::simwalk2) { const char * reason = "The %s option is disabled when creating " "intermediate results for SimWalk2\n"; // No between marker analyses Enforce(FamilyAnalysis::steps_per_interval, 0, reason, "--steps"); Enforce(FamilyAnalysis::minDistance, _NAN_, reason, "--minStep"); Enforce(FamilyAnalysis::maxDistance, _NAN_, reason, "--maxStep"); Enforce(FamilyAnalysis::grid, _NAN_, reason, "--grid"); Enforce(FamilyAnalysis::start, _NAN_, reason, "--start"); Enforce(FamilyAnalysis::stop, _NAN_, reason, "--stop"); const char * reason2 = " %s option enabled when creating " "intermediate results for SimWalk2\n"; // Simwalk2 might want the marker names Enforce(FamilyAnalysis::useMarkerNames, true, reason2, "--markerNames"); if (KongAndCox::nplPairs) messages += "The --pairs option will ignore inbreeding " "to allow joint analysis with Simwalk2\n"; // Non-parametric statistics are required Enforce(KongAndCox::nplAll, true, reason2, "--npl"); Enforce(KongAndCox::nplPairs, true, reason2, "--pairs"); } // Checked that proportion of unlinked families is within range if (VarianceComponents::unlinkedFraction < 0.0 || VarianceComponents::unlinkedFraction >= 1.0) VarianceComponents::unlinkedFraction = 0.0; // Limited range of options zero recombination is assumed if (MerlinCore::zeroRecombination) { const char * reason = "The --%s option is incompatible with the --zero flag\n" "and will be disabled\n"; Enforce(associationAnalysis, false, reason, "--assoc options"); Enforce(FamilyAnalysis::findErrors, false, reason, "--flag / --error option"); } if (reruns > 1) Enforce(simulateNull, true, "The --reruns option automatically enables the --simulate option\n"); FamilyAnalysis::storeKinshipForVc = varianceComponents; FamilyAnalysis::storeKinshipForAssoc = associationAnalysis; // With the --infer parameter, we actively output all information if (FamilyAnalysis::inferGenotypes) GenotypeInference::inferBest = GenotypeInference::inferExpected = GenotypeInference::inferProbabilities = true; // With the specific options, we enable genotype inference but don't // touch the individual flags if (GenotypeInference::inferBest || GenotypeInference::inferExpected || GenotypeInference::inferProbabilities) FamilyAnalysis::inferGenotypes = true; // The infer genotypes flag controls inference, whereas the output // flag determines whether results get saved to disk if (FamilyAnalysis::inferGenotypes) FamilyAnalysis::outputInferredGenotypes = true; if (associationAnalysis || FamilyAnalysis::fastAssociationAnalysis) FamilyAnalysis::inferGenotypes = true; // Some basic calculations to convert megabyte memory usage // limit into maximum TreeNode count BasicTree::maxNodes = (1024 * 1024) / sizeof(TreeNode) * maxMegabytes; // If we are saving replicated data, then we should also // be simulating it! simulateNull |= saveReplicate; // The max bit parameters for processing haplotype clusters // should be the same as for other analyses FamilyHaplos::maxBits = MerlinCore::maxBits; }