use of org.nextprot.api.commons.utils.NucleotidePositionRange in project nextprot-api by calipho-sib.
the class SequencePositionMapperTest method geneIsoformPosTestNotInFrameCrossExon.
@Test
public void geneIsoformPosTestNotInFrameCrossExon() {
// 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 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);
// logger.debug(result);
assertEquals(true, result.areInFrame());
assertEquals(new Integer(2), result.getAminoAcidPosition());
}
use of org.nextprot.api.commons.utils.NucleotidePositionRange in project nextprot-api by calipho-sib.
the class SequencePositionMapper method getCodonNucleotideIndices.
/*
*
* 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--|
*
*
*/
static CodonNucleotideIndices getCodonNucleotideIndices(GeneMasterCodonPosition codonPos, List<NucleotidePositionRange> positionsOfIsoformOnDNA) {
logger.debug("----------------------------------------------------------");
int lowNum = 0;
CodonNucleotideIndices codonPosInTranscript = new CodonNucleotideIndices();
for (NucleotidePositionRange range : positionsOfIsoformOnDNA) {
int nu1Pos = range.getLower();
int nu2Pos = range.getUpper();
int highNum = lowNum + nu2Pos - nu1Pos;
logger.debug("nu1Pos:" + nu1Pos + " nu2Pos:" + nu2Pos + " lowNum:" + lowNum + " highNum:" + highNum);
while (true) {
int nuIndex = codonPosInTranscript.size();
int nuPos = codonPos.getNucleotidePosition(nuIndex);
logger.debug("nuPos(" + nuIndex + ")=" + nuPos);
if (nuPos < nu1Pos || nuPos > nu2Pos)
break;
int nuNum = lowNum + nuPos - nu1Pos;
logger.debug("adding codon nucelotide number:" + nuNum);
codonPosInTranscript.addNucleotideIndex(nuNum);
if (codonPosInTranscript.size() == 3) {
logger.debug("returning codonPosInTranscript: " + codonPosInTranscript);
return codonPosInTranscript;
}
}
lowNum = highNum + 1;
}
logger.debug("codon not found in the gene mapping ranges, " + codonPosInTranscript.size() + " nucleotides found");
logger.debug("returning codonPosInTranscript: " + codonPosInTranscript);
return codonPosInTranscript;
}
use of org.nextprot.api.commons.utils.NucleotidePositionRange in project nextprot-api by calipho-sib.
the class MasterIsoformMappingDaoImpl method findMasterIsoformMapping.
@Override
public Map<String, List<NucleotidePositionRange>> findMasterIsoformMapping(String ac) {
SqlParameterSource namedParams = new MapSqlParameterSource("entryName", ac);
List<IsoMasterNuRangePos> isoNuRanges = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("master-isoform-mapping-by-entry-name"), namedParams, new RowMapper<IsoMasterNuRangePos>() {
@Override
public IsoMasterNuRangePos mapRow(ResultSet resultSet, int row) throws SQLException {
IsoMasterNuRangePos rec = new IsoMasterNuRangePos();
rec.iso = resultSet.getString("isoform_ac");
rec.nuPosRange = new NucleotidePositionRange(resultSet.getInt("first_pos"), resultSet.getInt("last_pos"));
return rec;
}
});
Map<String, List<NucleotidePositionRange>> mapIsoNuRanges = new HashMap<String, List<NucleotidePositionRange>>();
for (IsoMasterNuRangePos rec : isoNuRanges) {
if (!mapIsoNuRanges.containsKey(rec.iso))
mapIsoNuRanges.put(rec.iso, new ArrayList<NucleotidePositionRange>());
mapIsoNuRanges.get(rec.iso).add(new NucleotidePositionRange(rec.nuPosRange.getLower(), rec.nuPosRange.getUpper()));
}
return mapIsoNuRanges;
}
Aggregations