Search in sources :

Example 26 with Probe

use of uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe 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 27 with Probe

use of uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe 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 28 with Probe

use of uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe 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)

Example 29 with Probe

use of uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe in project SeqMonk by s-andrews.

the class ShuffleListProbeGenerator method run.

/* (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
public void run() {
    Vector<Probe> newProbes = new Vector<Probe>();
    String description = collection.probeSet().description() + " then shuffled " + selectedList.name() + " into random positions.";
    if (keepChromosomalDistributionBox.isSelected()) {
        description += " Chromosomal distribution was maintained.";
    }
    if (limitEndsBox.isSelected()) {
        description += " Positions were constrained within the limits of the existing probeset.";
    }
    Probe[] probes = selectedList.getAllProbes();
    long totalGenomeLength = collection.genome().getTotalGenomeLength();
    // If we're constraining within the limits of the probes then
    // we need to work out where the ends are.
    HashMap<Chromosome, int[]> chromosomeLimits = new HashMap<Chromosome, int[]>();
    Chromosome[] chromosomes = collection.genome().getAllChromosomes();
    for (int c = 0; c < chromosomes.length; c++) {
        Probe[] thisChrProbes = selectedList.getProbesForChromosome(chromosomes[c]);
        for (int p = 0; p < thisChrProbes.length; p++) {
            if (!chromosomeLimits.containsKey(chromosomes[c])) {
                chromosomeLimits.put(chromosomes[c], new int[] { probes[p].start(), probes[p].end() });
                continue;
            }
            if (thisChrProbes[p].start() < chromosomeLimits.get(chromosomes[c])[0]) {
                if (probes[p].start() < 0) {
                    System.err.println("Probe " + thisChrProbes[p].name() + " started at " + thisChrProbes[p].start());
                }
                chromosomeLimits.get(chromosomes[c])[0] = thisChrProbes[p].start();
            }
            if (thisChrProbes[p].end() > chromosomeLimits.get(chromosomes[c])[1]) {
                if (thisChrProbes[p].end() > chromosomes[c].length()) {
                    System.err.println("Probe " + thisChrProbes[p].name() + " ended at " + thisChrProbes[p].end() + " which is beyond " + chromosomes[c].length() + " for chr " + chromosomes[c].name());
                }
                chromosomeLimits.get(chromosomes[c])[1] = thisChrProbes[p].end();
            }
        }
    }
    if (limitEndsBox.isSelected()) {
        totalGenomeLength = 0;
        for (int c = 0; c < chromosomes.length; c++) {
            if (chromosomeLimits.containsKey(chromosomes[c])) {
                int length = (chromosomeLimits.get(chromosomes[c])[1] - chromosomeLimits.get(chromosomes[c])[0]) + 1;
                // System.err.println("Length of "+chromosomes[c].name()+" is "+length+" from "+chromosomeLimits.get(chromosomes[c])[1]+" and "+chromosomeLimits.get(chromosomes[c])[0]+" compared to "+chromosomes[c].length());
                totalGenomeLength += length;
            }
        }
    } else {
        for (int c = 0; c < chromosomes.length; c++) {
            chromosomeLimits.put(chromosomes[c], new int[] { 1, chromosomes[c].length() });
        }
    }
    for (int p = 0; p < probes.length; p++) {
        // See if we need to quit
        if (cancel) {
            generationCancelled();
            return;
        }
        if (p % 10000 == 0) {
            // Time for an update
            updateGenerationProgress("Processed " + p + " probes", p, probes.length);
        }
        Chromosome chromosomeToUse = probes[p].chromosome();
        if (!keepChromosomalDistributionBox.isSelected()) {
            chromosomeToUse = selectRandomChromosome(totalGenomeLength, chromosomeLimits, probes[p].length());
        }
        // Now we need to select a random position within that chromosome.  We need it to start within
        // the range of viable positions.
        int validStart = chromosomeLimits.get(chromosomeToUse)[0];
        int validEnd = chromosomeLimits.get(chromosomeToUse)[1] - probes[p].length();
        int actualStart = validStart + (int) (Math.random() * (validEnd - validStart));
        int actualEnd = actualStart + (probes[p].length() - 1);
        // We leave probes of unknown strand as unknown, but we randomly shuffle known ones
        int strand = Location.UNKNOWN;
        if (probes[p].strand() != Location.UNKNOWN) {
            if (Math.random() >= 0.5) {
                strand = Location.FORWARD;
            } else {
                strand = Location.REVERSE;
            }
        }
        newProbes.add(new Probe(chromosomeToUse, actualStart, actualEnd, strand, probes[p].name()));
    }
    Probe[] finalList = newProbes.toArray(new Probe[0]);
    ProbeSet finalSet = new ProbeSet(description, finalList);
    generationComplete(finalSet);
}
Also used : ProbeSet(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeSet) HashMap(java.util.HashMap) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) Vector(java.util.Vector)

Example 30 with Probe

use of uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe in project SeqMonk by s-andrews.

the class FeaturePercentileProbeGenerator method run.

/* (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
public void run() {
    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);
        Feature[] features = collection.genome().annotationCollection().getFeaturesForType(chromosomes[c], featureType);
        for (int f = 0; f < features.length; f++) {
            // See if we need to quit
            if (cancel) {
                generationCancelled();
                return;
            }
            if (useSubfeatures && (features[f].location() instanceof SplitLocation)) {
                SplitLocation location = (SplitLocation) features[f].location();
                Location[] subLocations = location.subLocations();
                for (int s = 0; s < subLocations.length; s++) {
                    makeProbes(features[f], chromosomes[c], subLocations[s], newProbes);
                }
            } else {
                makeProbes(features[f], chromosomes[c], features[f].location(), newProbes);
            }
        }
    }
    Probe[] finalList = newProbes.toArray(new Probe[0]);
    ProbeSet finalSet = new ProbeSet(getDescription(), finalList);
    generationComplete(finalSet);
}
Also used : Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) Feature(uk.ac.babraham.SeqMonk.DataTypes.Genome.Feature) ProbeSet(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeSet) SplitLocation(uk.ac.babraham.SeqMonk.DataTypes.Genome.SplitLocation) Vector(java.util.Vector) Location(uk.ac.babraham.SeqMonk.DataTypes.Genome.Location) SplitLocation(uk.ac.babraham.SeqMonk.DataTypes.Genome.SplitLocation)

Aggregations

Probe (uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe)125 ProbeList (uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList)54 SeqMonkException (uk.ac.babraham.SeqMonk.SeqMonkException)52 Vector (java.util.Vector)48 Chromosome (uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome)47 ProbeSet (uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeSet)26 DataStore (uk.ac.babraham.SeqMonk.DataTypes.DataStore)21 Feature (uk.ac.babraham.SeqMonk.DataTypes.Genome.Feature)20 HashSet (java.util.HashSet)9 Location (uk.ac.babraham.SeqMonk.DataTypes.Genome.Location)9 File (java.io.File)8 PrintWriter (java.io.PrintWriter)8 ProbeTTestValue (uk.ac.babraham.SeqMonk.Analysis.Statistics.ProbeTTestValue)8 SplitLocation (uk.ac.babraham.SeqMonk.DataTypes.Genome.SplitLocation)7 HiCDataStore (uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore)7 BufferedReader (java.io.BufferedReader)6 FileReader (java.io.FileReader)6 Hashtable (java.util.Hashtable)6 DataSet (uk.ac.babraham.SeqMonk.DataTypes.DataSet)6 HiCHitCollection (uk.ac.babraham.SeqMonk.DataTypes.Sequence.HiCHitCollection)6