forked from charite/jannovar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for charite#519 - add support for HGVS repeats
- Loading branch information
Showing
12 changed files
with
751 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
...c/main/java/de/charite/compbio/jannovar/hgvs/nts/change/NucleotideNotSequencedRepeat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package de.charite.compbio.jannovar.hgvs.nts.change; | ||
|
||
import java.util.Objects; | ||
import de.charite.compbio.jannovar.hgvs.AminoAcidCode; | ||
import de.charite.compbio.jannovar.hgvs.nts.NucleotideRange; | ||
|
||
|
||
/** | ||
* A repeat that is not completely sequenced (i.e. unknown bases). | ||
* | ||
* @author Mark Woon | ||
*/ | ||
public class NucleotideNotSequencedRepeat extends NucleotideChange { | ||
public enum InDelType { INS, DEL} | ||
private final NucleotideRange range; | ||
private final InDelType type; | ||
/** | ||
* The lower bound on the length of the repeat, inclusive. | ||
*/ | ||
private final int minCount; | ||
/** | ||
* The upper bound on the length of the repeat, inclusive. | ||
*/ | ||
private final int maxCount; | ||
|
||
|
||
public NucleotideNotSequencedRepeat(boolean onlyPredicted, NucleotideRange range, InDelType type, | ||
int minCount, int maxCount) { | ||
super(onlyPredicted); | ||
this.range = range; | ||
this.type = type; | ||
this.minCount = minCount; | ||
this.maxCount = maxCount; | ||
} | ||
|
||
|
||
/** | ||
* @return range of repeat | ||
*/ | ||
public NucleotideRange getRange() { | ||
return range; | ||
} | ||
|
||
public boolean isInsertion() { | ||
return type == InDelType.INS; | ||
} | ||
|
||
public boolean isDeletion() { | ||
return type == InDelType.DEL; | ||
} | ||
|
||
/** | ||
* Gets the lower bound on the length of the repeat, inclusive. | ||
*/ | ||
public int getMinCount() { | ||
return minCount; | ||
} | ||
|
||
/** | ||
* Gets the upper bound on the length of the repeat, inclusive. | ||
*/ | ||
public int getMaxCount() { | ||
return maxCount; | ||
} | ||
|
||
|
||
@Override | ||
public NucleotideChange withOnlyPredicted(boolean flag) { | ||
return new NucleotideNotSequencedRepeat(flag, range, type, minCount, maxCount); | ||
} | ||
|
||
|
||
@Override | ||
public String toHGVSString() { | ||
StringBuilder builder = new StringBuilder(range.toHGVSString()) | ||
.append(type.name().toLowerCase()) | ||
.append("(") | ||
.append(minCount); | ||
if (minCount != maxCount) { | ||
builder.append("_") | ||
.append(maxCount); | ||
} | ||
builder.append(")"); | ||
return wrapIfOnlyPredicted(builder.toString()); | ||
} | ||
|
||
@Override | ||
public String toHGVSString(AminoAcidCode code) { | ||
return toHGVSString(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "NucleotideNotSequencedRepeat [range=" + range + "type=" + type.name() + ", minCount=" + | ||
minCount + ", maxCount=" + maxCount + "]"; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(range, type, minCount, maxCount); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
final NucleotideNotSequencedRepeat other = (NucleotideNotSequencedRepeat)obj; | ||
return Objects.equals(range, other.range) && | ||
Objects.equals(type, other.type) && | ||
Objects.equals(minCount, other.getMinCount()) && | ||
Objects.equals(maxCount, other.getMaxCount()); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...s/src/main/java/de/charite/compbio/jannovar/hgvs/nts/change/NucleotideRepeatSequence.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package de.charite.compbio.jannovar.hgvs.nts.change; | ||
|
||
import java.util.Objects; | ||
import de.charite.compbio.jannovar.hgvs.AminoAcidCode; | ||
import de.charite.compbio.jannovar.hgvs.ConvertibleToHGVSString; | ||
|
||
|
||
/** | ||
* A repeated sequence. | ||
* | ||
* @author Mark Woon | ||
*/ | ||
public class NucleotideRepeatSequence implements ConvertibleToHGVSString { | ||
final String sequence; | ||
final int copyNumber; | ||
|
||
|
||
public NucleotideRepeatSequence(String sequence, int copyNumber) { | ||
this.sequence = sequence; | ||
this.copyNumber = copyNumber; | ||
} | ||
|
||
|
||
public String getSequence() { | ||
return sequence; | ||
} | ||
|
||
public int getCopyNumber() { | ||
return copyNumber; | ||
} | ||
|
||
|
||
@Override | ||
public String toHGVSString() { | ||
return sequence + "[" + copyNumber + "]"; | ||
} | ||
|
||
@Override | ||
public String toHGVSString(AminoAcidCode code) { | ||
return toHGVSString(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "NucleotideRepeatSequence [sequence=" + sequence + ", copyNumber=" + copyNumber + "]"; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(sequence, copyNumber); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
final NucleotideRepeatSequence other = (NucleotideRepeatSequence)obj; | ||
return Objects.equals(sequence, other.sequence) && | ||
Objects.equals(copyNumber, other.copyNumber); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
.../src/main/java/de/charite/compbio/jannovar/hgvs/nts/change/NucleotideSequencedRepeat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package de.charite.compbio.jannovar.hgvs.nts.change; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import com.google.common.base.Joiner; | ||
import de.charite.compbio.jannovar.hgvs.nts.NucleotideRange; | ||
|
||
|
||
/** | ||
* A repeat that has been sequenced. | ||
* | ||
* @author Mark Woon | ||
*/ | ||
public class NucleotideSequencedRepeat extends NucleotideChange { | ||
private final NucleotideRange range; | ||
public List<NucleotideRepeatSequence> sequencedRepeats; | ||
public NucleotideNotSequencedRepeat notSequencedRepeat; | ||
|
||
|
||
public NucleotideSequencedRepeat(boolean onlyPredicted, NucleotideRange range, | ||
List<NucleotideRepeatSequence> sequencedRepeats) { | ||
super(onlyPredicted); | ||
this.range = range; | ||
this.sequencedRepeats = sequencedRepeats; | ||
} | ||
|
||
|
||
/** | ||
* @return range of repeat | ||
*/ | ||
public NucleotideRange getRange() { | ||
return range; | ||
} | ||
|
||
/** | ||
* Gets the sequenced repeats. Null if this repeat is not sequenced. | ||
*/ | ||
public List<NucleotideRepeatSequence> getSequencedRepeats() { | ||
return sequencedRepeats; | ||
} | ||
|
||
/** | ||
* Gets the repeat if it was not sequenced. Null if this repeat is sequenced. | ||
*/ | ||
public NucleotideNotSequencedRepeat getNotSequencedRepeat() { | ||
return notSequencedRepeat; | ||
} | ||
|
||
|
||
@Override | ||
public NucleotideChange withOnlyPredicted(boolean flag) { | ||
return new NucleotideSequencedRepeat(flag, range, sequencedRepeats); | ||
} | ||
|
||
|
||
@Override | ||
public String toHGVSString() { | ||
StringBuilder builder = new StringBuilder(range.toHGVSString()); | ||
sequencedRepeats.stream() | ||
.map(NucleotideRepeatSequence::toHGVSString) | ||
.forEach(builder::append); | ||
return wrapIfOnlyPredicted(builder.toString()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "NucleotideRepeat [range=" + range + ", sequences=(" + | ||
Joiner.on(", ").join(sequencedRepeats) + ")]"; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), range, sequencedRepeats); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
final NucleotideSequencedRepeat other = (NucleotideSequencedRepeat)obj; | ||
return super.equals(obj) && | ||
Objects.equals(range, other.range) && | ||
Objects.equals(sequencedRepeats, other.sequencedRepeats); | ||
} | ||
} |
Oops, something went wrong.