use of com.milaboratory.core.sequence.NucleotideSequence in project repseqio by repseqio.
the class SequenceBaseTest method test2em.
@Test(expected = IllegalArgumentException.class)
public void test2em() throws Exception {
SequenceBase base = new SequenceBase();
base.put("A1", 100, new NucleotideSequence("ATTAGACACACAC"));
base.put("A1", 10, new NucleotideSequence("ATTAGACACACAC"));
base.put("A1", 20, new NucleotideSequence("TACATA"));
}
use of com.milaboratory.core.sequence.NucleotideSequence in project repseqio by repseqio.
the class SequenceBaseTest method test4.
@Test
public void test4() throws Exception {
SequenceBase base = new SequenceBase();
base.put("A1", 18, new NucleotideSequence("CAC"));
base.put("A1", 10, new NucleotideSequence("ATTAGACACACAC"));
assertEquals(new NucleotideSequence("ATTAGACACAC"), base.get("A1", new Range(10, 21)));
}
use of com.milaboratory.core.sequence.NucleotideSequence in project repseqio by repseqio.
the class SequenceBaseTest method test2m.
@Test
public void test2m() throws Exception {
SequenceBase base = new SequenceBase();
base.put("A1", 100, new NucleotideSequence("ATTAGACACACAC"));
base.put("A1", 10, new NucleotideSequence("ATTAGACACACAC"));
base.put("A1", 20, new NucleotideSequence("CACATA"));
assertEquals(new NucleotideSequence("ACACA"), base.get("A1", new Range(19, 24)));
assertEquals(new NucleotideSequence("TTAG"), base.get("A1", new Range(101, 105)));
}
use of com.milaboratory.core.sequence.NucleotideSequence in project repseqio by repseqio.
the class SequenceBaseTest method test1e.
@Test(expected = IllegalArgumentException.class)
public void test1e() throws Exception {
SequenceBase base = new SequenceBase();
base.put("A1", 10, new NucleotideSequence("ATTAGACACACAC"));
base.put("A1", 20, new NucleotideSequence("ATT"));
}
use of com.milaboratory.core.sequence.NucleotideSequence in project mixcr by milaboratory.
the class VDJCAlignmentsFormatter method getTargetAsMultiAlignment.
public static MultiAlignmentHelper getTargetAsMultiAlignment(VDJCObject vdjcObject, int targetId, boolean addHitScore, boolean addReads) {
if (addReads && !(vdjcObject instanceof VDJCAlignments))
throw new IllegalArgumentException("Read alignments supported only for VDJCAlignments.");
NSequenceWithQuality target = vdjcObject.getTarget(targetId);
NucleotideSequence targetSeq = target.getSequence();
SequencePartitioning partitioning = vdjcObject.getPartitionedTarget(targetId).getPartitioning();
List<Alignment<NucleotideSequence>> alignments = new ArrayList<>();
List<String> alignmentLeftComments = new ArrayList<>();
List<String> alignmentRightComments = new ArrayList<>();
for (GeneType gt : GeneType.values()) for (VDJCHit hit : vdjcObject.getHits(gt)) {
Alignment<NucleotideSequence> alignment = hit.getAlignment(targetId);
if (alignment == null)
continue;
alignment = alignment.invert(targetSeq);
alignments.add(alignment);
alignmentLeftComments.add(hit.getGene().getName());
alignmentRightComments.add(" " + (int) (hit.getAlignment(targetId).getScore()) + (addHitScore ? " (" + (int) (hit.getScore()) + ")" : ""));
}
// Adding read information
if (addReads) {
VDJCAlignments vdjcAlignments = (VDJCAlignments) vdjcObject;
SequenceHistory history = vdjcAlignments.getHistory(targetId);
List<SequenceHistory.RawSequence> reads = history.rawReads();
for (SequenceHistory.RawSequence read : reads) {
NucleotideSequence seq = vdjcAlignments.getOriginalSequence(read.index).getSequence();
int offset = history.offset(read.index);
Alignment<NucleotideSequence> alignment = Aligner.alignOnlySubstitutions(targetSeq, seq, offset, seq.size(), 0, seq.size(), AffineGapAlignmentScoring.IGBLAST_NUCLEOTIDE_SCORING);
alignments.add(alignment);
alignmentLeftComments.add(read.index.toString());
alignmentRightComments.add("");
}
}
MultiAlignmentHelper helper = MultiAlignmentHelper.build(MultiAlignmentHelper.DEFAULT_SETTINGS, new Range(0, target.size()), targetSeq, alignments.toArray(new Alignment[alignments.size()]));
if (!alignments.isEmpty())
drawPoints(helper, partitioning, POINTS_FOR_REARRANGED);
drawAASequence(helper, partitioning, targetSeq);
helper.addSubjectQuality("Quality", target.getQuality());
helper.setSubjectLeftTitle("Target" + targetId);
helper.setSubjectRightTitle(" Score" + (addHitScore ? " (hit score)" : ""));
for (int i = 0; i < alignmentLeftComments.size(); i++) {
helper.setQueryLeftTitle(i, alignmentLeftComments.get(i));
helper.setQueryRightTitle(i, alignmentRightComments.get(i));
}
return helper;
}
Aggregations