Search in sources :

Example 1 with Reporter

use of ubic.gemma.core.loader.expression.arrayDesign.Reporter in project Gemma by PavlidisLab.

the class SequenceManipulation method collapse.

/**
 * Convert a CompositeSequence's immobilizedCharacteristics into a single sequence, using a simple merge-join
 * strategy.
 *
 * @param sequences sequences
 * @return BioSequence. Not all fields are filled in and must be set by the caller.
 */
public static BioSequence collapse(Collection<Reporter> sequences) {
    Collection<Reporter> copyOfSequences = SequenceManipulation.copyReporters(sequences);
    BioSequence collapsed = BioSequence.Factory.newInstance();
    collapsed.setSequence("");
    if (SequenceManipulation.log.isDebugEnabled())
        SequenceManipulation.log.debug("Collapsing " + sequences.size() + " sequences");
    while (!copyOfSequences.isEmpty()) {
        Reporter next = SequenceManipulation.findLeftMostProbe(copyOfSequences);
        int ol = SequenceManipulation.rightHandOverlap(collapsed, next.getImmobilizedCharacteristic());
        String nextSeqStr = next.getImmobilizedCharacteristic().getSequence();
        collapsed.setSequence(collapsed.getSequence() + nextSeqStr.substring(ol));
        if (SequenceManipulation.log.isDebugEnabled()) {
            SequenceManipulation.log.debug("New Seq to add: " + nextSeqStr + " Overlap=" + ol + " Result=" + collapsed.getSequence());
        }
        copyOfSequences.remove(next);
    }
    collapsed.setIsCircular(false);
    collapsed.setIsApproximateLength(false);
    collapsed.setLength((long) collapsed.getSequence().length());
    collapsed.setDescription("Collapsed from " + sequences.size() + " reporter sequences");
    return collapsed;
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) Reporter(ubic.gemma.core.loader.expression.arrayDesign.Reporter)

Example 2 with Reporter

use of ubic.gemma.core.loader.expression.arrayDesign.Reporter in project Gemma by PavlidisLab.

the class SequenceManipulation method findLeftMostProbe.

/**
 * From a set of Reporters, find the one with the left-most location.
 */
private static Reporter findLeftMostProbe(Collection<Reporter> copyOfProbes) {
    Long minLocation = (long) Integer.MAX_VALUE;
    Reporter next = null;
    for (Reporter probe : copyOfProbes) {
        Long loc = probe.getStartInBioChar();
        if (loc <= minLocation) {
            minLocation = loc;
            next = probe;
        }
    }
    return next;
}
Also used : Reporter(ubic.gemma.core.loader.expression.arrayDesign.Reporter)

Example 3 with Reporter

use of ubic.gemma.core.loader.expression.arrayDesign.Reporter in project Gemma by PavlidisLab.

the class SequenceManipulation method copyReporters.

private static Collection<Reporter> copyReporters(Collection<Reporter> reporters) {
    Collection<Reporter> copyReporters = new HashSet<>();
    for (Reporter next : reporters) {
        assert next.getStartInBioChar() != null : "Null startInBioChar";
        assert next.getImmobilizedCharacteristic() != null : "Null immobilized characteristic";
        Reporter copy = Reporter.Factory.newInstance();
        copy.setImmobilizedCharacteristic(next.getImmobilizedCharacteristic());
        copy.setName(next.getName());
        copy.setStartInBioChar(next.getStartInBioChar());
        copyReporters.add(copy);
    }
    assert copyReporters.size() == reporters.size() : "Sequences did not copy properly";
    return copyReporters;
}
Also used : Reporter(ubic.gemma.core.loader.expression.arrayDesign.Reporter) HashSet(java.util.HashSet)

Example 4 with Reporter

use of ubic.gemma.core.loader.expression.arrayDesign.Reporter in project Gemma by PavlidisLab.

the class MatrixConversionTest method getCompositeSequences.

private List<CompositeSequence> getCompositeSequences(ArrayDesign ad) {
    List<CompositeSequence> sequences = new ArrayList<>();
    for (long i = 0; i < MatrixConversionTest.NUM_CS; i++) {
        Reporter reporter = Reporter.Factory.newInstance();
        CompositeSequence compositeSequence = CompositeSequence.Factory.newInstance();
        reporter.setName(RandomStringUtils.randomNumeric(15) + "_testreporter");
        compositeSequence.setName(RandomStringUtils.randomNumeric(15) + "_testcs");
        compositeSequence.setId(i);
        compositeSequence.setArrayDesign(ad);
        sequences.add(compositeSequence);
    }
    return sequences;
}
Also used : Reporter(ubic.gemma.core.loader.expression.arrayDesign.Reporter) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Aggregations

Reporter (ubic.gemma.core.loader.expression.arrayDesign.Reporter)4 HashSet (java.util.HashSet)1 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)1 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)1