use of org.nextprot.api.commons.utils.NucleotidePositionRange in project nextprot-api by calipho-sib.
the class SequencePositionMapper method getCodonPositionOnMaster.
/**
* Get the codon position on gene master that corresponds to the given amino-acid position on isoform
*
* @param isoformPos the aa position on isoform
* @param isoformMasterMapping the list of isoform to gene master mapping
* @return the codon position on gene master
*/
static GeneMasterCodonPosition getCodonPositionOnMaster(int isoformPos, List<NucleotidePositionRange> isoformMasterMapping) {
int firstNucPos = isoformPos * 3 - 3;
// if (debug) System.out.println("nu1Num:" + nu1Num);
int lowNum = 0;
GeneMasterCodonPosition result = new GeneMasterCodonPosition();
for (NucleotidePositionRange range : isoformMasterMapping) {
int firstRangeNucPos = range.getLower();
int lastRangeNucPos = range.getUpper();
int highNum = lowNum + lastRangeNucPos - firstRangeNucPos;
// if (debug) System.out.println("nu1Pos:"+ nu1Pos + " nu2Pos:" + nu2Pos + " lowNum:" + lowNum + " highNum:" + highNum);
while (true) {
int nuIndex = result.size();
int nuNum = firstNucPos + nuIndex;
// if (debug) System.out.println("nuNum:" + nuNum);
if (nuNum < lowNum || nuNum > highNum)
break;
result.addNucleotidePosition(firstRangeNucPos + nuNum - lowNum);
if (result.size() == 3)
return result;
}
lowNum = highNum + 1;
}
return result;
}
use of org.nextprot.api.commons.utils.NucleotidePositionRange in project nextprot-api by calipho-sib.
the class SequencePositionMapperTest method geneCodonPosTest.
@Test
public void geneCodonPosTest() {
// represent two coding regions of DNA (gene,master) mapped to an isoform sequence
List<NucleotidePositionRange> ranges = new ArrayList<NucleotidePositionRange>();
ranges.add(new NucleotidePositionRange(100, 104));
ranges.add(new NucleotidePositionRange(201, 204));
/*
*
* nuNum 0 1 2 3 4 5 6 7 8
* exons |---- exon1 ------| |-- exon 2 ---|
* nuPos 100 101 102 103 104 201 202 203 204
* codons |--codon1--|-------codon2-------|--codon3--|
*
*
*/
GeneMasterCodonPosition result;
// get gene position of each nucl of the codon coding for aa of isoform at pos 1
result = SequencePositionMapper.getCodonPositionOnMaster(1, ranges);
assertEquals(new Integer(100), result.getNucleotidePosition(0));
assertEquals(new Integer(101), result.getNucleotidePosition(1));
assertEquals(new Integer(102), result.getNucleotidePosition(2));
assertEquals(true, result.isValid());
// get gene position of each nucl of the codon coding for aa of isoform at pos 2
result = SequencePositionMapper.getCodonPositionOnMaster(2, ranges);
assertEquals(new Integer(103), result.getNucleotidePosition(0));
assertEquals(new Integer(104), result.getNucleotidePosition(1));
assertEquals(new Integer(201), result.getNucleotidePosition(2));
assertEquals(true, result.isValid());
// get gene position of each nucl of the codon coding for aa of isoform at pos 3
result = SequencePositionMapper.getCodonPositionOnMaster(3, ranges);
assertEquals(new Integer(202), result.getNucleotidePosition(0));
assertEquals(new Integer(203), result.getNucleotidePosition(1));
assertEquals(new Integer(204), result.getNucleotidePosition(2));
assertEquals(true, result.isValid());
// get gene position of each nucl of the codon coding for aa of isoform at pos 0 (out of range)
result = SequencePositionMapper.getCodonPositionOnMaster(0, ranges);
assertEquals(0, result.size());
assertEquals(false, result.isValid());
// get gene position of each nucl of the codon coding for aa of isoform at pos 4 (out of range)
result = SequencePositionMapper.getCodonPositionOnMaster(4, ranges);
assertEquals(0, result.size());
assertEquals(false, result.isValid());
}
use of org.nextprot.api.commons.utils.NucleotidePositionRange in project nextprot-api by calipho-sib.
the class SequencePositionMapperTest method geneIsoformPosTest.
@Test
public void geneIsoformPosTest() {
// represent two coding regions of DNA mapped to an isoform sequence
List<NucleotidePositionRange> genePosRanges = new ArrayList<NucleotidePositionRange>();
genePosRanges.add(new NucleotidePositionRange(100, 104));
genePosRanges.add(new NucleotidePositionRange(201, 204));
/*
* nuNum 0 1 2 3 4 5 6 7 8
* exons |---- exon1 ------| |-- exon 2 ---|
* nuPos 100 101 102 103 104 201 202 203 204
* codons |--codon1--|-------codon2-------|--codon3--|
*/
CodonNucleotideIndices result;
GeneMasterCodonPosition codonNuPos = new GeneMasterCodonPosition();
// get isoform pos of aa corresponding to codon with nu at pos 202 203 204
codonNuPos.clear();
codonNuPos.addNucleotidePosition(202);
codonNuPos.addNucleotidePosition(203);
codonNuPos.addNucleotidePosition(204);
result = SequencePositionMapper.getCodonNucleotideIndices(codonNuPos, genePosRanges);
assertEquals(true, result.has3Nucleotides());
assertEquals(new Integer(3), result.getAminoAcidPosition());
// get isoform position of aa corresponding to codon with nucleotides at position 100,101,102
codonNuPos.clear();
codonNuPos.addNucleotidePosition(100);
codonNuPos.addNucleotidePosition(101);
codonNuPos.addNucleotidePosition(102);
result = SequencePositionMapper.getCodonNucleotideIndices(codonNuPos, genePosRanges);
assertEquals(new Integer(1), result.getAminoAcidPosition());
// get isoform position of aa corresponding to codon with nucleotides at position 103 104 201
codonNuPos.clear();
codonNuPos.addNucleotidePosition(103);
codonNuPos.addNucleotidePosition(104);
codonNuPos.addNucleotidePosition(201);
result = SequencePositionMapper.getCodonNucleotideIndices(codonNuPos, genePosRanges);
assertEquals(new Integer(2), result.getAminoAcidPosition());
// get isoform position of aa corresponding to codon with nucleotides at position 202 203 204
codonNuPos.clear();
codonNuPos.addNucleotidePosition(202);
codonNuPos.addNucleotidePosition(203);
codonNuPos.addNucleotidePosition(204);
result = SequencePositionMapper.getCodonNucleotideIndices(codonNuPos, genePosRanges);
assertEquals(new Integer(3), result.getAminoAcidPosition());
// trying to find a codon position having NON consecutive nucleotides i.e. at pos 201 203 204
codonNuPos.clear();
codonNuPos.addNucleotidePosition(201);
codonNuPos.addNucleotidePosition(203);
codonNuPos.addNucleotidePosition(204);
result = SequencePositionMapper.getCodonNucleotideIndices(codonNuPos, genePosRanges);
assertEquals(false, result.areConsecutive());
assertEquals(null, result.getAminoAcidPosition());
// trying to find a codon position having nucleotide positions that are not in frame (3 nucl of same codon)
// i.e. at pos 101 102 103
codonNuPos.clear();
codonNuPos.addNucleotidePosition(101);
codonNuPos.addNucleotidePosition(102);
codonNuPos.addNucleotidePosition(103);
result = SequencePositionMapper.getCodonNucleotideIndices(codonNuPos, genePosRanges);
assertEquals(false, result.areInFrame());
assertEquals(null, result.getAminoAcidPosition());
// trying to find a codon position having nucleotide positions that are not in frame (3 nucl of same codon)
// i.e. at pos 102 103 104
codonNuPos.clear();
codonNuPos.addNucleotidePosition(102);
codonNuPos.addNucleotidePosition(103);
codonNuPos.addNucleotidePosition(104);
result = SequencePositionMapper.getCodonNucleotideIndices(codonNuPos, genePosRanges);
assertEquals(false, result.areInFrame());
assertEquals(null, result.getAminoAcidPosition());
// trying to find a codon having nucleotide positions out of the gene mapping ranges
// i.e. at pos 77,78,79
codonNuPos.clear();
codonNuPos.addNucleotidePosition(77);
codonNuPos.addNucleotidePosition(78);
codonNuPos.addNucleotidePosition(79);
result = SequencePositionMapper.getCodonNucleotideIndices(codonNuPos, genePosRanges);
assertEquals(null, result.getAminoAcidPosition());
// trying to find a codon having nucleotide positions out of the gene mapping ranges
// i.e. at pos 99,100,101
codonNuPos.clear();
codonNuPos.addNucleotidePosition(99);
codonNuPos.addNucleotidePosition(100);
codonNuPos.addNucleotidePosition(101);
result = SequencePositionMapper.getCodonNucleotideIndices(codonNuPos, genePosRanges);
assertEquals(null, result.getAminoAcidPosition());
// trying to find a codon having nucleotide positions out of the gene mapping ranges
// i.e. at pos 103,104, 015
codonNuPos.clear();
codonNuPos.addNucleotidePosition(103);
codonNuPos.addNucleotidePosition(104);
codonNuPos.addNucleotidePosition(105);
result = SequencePositionMapper.getCodonNucleotideIndices(codonNuPos, genePosRanges);
assertEquals(null, result.getAminoAcidPosition());
}
use of org.nextprot.api.commons.utils.NucleotidePositionRange in project nextprot-api by calipho-sib.
the class IsoformSequencePositionMapperIntegrationTest method getNucleotideCount.
private int getNucleotideCount(List<NucleotidePositionRange> ranges) {
int nuCount = 0;
for (NucleotidePositionRange r : ranges) {
int cnt = r.getUpper() - r.getLower() + 1;
nuCount += cnt;
}
return nuCount;
}
use of org.nextprot.api.commons.utils.NucleotidePositionRange in project nextprot-api by calipho-sib.
the class IsoformSequencePositionMapperIntegrationTest method printIsoLengthAndRangesNuCount.
private void printIsoLengthAndRangesNuCount(String isoName, String isoSeq, List<NucleotidePositionRange> ranges) {
int isoLng = isoSeq.length();
int nuCount = getNucleotideCount(ranges);
boolean ok = isoLng * 3 == nuCount;
for (NucleotidePositionRange r : ranges) if (sout)
System.out.println(isoName + " has masterMapping range " + r);
if (sout)
System.out.println((ok ? "OK - " : "ERROR4 - ") + isoName + " lng in nu:" + isoLng * 3 + " nuCount:" + nuCount);
}
Aggregations