use of bacter.Conversion in project bacter by tgvaughan.
the class ConvertedEdgeHopContemp method proposal.
@Override
public double proposal() {
if (acg.getTotalConvCount() == 0)
return Double.NEGATIVE_INFINITY;
// Select recombination at random
Conversion conv = chooseConversion();
// Choose whether to move departure or arrival point
boolean moveDeparture = conv.getNode2().isRoot() || Randomizer.nextBoolean();
double pointHeight = moveDeparture ? conv.getHeight1() : conv.getHeight2();
Node convNode = moveDeparture ? conv.getNode1() : conv.getNode2();
// Find list of CF edges alive at pointHeight
List<Node> intersectingEdges = new ArrayList<>();
for (Node node : acg.getNodesAsArray()) {
if (node.isRoot() || node == convNode || node.getHeight() > pointHeight || node.getParent().getHeight() < pointHeight) {
continue;
}
intersectingEdges.add(node);
}
if (intersectingEdges.isEmpty())
return Double.NEGATIVE_INFINITY;
// Select new attachment point:
if (moveDeparture)
conv.setNode1(intersectingEdges.get(Randomizer.nextInt(intersectingEdges.size())));
else
conv.setNode2(intersectingEdges.get(Randomizer.nextInt(intersectingEdges.size())));
return 0.0;
}
use of bacter.Conversion in project bacter by tgvaughan.
the class ConversionGraphStatsLogger method getMeanDepartureHeight.
/**
* Obtain mean height of point of departure of converted edges
* in ACG.
*
* @param acg
* @return mean height, or NaN if ACG has no converted edges
*/
public static double getMeanDepartureHeight(ConversionGraph acg) {
if (acg.getTotalConvCount() < 1)
return Double.NaN;
double mean = 0.0;
for (Locus locus : acg.getLoci()) {
for (Conversion conv : acg.getConversions(locus)) {
mean += conv.getHeight1();
}
}
mean /= acg.getTotalConvCount();
return mean;
}
use of bacter.Conversion in project bacter by tgvaughan.
the class ConversionGraphStatsLogger method getMeanEdgeLength.
/**
* Obtain mean length of converted edges in ACG.
*
* @param acg
* @return mean length, or NaN if ACG has no converted edges
*/
public static double getMeanEdgeLength(ConversionGraph acg) {
if (acg.getTotalConvCount() < 1)
return Double.NaN;
double mean = 0.0;
for (Locus locus : acg.getLoci()) {
for (Conversion conv : acg.getConversions(locus)) mean += conv.getHeight2() - conv.getHeight1();
}
mean /= acg.getTotalConvCount();
return mean;
}
use of bacter.Conversion in project bacter by tgvaughan.
the class ConversionGraphStatsLogger method getMeanEndSite.
/**
* Obtain average position of conversion ends.
*
* @param acg
* @param locus
* @return average site index or NaN if no conversions in ACG.
*/
public static double getMeanEndSite(ConversionGraph acg, Locus locus) {
if (acg.getConvCount(locus) < 1)
return Double.NaN;
double mean = 0.0;
for (Conversion conv : acg.getConversions(locus)) mean += conv.getEndSite();
mean /= acg.getConvCount(locus);
return mean;
}
Aggregations