Search in sources :

Example 21 with Chromosome

use of uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome in project SeqMonk by s-andrews.

the class RandomProbeGenerator method designPerChromosome.

private ProbeSet designPerChromosome() {
    Chromosome[] chromosomes = collection.genome().getAllChromosomes();
    long[] offsets = new long[chromosomes.length];
    offsets[0] = chromosomes[0].length();
    for (int i = 1; i < chromosomes.length; i++) {
        offsets[i] = offsets[i - 1] + chromosomes[i].length();
    }
    // Now make up the probes
    Vector<Probe> newProbes = new Vector<Probe>();
    Random rand = new Random();
    while (newProbes.size() < numberToGenerate) {
        if (cancel) {
            return null;
        }
        if (newProbes.size() % 1000 == 0) {
            updateGenerationProgress("Designed " + newProbes.size() + " probes", newProbes.size(), numberToGenerate);
        }
        // Select a random position in the genome
        long random = (long) (collection.genome().getTotalGenomeLength() * rand.nextDouble());
        Chromosome chromosome = null;
        int start = 0;
        int end = 0;
        // Find out which chromosome this comes from
        for (int o = 0; o < offsets.length; o++) {
            if (random < offsets[o]) {
                chromosome = chromosomes[o];
                if (o > 0) {
                    start = (int) (random - offsets[o - 1]) + 1;
                } else {
                    start = (int) random + 1;
                }
                end = start + (windowSize - 1);
                break;
            }
        }
        if (end > chromosome.length()) {
            // Try again
            continue;
        }
        // Make a probe
        newProbes.add(new Probe(chromosome, start, end));
    }
    Probe[] finalList = newProbes.toArray(new Probe[0]);
    ProbeSet finalSet = new ProbeSet(getDescription(), finalList);
    return finalSet;
}
Also used : ProbeSet(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeSet) Random(java.util.Random) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) Vector(java.util.Vector)

Example 22 with Chromosome

use of uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome in project SeqMonk by s-andrews.

the class RandomProbeGenerator method designPerProbe.

private ProbeSet designPerProbe() {
    Probe[] probes = collection.probeSet().getActiveList().getAllProbes();
    // TODO: We could remove all probes which are smaller than the windows we're going to
    // generate?
    long[] offsets = new long[probes.length];
    offsets[0] = probes[0].length();
    for (int i = 1; i < probes.length; i++) {
        offsets[i] = offsets[i - 1] + probes[i].length();
    }
    long totalLength = offsets[offsets.length - 1];
    // Now make up the probes
    Vector<Probe> newProbes = new Vector<Probe>();
    Random rand = new Random();
    RANDLOOP: while (newProbes.size() < numberToGenerate) {
        if (cancel) {
            return null;
        }
        if (newProbes.size() % 1000 == 0) {
            updateGenerationProgress("Designed " + newProbes.size() + " probes", newProbes.size(), numberToGenerate);
        }
        // Select a random position in the genome
        long random = (long) (totalLength * rand.nextDouble());
        Chromosome chromosome = null;
        int start = 0;
        int end = 0;
        // Find out which chromosome this comes from
        for (int o = 0; o < offsets.length; o++) {
            if (random < offsets[o]) {
                chromosome = probes[o].chromosome();
                if (o > 0) {
                    start = (int) (random - offsets[o - 1]) + probes[o].start();
                } else {
                    start = (int) random + probes[o].start();
                }
                end = start + (windowSize - 1);
                // Check that this is valid
                if (end > probes[o].end()) {
                    // Try again
                    continue RANDLOOP;
                }
                break;
            }
        }
        // Make a probe
        newProbes.add(new Probe(chromosome, start, end));
    }
    Probe[] finalList = newProbes.toArray(new Probe[0]);
    ProbeSet finalSet = new ProbeSet(getDescription(), finalList);
    return finalSet;
}
Also used : ProbeSet(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeSet) Random(java.util.Random) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) Vector(java.util.Vector)

Example 23 with Chromosome

use of uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome in project SeqMonk by s-andrews.

the class RunningWindowProbeGenerator method designPerChromosome.

private ProbeSet designPerChromosome() {
    Chromosome[] chromosomes = collection.genome().getAllChromosomes();
    Vector<Probe> newProbes = new Vector<Probe>();
    for (int c = 0; c < chromosomes.length; c++) {
        // Time for an update
        updateGenerationProgress("Processed " + c + " chromosomes", c, chromosomes.length);
        int pos = 1;
        while (pos < chromosomes[c].length()) {
            // See if we need to quit
            if (cancel) {
                generationCancelled();
            }
            int end = pos + (probeSize - 1);
            if (end > chromosomes[c].length())
                end = chromosomes[c].length();
            Probe p = new Probe(chromosomes[c], pos, end);
            newProbes.add(p);
            pos += stepSize;
        }
    }
    Probe[] finalList = newProbes.toArray(new Probe[0]);
    ProbeSet finalSet = new ProbeSet(getDescription(), finalList);
    return finalSet;
}
Also used : ProbeSet(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeSet) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) Vector(java.util.Vector)

Example 24 with Chromosome

use of uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome in project SeqMonk by s-andrews.

