Search in sources :

Example 1 with Chromosome

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

the class ReadLengthHistogramPlot method getReadLengths.

/**
 * Gets the read lengths.
 *
 * @param d the d
 * @return the read lengths
 */
private float[] getReadLengths(DataStore d) {
    float[] data = new float[d.getTotalReadCount()];
    int index = 0;
    Chromosome[] chrs = d.collection().genome().getAllChromosomes();
    for (int c = 0; c < chrs.length; c++) {
        ReadsWithCounts reads = d.getReadsForChromosome(chrs[c]);
        for (int r = 0; r < reads.reads.length; r++) {
            for (int ct = 0; ct < reads.counts[r]; ct++) {
                data[index] = SequenceRead.length(reads.reads[r]);
                ++index;
            }
        }
    }
    return data;
}
Also used : Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) ReadsWithCounts(uk.ac.babraham.SeqMonk.DataTypes.Sequence.ReadsWithCounts)

Example 2 with Chromosome

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

the class FeaturePositionSelectorPanel method getCoreProbes.

/**
 * Gets the set of locations for the core of each feature.  This wouldn't
 * include additional context added by the options, but would have subtracted
 * context removed by the options.
 *
 * @return
 */
public Probe[] getCoreProbes() {
    Chromosome[] chromosomes = collection.genome().getAllChromosomes();
    Vector<Probe> newProbes = new Vector<Probe>();
    for (int c = 0; c < chromosomes.length; c++) {
        Vector<Feature> allFeatures = new Vector<Feature>();
        String[] selectedFeatureTypes = selectedFeatureTypes();
        for (int f = 0; f < selectedFeatureTypes.length; f++) {
            Feature[] features = collection.genome().annotationCollection().getFeaturesForType(chromosomes[c], selectedFeatureTypes[f]);
            for (int i = 0; i < features.length; i++) {
                allFeatures.add(features[i]);
            }
        }
        Feature[] features = allFeatures.toArray(new Feature[0]);
        for (int f = 0; f < features.length; f++) {
            if (useSubFeatures()) {
                // We need to split this up so get the sub-features
                if (features[f].location() instanceof SplitLocation) {
                    SplitLocation location = (SplitLocation) features[f].location();
                    Location[] subLocations = location.subLocations();
                    if (useExonSubfeatures()) {
                        for (int s = 0; s < subLocations.length; s++) {
                            makeProbes(features[f], chromosomes[c], subLocations[s], newProbes, true);
                        }
                    } else {
                        // We're making introns
                        for (int s = 1; s < subLocations.length; s++) {
                            makeProbes(features[f], chromosomes[c], new Location(subLocations[s - 1].end() + 1, subLocations[s].start() - 1, features[f].location().strand()), newProbes, true);
                        }
                    }
                } else {
                    if (useExonSubfeatures()) {
                        // We can still make a single probe
                        makeProbes(features[f], chromosomes[c], features[f].location(), newProbes, true);
                    }
                // If we're making introns then we're stuffed and we give up.
                }
            } else {
                makeProbes(features[f], chromosomes[c], features[f].location(), newProbes, true);
            }
        }
    }
    Probe[] finalList = newProbes.toArray(new Probe[0]);
    if (removeDuplicates()) {
        finalList = removeDuplicates(finalList);
    }
    return finalList;
}
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) 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)

Example 3 with Chromosome

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

the class RNAQCPreferencesDialog method actionPerformed.

