Search in sources :

Example 6 with NucleotidePositionRange

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());
}
Also used : NucleotidePositionRange(org.nextprot.api.commons.utils.NucleotidePositionRange) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with NucleotidePositionRange

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;
}
Also used : NucleotidePositionRange(org.nextprot.api.commons.utils.NucleotidePositionRange)

Example 8 with NucleotidePositionRange

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;
}
Also used : NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) SQLException(java.sql.SQLException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) NucleotidePositionRange(org.nextprot.api.commons.utils.NucleotidePositionRange) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

NucleotidePositionRange (org.nextprot.api.commons.utils.NucleotidePositionRange)8 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)1 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)1