the class RunningWindowProbeGenerator method designPerProbe.

private ProbeSet designPerProbe() {
    Chromosome[] chromosomes = collection.genome().getAllChromosomes();
    ProbeList activeList;
    if (limitRegionBox.getSelectedItem().equals("Active Probe List")) {
        activeList = collection.probeSet().getActiveList();
    } else {
        // We're just analysing a single probe over the current region
        existingListName = "Currently visible region";
        Probe p = new Probe(DisplayPreferences.getInstance().getCurrentChromosome(), DisplayPreferences.getInstance().getCurrentLocation());
        activeList = new ProbeSet("Current Region", 1);
        activeList.addProbe(p, 0f);
    }
    Vector<Probe> newProbes = new Vector<Probe>();
    for (int c = 0; c < chromosomes.length; c++) {
        // Time for an update
        updateGenerationProgress("Processed " + c + " chromosomes", c, chromosomes.length);
        Probe[] probes = activeList.getProbesForChromosome(chromosomes[c]);
        for (int p = 0; p < probes.length; p++) {
            int pos = probes[p].start();
            while (pos < probes[p].end() - (probeSize - 1)) {
                // See if we need to quit
                if (cancel) {
                    generationCancelled();
                }
                int end = pos + (probeSize - 1);
                if (end > chromosomes[c].length())
                    end = chromosomes[c].length();
                Probe pr = new Probe(chromosomes[c], pos, end, probes[p].strand());
                newProbes.add(pr);
                pos += stepSize;
            }
        }
    }
    Probe[] finalList = newProbes.toArray(new Probe[0]);
    ProbeSet finalSet = new ProbeSet(getDescription(), finalList);
    return finalSet;
}
Also used : ProbeSet(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeSet) ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) Vector(java.util.Vector)

Example 25 with Chromosome

use of uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome in project SeqMonk by s-andrews.

the class LogTransformQuantitation method run.

/* (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
public void run() {
    if (!isReady()) {
        progressExceptionReceived(new SeqMonkException("Options weren't set correctly"));
    }
    Chromosome[] chromosomes = application.dataCollection().genome().getAllChromosomes();
    Vector<DataStore> quantitatedStores = new Vector<DataStore>();
    DataSet[] sets = application.dataCollection().getAllDataSets();
    for (int s = 0; s < sets.length; s++) {
        if (sets[s].isQuantitated()) {
            quantitatedStores.add(sets[s]);
        }
    }
    DataGroup[] groups = application.dataCollection().getAllDataGroups();
    for (int g = 0; g < groups.length; g++) {
        if (groups[g].isQuantitated()) {
            quantitatedStores.add(groups[g]);
        }
    }
    DataStore[] data = quantitatedStores.toArray(new DataStore[0]);
    for (int c = 0; c < chromosomes.length; c++) {
        // See if we need to quit
        if (cancel) {
            progressCancelled();
            return;
        }
        progressUpdated(c, chromosomes.length);
        Probe[] allProbes = application.dataCollection().probeSet().getProbesForChromosome(chromosomes[c]);
        try {
            for (int p = 0; p < allProbes.length; p++) {
                // See if we need to quit
                if (cancel) {
                    progressCancelled();
                    return;
                }
                for (int d = 0; d < data.length; d++) {
                    data[d].setValueForProbe(allProbes[p], (float) (Math.log(Math.max(data[d].getValueForProbe(allProbes[p]), threshold)) / Math.log(logBase)));
                }
            }
        } catch (SeqMonkException e) {
            progressExceptionReceived(e);
        }
    }
    quantitatonComplete();
}
Also used : DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) DataStore(uk.ac.babraham.SeqMonk.DataTypes.DataStore) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException) Vector(java.util.Vector)

Aggregations

Chromosome (uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome)78 Probe (uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe)47 Vector (java.util.Vector)36 Feature (uk.ac.babraham.SeqMonk.DataTypes.Genome.Feature)23 SeqMonkException (uk.ac.babraham.SeqMonk.SeqMonkException)23 ProbeSet (uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeSet)22 ProbeList (uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList)12 DataStore (uk.ac.babraham.SeqMonk.DataTypes.DataStore)11 DataSet (uk.ac.babraham.SeqMonk.DataTypes.DataSet)8 ReadsWithCounts (uk.ac.babraham.SeqMonk.DataTypes.Sequence.ReadsWithCounts)8 Location (uk.ac.babraham.SeqMonk.DataTypes.Genome.Location)7 SplitLocation (uk.ac.babraham.SeqMonk.DataTypes.Genome.SplitLocation)7 ProgressListener (uk.ac.babraham.SeqMonk.DataTypes.ProgressListener)7 HiCHitCollection (uk.ac.babraham.SeqMonk.DataTypes.Sequence.HiCHitCollection)7 IOException (java.io.IOException)6 File (java.io.File)5 Hashtable (java.util.Hashtable)5 HiCDataStore (uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore)5 QuantitationStrandType (uk.ac.babraham.SeqMonk.DataTypes.Sequence.QuantitationStrandType)5 PairedDataSet (uk.ac.babraham.SeqMonk.DataTypes.PairedDataSet)4