/** * Add an exon. If the exon's bounds are beyond the transcript's bounds, the transcript's bounds * are adjusted accordingly. Sets the exon's transcript to this transcript object. * * @param exon - Exon to be added */ public void addExon(Exon exon) { CVTerm partOfCvterm = conf.getDefaultCVTermForClass("PartOf"); // if the exon's bounds are beyond the transcript's bounds, need to adjust the transcript's // bounds if (exon.getFeatureLocation().getFmin() < getFeatureLocation().getFmin()) { getFeatureLocation().setFmin(exon.getFeatureLocation().getFmin()); } if (exon.getFeatureLocation().getFmax() > getFeatureLocation().getFmax()) { getFeatureLocation().setFmax(exon.getFeatureLocation().getFmax()); } // if the transcript's bounds are beyond the gene's bounds, need to adjust the gene's bounds if (getGene() != null) { if (getFmin() < getGene().getFmin()) { getGene().setFmin(getFmin()); } if (getFmax() > getGene().getFmax()) { getGene().setFmax(getFmax()); } } // add exon int rank = 0; // TODO: do we need to figure out the rank? feature .getChildFeatureRelationships() .add(new FeatureRelationship(partOfCvterm, feature, exon.getFeature(), rank)); exon.setTranscript(this); }
@Override public int convertSourceCoordinateToLocalCoordinate(int sourceCoordinate) { List<Exon> exons = BioObjectUtil.createSortedFeatureListByLocation(getExons()); int localCoordinate = -1; if (exons.size() == 0) { return super.convertSourceCoordinateToLocalCoordinate(sourceCoordinate); } int currentCoordinate = 0; for (Exon exon : exons) { if (exon.getFeatureLocation().getFmin() <= sourceCoordinate && exon.getFeatureLocation().getFmax() >= sourceCoordinate) { if (getFeatureLocation().getStrand() == -1) { localCoordinate = currentCoordinate + (exon.getFeatureLocation().getFmax() - sourceCoordinate) - 1; } else { localCoordinate = currentCoordinate + (sourceCoordinate - exon.getFeatureLocation().getFmin()); } } currentCoordinate += exon.getLength(); } return localCoordinate; }
@Override public int convertLocalCoordinateToSourceCoordinate(int localCoordinate) { List<Exon> exons = BioObjectUtil.createSortedFeatureListByLocation(getExons()); int sourceCoordinate = -1; if (exons.size() == 0) { return super.convertLocalCoordinateToSourceCoordinate(localCoordinate); } int currentLength = 0; int currentCoordinate = localCoordinate; for (Exon exon : exons) { int exonLength = exon.getLength(); if (currentLength + exonLength >= localCoordinate) { if (getFeatureLocation().getStrand() == -1) { sourceCoordinate = exon.getFeatureLocation().getFmax() - currentCoordinate - 1; } else { sourceCoordinate = exon.getFeatureLocation().getFmin() + currentCoordinate; } break; } currentLength += exonLength; currentCoordinate -= exonLength; } return sourceCoordinate; }