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
......@@ -373,7 +373,7 @@ public class PermanentDatabaseLevelCacheTest extends AnnotationTestFunctions {
cache.invalidateByQuery(query, type);
while (cache.getRefreshExecutingTasksSize() + cache.getRefreshPendingQueueSize() > 0) {
while (cache.refreshIsBusy()) {
Thread.sleep(10);
}
assertEquals(1, getErrors().size());
......@@ -491,7 +491,7 @@ public class PermanentDatabaseLevelCacheTest extends AnnotationTestFunctions {
while (cache.getRefreshExecutingTasksSize() + cache.getRefreshPendingQueueSize() > 0) {
Thread.sleep(10);
}
//errors are not caught
// errors are not caught
assertEquals(0, getErrors().size());
assertEquals(0, getFatals().size());
......
......@@ -9,7 +9,8 @@
* @param {string} javaObject.referenceGenomeType
* @param {string} javaObject.referenceGenomeVersion
* @param {string} javaObject.contig
* @param {null|number} [javaObject.allelFrequency]
* @param {string} [javaObject.aminoAcidChange]
* @param {null|string} [javaObject.allelFrequency]
* @param {null|string} [javaObject.variantIdentifier]
*
* @constructor
......@@ -23,8 +24,25 @@ function GeneVariant(javaObject) {
this.setContig(javaObject.contig);
this.setAllelFrequency(javaObject.allelFrequency);
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
......@@ -91,13 +109,13 @@ GeneVariant.prototype.getContig = function () {
/**
*
* @param {number} allelFrequency
* @param {string} allelFrequency
*/
GeneVariant.prototype.setAllelFrequency = function (allelFrequency) {
if (allelFrequency === null) {
this._allelFrequency = undefined;
} else {
this._allelFrequency = allelFrequency;
this._allelFrequency = parseFloat(allelFrequency);
}
};
......
......@@ -5,6 +5,7 @@ var assert = require('assert');
describe('GeneVariant', function () {
it("constructor", function () {
// noinspection SpellCheckingInspection
var data = {
position: 12,
originalDna: "A",
......@@ -13,7 +14,8 @@ describe('GeneVariant', function () {
referenceGenomeVersion: "v1",
contig: "1",
allelFrequency: "0.2",
variantIdentifier: "id"
variantIdentifier: "id",
aminoAcidChange: "LRRK2:NM_198578:exon1:c.T45C:p.T15T"
};
var variant = new GeneVariant(data);
assert.equal(variant.getPosition(), data.position);
......@@ -24,5 +26,6 @@ describe('GeneVariant', function () {
assert.equal(variant.getAllelFrequency(), data.allelFrequency);
assert.equal(variant.getVariantIdentifier(), data.variantIdentifier);
assert.equal(variant.getReferenceGenomeVersion(), data.referenceGenomeVersion);
assert.equal(variant.getAminoAcidChange(), data.aminoAcidChange);
});
});
......@@ -5,6 +5,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.log4j.Logger;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.map.MiriamData;
......@@ -16,6 +18,12 @@ import lcsb.mapviewer.model.map.MiriamData;
*/
public class GeneVariation implements Serializable {
/**
* Default class logger.
*/
@SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(GeneVariation.class);
/**
*
*/
......@@ -27,12 +35,12 @@ public class GeneVariation implements Serializable {
private Long position;
/**
* Original dna (from the reference genome).
* Original DNA (from the reference genome).
*/
private String originalDna;
/**
* Alternative dna (suggested by the variant).
* Alternative DNA (suggested by the variant).
*/
private String modifiedDna;
......@@ -41,7 +49,19 @@ public class GeneVariation implements Serializable {
*/
private String contig;
/**
* Allel frequency of the variant.
*/
private String allelFrequency;
/**
* Amino acid change for corresponding protein.
*/
private String aminoAcidChange;
/**
* Gene variant id.
*/
private String variantIdentifier;
/**
......@@ -75,6 +95,7 @@ public class GeneVariation implements Serializable {
this.setContig(original.getContig());
this.setAllelFrequency(original.getAllelFrequency());
this.setVariantIdentifier(original.getVariantIdentifier());
this.setAminoAcidChange(original.getAminoAcidChange());
}
/**
......@@ -274,4 +295,12 @@ public class GeneVariation implements Serializable {
this.variantIdentifier = variantIdentifier;
}
public String getAminoAcidChange() {
return aminoAcidChange;
}
public void setAminoAcidChange(String aminoAcidChange) {
this.aminoAcidChange = aminoAcidChange;
}
}
......@@ -8,6 +8,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
......@@ -18,6 +19,8 @@ import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import com.sun.xml.ws.policy.privateutil.PolicyUtils.Collections;
import lcsb.mapviewer.annotation.services.MiriamConnector;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.Pair;
......@@ -176,6 +179,7 @@ public class ColorSchemaReader {
Integer referencesColumn = schemaColumns.get(ColorSchemaColumn.REFERENCES);
Integer referenceGenomeTypeColumn = schemaColumns.get(ColorSchemaColumn.REFERENCE_GENOME_TYPE);
Integer referenceGenomeVersionColumn = schemaColumns.get(ColorSchemaColumn.REFERENCE_GENOME_VERSION);
Integer aminoAcidChangeColumn = schemaColumns.get(ColorSchemaColumn.AMINO_ACID_CHANGE);
if (nameColumn == null && identifierColumn == null && customIdentifiers.size() == 0) {
throw new InvalidColorSchemaException("One of these columns is obligatory: name, identifier");
}
......@@ -261,6 +265,9 @@ public class ColorSchemaReader {
if (alternativeDnaColumn != null) {
gv.setModifiedDna(values[alternativeDnaColumn]);
}
if (aminoAcidChangeColumn != null) {
gv.setAminoAcidChange(values[aminoAcidChangeColumn]);
}
if (referencesColumn != null) {
String[] references = values[referencesColumn].split(";");
for (String string : references) {
......@@ -691,7 +698,7 @@ public class ColorSchemaReader {
}
if (!found) {
if (acceptableIdentifiers.keySet().contains(columns[i].toLowerCase())) {
customIdentifiers.add(new Pair<MiriamType, Integer>(acceptableIdentifiers.get(columns[i].toLowerCase()), i));
customIdentifiers.add(new Pair<>(acceptableIdentifiers.get(columns[i].toLowerCase()), i));
} else {
String columnNames = "";
for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) {
......
......@@ -119,7 +119,12 @@ public enum ColorSchemaColumn {
/**
* Should the direction of reaction be reversed.
*/
REVERSE_REACTION("reverseReaction", new ColorSchemaType[] { ColorSchemaType.GENERIC }); //
REVERSE_REACTION("reverseReaction", new ColorSchemaType[] { ColorSchemaType.GENERIC }), //
/**
* Optional amino acid change in the variant.
*/
AMINO_ACID_CHANGE("amino_acid_change", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }); //
/**
* Default constructor that creates enum entry.
......
......@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.awt.Color;
......@@ -27,6 +28,8 @@ import lcsb.mapviewer.commands.ColorModelCommand;
import lcsb.mapviewer.common.TextFileUtils;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.layout.ColorSchema;
import lcsb.mapviewer.model.map.layout.GeneVariation;
import lcsb.mapviewer.model.map.layout.GeneVariationColorSchema;
import lcsb.mapviewer.model.map.layout.InvalidColorSchemaException;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.services.ServiceTestFunctions;
......@@ -102,6 +105,48 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
}
}
@Test
public void testReadGeneVariantsWithAminoAcidChange() throws Exception {
try {
File f = new File("testFiles/coloring/gene_variants_aa_change.txt");
InputStream in = new FileInputStream(f);
byte[] buff = new byte[8000];
int bytesRead = 0;
ByteArrayOutputStream bao = new ByteArrayOutputStream();
while ((bytesRead = in.read(buff)) != -1) {
bao.write(buff, 0, bytesRead);
}
in.close();
bao.close();
byte[] data = bao.toByteArray();
ByteArrayInputStream bin = new ByteArrayInputStream(data);
ColorSchemaReader reader = new ColorSchemaReader();
Collection<ColorSchema> schemas = reader.readColorSchema(bin,
TextFileUtils.getHeaderParametersFromFile(new ByteArrayInputStream(data)));
assertNotNull(schemas);
assertEquals(2, schemas.size());
GeneVariationColorSchema schema = (GeneVariationColorSchema) schemas.iterator().next();
boolean aaChangeFound = false;
for (GeneVariation geneVariant : schema.getGeneVariations()) {
if (geneVariant.getAminoAcidChange() != null && !geneVariant.getAminoAcidChange().trim().isEmpty()) {
aaChangeFound = true;
}
}
assertTrue("Amino acid are not present in parsed data", aaChangeFound);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testReadGeneVariantsWithNewNamingSchema() throws Exception {
try {
......
#TYPE=GENETIC_VARIANT
#GENOME_TYPE=UCSC
#GENOME_VERSION=hg38
position original_dna alternative_dna name description color contig allel_frequency variant_identifier amino_acid_change
10146 AC A DDX11L1 upstream #ff0000 chr1 0.8 identifier_1 LRRK2:NM_198578:exon1:c.T45C:p.T15T
10439 AC A DDX11L1;WASH7P upstream;downstream #ff0001 chr1 0.5 identifier_2 LRRK2:NM_198578:exon1:c.C67T:p.L23L
10441 AC A DDX11L1;WASH7P upstream;downstream #ff0001 chr1 0.2 identifier_3 frameshift_insertion
10443 AC A DDX11L1;WASH7P upstream;downstream #ff0001 chr1 0.9 identifier_4
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment