Search in sources :

Example 46 with Conversion

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;
}
Also used : Node(beast.evolution.tree.Node) ArrayList(java.util.ArrayList) Conversion(bacter.Conversion)

Example 47 with Conversion

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;
}
Also used : Locus(bacter.Locus) Conversion(bacter.Conversion)

Example 48 with Conversion

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;
}
Also used : Locus(bacter.Locus) Conversion(bacter.Conversion)

Example 49 with Conversion

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;
}
Also used : Conversion(bacter.Conversion)

Aggregations

Conversion (bacter.Conversion)49 Locus (bacter.Locus)27 Node (beast.evolution.tree.Node)24 ConversionGraph (bacter.ConversionGraph)7 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 RealParameter (beast.core.parameter.RealParameter)4 SiteModel (beast.evolution.sitemodel.SiteModel)4 JukesCantor (beast.evolution.substitutionmodel.JukesCantor)4 TaxonSet (beast.evolution.alignment.TaxonSet)3 ConstantPopulation (beast.evolution.tree.coalescent.ConstantPopulation)3 ClusterTree (beast.util.ClusterTree)3 PrintStream (java.io.PrintStream)3 SimulatedACG (bacter.model.SimulatedACG)2 CFEventList (bacter.CFEventList)1 ACGCoalescent (bacter.model.ACGCoalescent)1 ACGLogReader (bacter.util.ACGLogReader)1 BacterACGLogReader (bacter.util.BacterACGLogReader)1 COACGLogFileReader (bacter.util.COACGLogFileReader)1 State (beast.core.State)1