public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals("plot")) {
        String geneFeatures = (String) geneFeaturesBox.getSelectedItem();
        String transcriptFeatures = null;
        if (measureTranscriptsBox.isSelected()) {
            transcriptFeatures = (String) transcriptFeaturesBox.getSelectedItem();
        }
        String rRNAFeatures = null;
        if (measureRRNABox.isSelected()) {
            rRNAFeatures = (String) rRNAFeaturesBox.getSelectedItem();
        }
        Object[] selectedChromosomes = chromosomeList.getSelectedValues();
        Chromosome[] chromosomes = new Chromosome[selectedChromosomes.length];
        for (int c = 0; c < chromosomes.length; c++) {
            chromosomes[c] = (Chromosome) selectedChromosomes[c];
        }
        RNAQCCalcualtor calc = new RNAQCCalcualtor(collection, geneFeatures, transcriptFeatures, rRNAFeatures, chromosomes, stores);
        calc.addListener(this);
        calc.addListener(new ProgressDialog("RNA-Seq QC Plot", calc));
        calc.startCalculating();
        setVisible(false);
    }
}
Also used : Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) ProgressDialog(uk.ac.babraham.SeqMonk.Dialogs.ProgressDialog.ProgressDialog)

Example 4 with Chromosome

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

the class ReportTableDialog method mouseClicked.

/* (non-Javadoc)
	 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
	 */
public void mouseClicked(MouseEvent me) {
    // We're only interested in double clicks
    if (me.getClickCount() != 2)
        return;
    // This is only linked from the report JTable
    JTable t = (JTable) me.getSource();
    int r = t.getSelectedRow();
    Chromosome chr = null;
    int start = -1;
    int end = -1;
    for (int i = 0; i < model.getColumnCount(); i++) {
        if (model.getColumnName(i).equals("Chr") || model.getColumnName(i).equals("Chromosome")) {
            if (model.getValueAt(r, i) instanceof Chromosome) {
                chr = (Chromosome) model.getValueAt(r, i);
            } else if (model.getValueAt(r, i) instanceof String) {
                chr = application.dataCollection().genome().getChromosome((String) model.getValueAt(r, i)).chromosome();
            }
        } else if (model.getColumnName(i).equals("Start")) {
            start = ((Integer) model.getValueAt(r, i)).intValue();
        } else if (model.getColumnName(i).equals("End")) {
            end = ((Integer) model.getValueAt(r, i)).intValue();
        }
    }
    if (chr != null && start > 0 && end > 0) {
        DisplayPreferences.getInstance().setLocation(chr, SequenceRead.packPosition(start, end, Location.UNKNOWN));
    } else {
        System.err.println("Couldn't find a position to jump to.  Closest thing was " + chr + " " + start + "-" + end);
    }
}
Also used : JTable(javax.swing.JTable) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome)

Example 5 with Chromosome

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

the class SmallRNAQCCalcualtor method run.

public void run() {
    SmallRNAQCResult[] results = new SmallRNAQCResult[stores.length];
    for (int s = 0; s < stores.length; s++) {
        results[s] = new SmallRNAQCResult(stores[s], minLength, maxLength, features);
    }
    for (int f = 0; f < features.length; f++) {
        for (int d = 0; d < stores.length; d++) {
            updateProgress("Quantitating " + features[f] + " for " + stores[d], (stores.length * f) + d, stores.length * features.length);
            int[] lengthCounts = new int[(maxLength - minLength) + 1];
            String lastChr = "";
            Chromosome lastChrObject = null;
            Feature[] theseFeatures = collection.genome().annotationCollection().getFeaturesForType(features[f]);
            Arrays.sort(theseFeatures);
            for (int i = 0; i < theseFeatures.length; i++) {
                if (theseFeatures[i].chromosomeName() != lastChr) {
                    lastChr = theseFeatures[i].chromosomeName();
                    lastChrObject = collection.genome().getExactChromsomeNameMatch(lastChr);
                }
                long[] reads = stores[d].getReadsForProbe(new Probe(lastChrObject, theseFeatures[i].location().packedPosition()));
                for (int r = 0; r < reads.length; r++) {
                    int length = SequenceRead.length(reads[r]);
                    if (length >= minLength && length <= maxLength) {
                        lengthCounts[length - minLength]++;
                        if (cancel) {
                            progressCancelled();
                            return;
                        }
                    }
                }
                // End each read
                results[d].addCountsForFeatureIndex(f, lengthCounts);
            }
        // End each feature instance
        }
    // End each data store
    }
    // End each feature
    // Finally we make up the data sets we're going to pass back.
    progressComplete(results);
}
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)

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