public static boolean isABadRange(String range, String sequence) { try{ Range r = createRangeFromString(range, sequence, false); return (getBadRangeInfo(r, sequence) != null); } catch (IllegalArgumentException e){ return true; } }
CvFuzzyType fromStatus = createCvFuzzyType(positions[0]); CvFuzzyType toStatus = createCvFuzzyType(positions[1]); Integer[] intervalStart = convertPosition(positions[0], fromStatus); Integer[] intervalEnd = convertPosition(positions[1], toStatus);
FeatureUtils.correctRangePositionsAccordingToType(r, seq); if (FeatureUtils.isABadRange(r, seq)){ throw new PersisterException( "Cannot convert the range " + r.toString() + ". " + FeatureUtils.getBadRangeInfo(r, seq) );
final int toIntervalEnd = range.getToIntervalEnd(); String areRangePositionsAccordingToTypeOkStart = getRangePositionsAccordingToRangeTypeErrorMessage(startStatus, fromIntervalStart, fromIntervalEnd, sequence); String areRangePositionsAccordingToTypeOkEnd = getRangePositionsAccordingToRangeTypeErrorMessage(endStatus, toIntervalStart, toIntervalEnd, sequence); return areRangePositionsAccordingToTypeOkEnd; if (areRangeStatusInconsistent(startStatus, endStatus)) { return "Start status " + startStatus.getShortLabel() + " and end status " + endStatus.getShortLabel() + " are inconsistent"; if (!(startStatus.isCTerminalRegion() || startStatus.isUndetermined() || startStatus.isNTerminalRegion()) && !(endStatus.isCTerminalRegion() || endStatus.isUndetermined() || endStatus.isNTerminalRegion()) && areRangePositionsOverlapping(range)) { return "The range positions overlap : " + startStatus.getShortLabel() + ":" + fromIntervalStart + "-" + fromIntervalEnd + "," + endStatus.getShortLabel() + ":" + toIntervalStart + "-" + toIntervalEnd;
if (!FeatureUtils.isABadRange(this, sequence)){ throw new IllegalRangeException("Problem extracting sequence using range. "+FeatureUtils.getBadRangeInfo(this, sequence) +": "+this+" / Start status: "+fromCvFuzzyType+" / End status: "+toCvFuzzyType+" / Seq.Length: "+(sequence != null? sequence.length() : 0));
/** * @param range : the range to convert * @return the range as a String * If the range is invalid, will return fromIntervalStart-toIntervalEnd */ public static String convertRangeIntoString(Range range) { if (range == null) { throw new IllegalArgumentException("The range cannot be null."); } if (isABadRange(range, null)) { return range.getFromIntervalStart() + RANGE_SEPARATOR + range.getToIntervalEnd(); //throw new IllegalRangeException(getBadRangeInfo(range, null)); } String startPosition = positionToString(range.getFromCvFuzzyType(), range.getFromIntervalStart(), range.getFromIntervalEnd()); String endPosition = positionToString(range.getToCvFuzzyType(), range.getToIntervalStart(), range.getToIntervalEnd()); return startPosition + RANGE_SEPARATOR + endPosition; }
/** * @param protein : the protein to check * @return a set of the protein feature ranges which are overlapping or out of bound */ public static Set<Range> getBadRanges(Protein protein) { Collection<Component> components = protein.getActiveInstances(); Set<Range> badRanges = new HashSet<Range>(); for (Component component : components) { Collection<Feature> features = component.getFeatures(); for (Feature feature : features) { Collection<Range> ranges = feature.getRanges(); for (Range range : ranges) { if (isABadRange(range, protein.getSequence())) { badRanges.add(range); } } } } return badRanges; }
if (areRangePositionsOutOfBounds(start, end, sequenceLength)) { return "Certain and ragged-n-terminus positions must always be strictly superior to 0 and inferior or equal to the protein sequence length. Actual positions : " + start + "-" + end + ", sequence length " + sequenceLength; if (areRangePositionsInvalid(start, end) || start <= 0 || end <= 0) { return rangeType.getShortLabel() + " positions must always be strictly superior to 0 and the end must be superior or equal to the start. Actual positions : " + start + "-" + end; if (areRangePositionsInvalid(start, end) || start <= 0 || end <= 0) { return rangeType.getShortLabel() + " positions must always have an end superior or equal to the start. Actual positions : " + start + "-" + end; } else if (areRangePositionsOutOfBounds(start, end, sequenceLength)) { return rangeType.getShortLabel() + " positions must always be strictly superior to 0 and inferior or equal to the sequence length. Actual positions : " + start + "-" + end + ", sequence length " + sequenceLength;
/** * @param range : the range to check * @param sequence : the sequence of the protein * @return true if the range is within the sequence, coherent with its fuzzy type and not overlapping */ public static boolean isABadRange(Range range, String sequence) { return (getBadRangeInfo(range, sequence) != null); }
String newSequence = updated.getNewRange() != null ? updated.getNewRange().getFullSequence() : null; String oldPositions = updated.getOldRange() != null ? FeatureUtils.convertRangeIntoString(updated.getOldRange()) : null; String newPositions = updated.getNewRange() != null ? FeatureUtils.convertRangeIntoString(updated.getNewRange()) : null;
return arePositionsOverlapping(range.getFromIntervalStart(), range.getFromIntervalEnd(), range.getToIntervalStart(), range.getToIntervalEnd());
FeatureUtils.correctRangePositionsAccordingToType(range, seq);
final int toIntervalEnd = range.getToIntervalEnd(); String areRangePositionsAccordingToTypeOkStart = getRangePositionsAccordingToRangeTypeErrorMessage(startStatus, fromIntervalStart, fromIntervalEnd, sequence); String areRangePositionsAccordingToTypeOkEnd = getRangePositionsAccordingToRangeTypeErrorMessage(endStatus, toIntervalStart, toIntervalEnd, sequence); return areRangePositionsAccordingToTypeOkEnd; if (areRangeStatusInconsistent(startStatus, endStatus)) { return "Start status " + startStatus.getShortLabel() + " and end status " + endStatus.getShortLabel() + " are inconsistent"; if (!(startStatus.isCTerminalRegion() || startStatus.isUndetermined() || startStatus.isNTerminalRegion()) && !(endStatus.isCTerminalRegion() || endStatus.isUndetermined() || endStatus.isNTerminalRegion()) && areRangePositionsOverlapping(range)) { return "The range positions overlap : " + startStatus.getShortLabel() + ":" + fromIntervalStart + "-" + fromIntervalEnd + "," + endStatus.getShortLabel() + ":" + toIntervalStart + "-" + toIntervalEnd;
if (!FeatureUtils.isABadRange(this, sequence)){ throw new IllegalRangeException("Problem extracting sequence using range. "+FeatureUtils.getBadRangeInfo(this, sequence) +": "+this+" / Start status: "+fromCvFuzzyType+" / End status: "+toCvFuzzyType+" / Seq.Length: "+(sequence != null? sequence.length() : 0));
/** * @param range : the range to convert * @return the range as a String * If the range is invalid, will return fromIntervalStart-toIntervalEnd */ public static String convertRangeIntoString(Range range) { if (range == null) { throw new IllegalArgumentException("The range cannot be null."); } if (isABadRange(range, null)) { return range.getFromIntervalStart() + RANGE_SEPARATOR + range.getToIntervalEnd(); //throw new IllegalRangeException(getBadRangeInfo(range, null)); } String startPosition = positionToString(range.getFromCvFuzzyType(), range.getFromIntervalStart(), range.getFromIntervalEnd()); String endPosition = positionToString(range.getToCvFuzzyType(), range.getToIntervalStart(), range.getToIntervalEnd()); return startPosition + RANGE_SEPARATOR + endPosition; }
/** * @param protein : the protein to check * @return a set of the protein features containing bad ranges (overlapping or out of bound) */ public static Set<Feature> getFeaturesWithBadRanges(Protein protein) { Collection<Component> components = protein.getActiveInstances(); Set<Feature> badFeatures = new HashSet<Feature>(); for (Component component : components) { Collection<Feature> features = component.getBindingDomains(); for (Feature feature : features) { Collection<Range> ranges = feature.getRanges(); for (Range range : ranges) { if (isABadRange(range, protein.getSequence())) { badFeatures.add(feature); break; } } } } return badFeatures; }
if (areRangePositionsOutOfBounds(start, end, sequenceLength)) { return "Certain and ragged-n-terminus positions must always be strictly superior to 0 and inferior or equal to the protein sequence length. Actual positions : " + start + "-" + end + ", sequence length " + sequenceLength; if (areRangePositionsInvalid(start, end) || start <= 0 || end <= 0) { return rangeType.getShortLabel() + " positions must always be strictly superior to 0 and the end must be superior or equal to the start. Actual positions : " + start + "-" + end; if (areRangePositionsInvalid(start, end) || start <= 0 || end <= 0) { return rangeType.getShortLabel() + " positions must always have an end superior or equal to the start. Actual positions : " + start + "-" + end; } else if (areRangePositionsOutOfBounds(start, end, sequenceLength)) { return rangeType.getShortLabel() + " positions must always be strictly superior to 0 and inferior or equal to the sequence length. Actual positions : " + start + "-" + end + ", sequence length " + sequenceLength;
/** * @param range : the range to check * @param sequence : the sequence of the protein * @return true if the range is within the sequence, coherent with its fuzzy type and not overlapping */ public static boolean isABadRange(Range range, String sequence) { return (getBadRangeInfo(range, sequence) != null); }
String rangeAsString = FeatureUtils.convertRangeIntoString(range); if (rangeAsString != null){ rangesMitab.add(rangeAsString);
return arePositionsOverlapping(range.getFromIntervalStart(), range.getFromIntervalEnd(), range.getToIntervalStart(), range.getToIntervalEnd());