Commit 1bdd52fc authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '500-gene-variants-in-molart' into 'master'

Resolve "gene variants in molart"

Closes #500

See merge request !420
parents b7c2d52b 728cbe10
Pipeline #6556 passed with stage
in 7 minutes and 26 seconds
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
* @param {string} javaObject.referenceGenomeType * @param {string} javaObject.referenceGenomeType
* @param {string} javaObject.referenceGenomeVersion * @param {string} javaObject.referenceGenomeVersion
* @param {string} javaObject.contig * @param {string} javaObject.contig
* @param {null|number} [javaObject.allelFrequency] * @param {string} [javaObject.aminoAcidChange]
* @param {null|string} [javaObject.allelFrequency]
* @param {null|string} [javaObject.variantIdentifier] * @param {null|string} [javaObject.variantIdentifier]
* *
* @constructor * @constructor
...@@ -23,8 +24,25 @@ function GeneVariant(javaObject) { ...@@ -23,8 +24,25 @@ function GeneVariant(javaObject) {
this.setContig(javaObject.contig); this.setContig(javaObject.contig);
this.setAllelFrequency(javaObject.allelFrequency); this.setAllelFrequency(javaObject.allelFrequency);
this.setVariantIdentifier(javaObject.variantIdentifier); this.setVariantIdentifier(javaObject.variantIdentifier);
this.setAminoAcidChange(javaObject.aminoAcidChange);
} }
/**
*
* @param {string} aminoAcidChange
*/
GeneVariant.prototype.setAminoAcidChange = function (aminoAcidChange) {
this._aminoAcidChange = aminoAcidChange;
};
/**
*
* @returns {string}
*/
GeneVariant.prototype.getAminoAcidChange = function () {
return this._aminoAcidChange;
};
/** /**
* *
* @param {number} position * @param {number} position
...@@ -91,13 +109,13 @@ GeneVariant.prototype.getContig = function () { ...@@ -91,13 +109,13 @@ GeneVariant.prototype.getContig = function () {
/** /**
* *
* @param {number} allelFrequency * @param {string} allelFrequency
*/ */
GeneVariant.prototype.setAllelFrequency = function (allelFrequency) { GeneVariant.prototype.setAllelFrequency = function (allelFrequency) {
if (allelFrequency === null) { if (allelFrequency === null) {
this._allelFrequency = undefined; this._allelFrequency = undefined;
} else { } else {
this._allelFrequency = allelFrequency; this._allelFrequency = parseFloat(allelFrequency);
} }
}; };
......
...@@ -5,6 +5,7 @@ var assert = require('assert'); ...@@ -5,6 +5,7 @@ var assert = require('assert');
describe('GeneVariant', function () { describe('GeneVariant', function () {
it("constructor", function () { it("constructor", function () {
// noinspection SpellCheckingInspection
var data = { var data = {
position: 12, position: 12,
originalDna: "A", originalDna: "A",
...@@ -13,7 +14,8 @@ describe('GeneVariant', function () { ...@@ -13,7 +14,8 @@ describe('GeneVariant', function () {
referenceGenomeVersion: "v1", referenceGenomeVersion: "v1",
contig: "1", contig: "1",
allelFrequency: "0.2", allelFrequency: "0.2",
variantIdentifier: "id" variantIdentifier: "id",
aminoAcidChange: "LRRK2:NM_198578:exon1:c.T45C:p.T15T"
}; };
var variant = new GeneVariant(data); var variant = new GeneVariant(data);
assert.equal(variant.getPosition(), data.position); assert.equal(variant.getPosition(), data.position);
...@@ -24,5 +26,6 @@ describe('GeneVariant', function () { ...@@ -24,5 +26,6 @@ describe('GeneVariant', function () {
assert.equal(variant.getAllelFrequency(), data.allelFrequency); assert.equal(variant.getAllelFrequency(), data.allelFrequency);
assert.equal(variant.getVariantIdentifier(), data.variantIdentifier); assert.equal(variant.getVariantIdentifier(), data.variantIdentifier);
assert.equal(variant.getReferenceGenomeVersion(), data.referenceGenomeVersion); assert.equal(variant.getReferenceGenomeVersion(), data.referenceGenomeVersion);
assert.equal(variant.getAminoAcidChange(), data.aminoAcidChange);
}); });
}); });
...@@ -5,6 +5,8 @@ import java.util.ArrayList; ...@@ -5,6 +5,8 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamData;
...@@ -16,262 +18,289 @@ import lcsb.mapviewer.model.map.MiriamData; ...@@ -16,262 +18,289 @@ import lcsb.mapviewer.model.map.MiriamData;
*/ */
public class GeneVariation implements Serializable { public class GeneVariation implements Serializable {
/** /**
* * Default class logger.
*/ */
private static final long serialVersionUID = 1L; @SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(GeneVariation.class);
/**
* Variation position in the genome. /**
*/ *
private Long position; */
private static final long serialVersionUID = 1L;
/**
* Original dna (from the reference genome). /**
*/ * Variation position in the genome.
private String originalDna; */
private Long position;
/**
* Alternative dna (suggested by the variant). /**
*/ * Original DNA (from the reference genome).
private String modifiedDna; */
private String originalDna;
/**
* Contig where variant was observed. /**
*/ * Alternative DNA (suggested by the variant).
private String contig; */
private String modifiedDna;
private String allelFrequency;
private String variantIdentifier; /**
* Contig where variant was observed.
/** */
* Reference genome type. private String contig;
*/
private ReferenceGenomeType referenceGenomeType; /**
* Allel frequency of the variant.
/** */
* Version of the reference genome. private String allelFrequency;
*/
private String referenceGenomeVersion; /**
* Amino acid change for corresponding protein.
/** */
* List of references connected to this variant. private String aminoAcidChange;
*/
private List<MiriamData> references = new ArrayList<>(); /**
* Gene variant id.
/** */
* Constructor that creates copy of the {@link GeneVariation}. private String variantIdentifier;
*
* @param original /**
* original {@link GeneVariation} * Reference genome type.
*/ */
protected GeneVariation(GeneVariation original) { private ReferenceGenomeType referenceGenomeType;
this.setPosition(original.getPosition());
this.setOriginalDna(original.getOriginalDna()); /**
this.setModifiedDna(original.getModifiedDna()); * Version of the reference genome.
this.setReferenceGenomeType(original.getReferenceGenomeType()); */
this.setReferenceGenomeVersion(original.getReferenceGenomeVersion()); private String referenceGenomeVersion;
this.addReferences(original.getReferences());
this.setContig(original.getContig()); /**
this.setAllelFrequency(original.getAllelFrequency()); * List of references connected to this variant.
this.setVariantIdentifier(original.getVariantIdentifier()); */
} private List<MiriamData> references = new ArrayList<>();
/** /**
* Default constructor. * Constructor that creates copy of the {@link GeneVariation}.
*/ *
public GeneVariation() { * @param original
} * original {@link GeneVariation}
*/
/** protected GeneVariation(GeneVariation original) {
* Adds references. this.setPosition(original.getPosition());
* this.setOriginalDna(original.getOriginalDna());
* @param references this.setModifiedDna(original.getModifiedDna());
* references to add this.setReferenceGenomeType(original.getReferenceGenomeType());
* @see #references this.setReferenceGenomeVersion(original.getReferenceGenomeVersion());
*/ this.addReferences(original.getReferences());
private void addReferences(Collection<MiriamData> references) { this.setContig(original.getContig());
for (MiriamData reference : references) { this.setAllelFrequency(original.getAllelFrequency());
addReference(reference); this.setVariantIdentifier(original.getVariantIdentifier());
} this.setAminoAcidChange(original.getAminoAcidChange());
} }
/** /**
* @return the position * Default constructor.
* @see #position */
*/ public GeneVariation() {
public Long getPosition() { }
return position;
} /**
* Adds references.
/** *
* @param position * @param references
* the position to set * references to add
* @see #position * @see #references
*/ */
public void setPosition(Long position) { private void addReferences(Collection<MiriamData> references) {
this.position = position; for (MiriamData reference : references) {
} addReference(reference);
}
/** }
* @return the originalDna
* @see #originalDna /**
*/ * @return the position
public String getOriginalDna() { * @see #position
return originalDna; */
} public Long getPosition() {
return position;
/** }
* @param originalDna
* the originalDna to set /**
* @see #originalDna * @param position
*/ * the position to set
public void setOriginalDna(String originalDna) { * @see #position
this.originalDna = originalDna; */
} public void setPosition(Long position) {
this.position = position;
/** }
* @return the modifiedDna
* @see #modifiedDna /**
*/ * @return the originalDna
public String getModifiedDna() { * @see #originalDna
return modifiedDna; */
} public String getOriginalDna() {
return originalDna;
/** }
* @param modifiedDna
* the modifiedDna to set /**
* @see #modifiedDna * @param originalDna
*/ * the originalDna to set
public void setModifiedDna(String modifiedDna) { * @see #originalDna
this.modifiedDna = modifiedDna; */
} public void setOriginalDna(String originalDna) {
this.originalDna = originalDna;
/** }
* @return the referenceGenomeType
* @see #referenceGenomeType /**
*/ * @return the modifiedDna
public ReferenceGenomeType getReferenceGenomeType() { * @see #modifiedDna
return referenceGenomeType; */
} public String getModifiedDna() {
return modifiedDna;
/** }
* @param referenceGenomeType
* the referenceGenomeType to set /**
* @see #referenceGenomeType * @param modifiedDna
*/ * the modifiedDna to set
public void setReferenceGenomeType(ReferenceGenomeType referenceGenomeType) { * @see #modifiedDna
this.referenceGenomeType = referenceGenomeType; */
} public void setModifiedDna(String modifiedDna) {
this.modifiedDna = modifiedDna;
/** }
* @return the references
* @see #references /**
*/ * @return the referenceGenomeType
public List<MiriamData> getReferences() { * @see #referenceGenomeType
return references; */
} public ReferenceGenomeType getReferenceGenomeType() {
return referenceGenomeType;
/** }
* @return the referenceGenomeVersion
* @see #referenceGenomeVersion /**
*/ * @param referenceGenomeType
public String getReferenceGenomeVersion() { * the referenceGenomeType to set
return referenceGenomeVersion; * @see #referenceGenomeType
} */
public void setReferenceGenomeType(ReferenceGenomeType referenceGenomeType) {
/** this.referenceGenomeType = referenceGenomeType;
* @param referenceGenomeVersion }
* the referenceGenomeVersion to set
* @see #referenceGenomeVersion /**
*/ * @return the references
public void setReferenceGenomeVersion(String referenceGenomeVersion) { * @see #references
this.referenceGenomeVersion = referenceGenomeVersion; */
} public List<MiriamData> getReferences() {
return references;
/** }
* Adds reference.
* /**
* @param reference * @return the referenceGenomeVersion
* reference to add * @see #referenceGenomeVersion
* @see #references */
*/ public String getReferenceGenomeVersion() {
public void addReference(MiriamData reference) { return referenceGenomeVersion;
this.references.add(reference); }
}
/**
/** * @param referenceGenomeVersion
* Creates copy of the object. * the referenceGenomeVersion to set
* * @see #referenceGenomeVersion
* @return copy of the object */
*/ public void setReferenceGenomeVersion(String referenceGenomeVersion) {
public GeneVariation copy() { this.referenceGenomeVersion = referenceGenomeVersion;
if (this.getClass().equals(GeneVariation.class)) { }
return new GeneVariation(this);
} else { /**
throw new NotImplementedException("Copy method not implemented for class: " + this.getClass()); * Adds reference.
} *
} * @param reference
* reference to add
/** * @see #references
* @return the contig */
* @see #contig public void addReference(MiriamData reference) {
*/ this.references.add(reference);
public String getContig() { }
return contig;
} /**
* Creates copy of the object.
/** *
* @param contig * @return copy of the object
* the contig to set */
* @see #contig public GeneVariation copy() {
*/ if (this.getClass().equals(GeneVariation.class)) {
public void setContig(String contig) { return new GeneVariation(this);
this.contig = contig; } else {
} throw new NotImplementedException("Copy method not implemented for class: " + this.getClass());
}
/** }
* Sets {@link #position}.
* /**
* @param position * @return the contig
* new position value * @see #contig
*/ */
public void setPosition(int position) { public String getContig() {
this.position = (long) position; return contig;
} }
/** /**
* @return the allelFrequency * @param contig
* @see #allelFrequency * the contig to set
*/ * @see #contig
public String getAllelFrequency() { */
return allelFrequency; public void setContig(String contig) {
} this.contig = contig;
}
/**
* @param allelFrequency /**
* the allelFrequency to set * Sets {@link #position}.
* @see #allelFrequency *
*/ * @param position
public void setAllelFrequency(String allelFrequency) { * new position value
this.allelFrequency = allelFrequency; */
} public void setPosition(int position) {
this.position = (long) position;
/** }
* @return the variantIdentifier
* @see #variantIdentifier /**
*/ * @return the allelFrequency
public String getVariantIdentifier() { * @see #allelFrequency
return variantIdentifier; */
} public String getAllelFrequency() {
return allelFrequency;
/** }
* @param variantIdentifier
* the variantIdentifier to set /**
* @see #variantIdentifier * @param allelFrequency
*/ * the allelFrequency to set
public void setVariantIdentifier(String variantIdentifier) { * @see #allelFrequency
this.variantIdentifier = variantIdentifier; */
} public void setAllelFrequency(String allelFrequency) {