Commit a6e2c39a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

gene variant allel frequency support added

parent 8def8394
......@@ -41,6 +41,9 @@ public class GeneVariation implements Serializable {
*/
private String contig;
private String allelFrequency;
private String variantIdentifier;
/**
* Reference genome type.
*/
......@@ -70,6 +73,8 @@ public class GeneVariation implements Serializable {
this.setReferenceGenomeVersion(original.getReferenceGenomeVersion());
this.addReferences(original.getReferences());
this.setContig(original.getContig());
this.setAllelFrequency(original.getAllelFrequency());
this.setVariantIdentifier(original.getVariantIdentifier());
}
/**
......@@ -235,4 +240,38 @@ public class GeneVariation implements Serializable {
this.position = (long) position;
}
/**
* @return the allelFrequency
* @see #allelFrequency
*/
public String getAllelFrequency() {
return allelFrequency;
}
/**
* @param allelFrequency
* the allelFrequency to set
* @see #allelFrequency
*/
public void setAllelFrequency(String allelFrequency) {
this.allelFrequency = allelFrequency;
}
/**
* @return the variantIdentifier
* @see #variantIdentifier
*/
public String getVariantIdentifier() {
return variantIdentifier;
}
/**
* @param variantIdentifier
* the variantIdentifier to set
* @see #variantIdentifier
*/
public void setVariantIdentifier(String variantIdentifier) {
this.variantIdentifier = variantIdentifier;
}
}
......@@ -151,6 +151,8 @@ public class ColorSchemaReader {
Integer contigColumn = schemaColumns.get(ColorSchemaColumn.CONTIG);
Integer nameColumn = schemaColumns.get(ColorSchemaColumn.NAME);
Integer identifierColumn = schemaColumns.get(ColorSchemaColumn.IDENTIFIER);
Integer variantIdentifierColumn = schemaColumns.get(ColorSchemaColumn.VARIANT_IDENTIFIER);
Integer allelFrequencyColumn = schemaColumns.get(ColorSchemaColumn.ALLEL_FREQUENCY);
Integer compartmentColumn = schemaColumns.get(ColorSchemaColumn.COMPARTMENT);
Integer typeColumn = schemaColumns.get(ColorSchemaColumn.TYPE);
Integer positionColumn = schemaColumns.get(ColorSchemaColumn.POSITION);
......@@ -233,6 +235,12 @@ public class ColorSchemaReader {
if (originalDnaColumn != null) {
gv.setOriginalDna(values[originalDnaColumn]);
}
if (allelFrequencyColumn != null) {
gv.setAllelFrequency(values[allelFrequencyColumn]);
}
if (variantIdentifierColumn != null) {
gv.setVariantIdentifier(values[variantIdentifierColumn]);
}
if (alternativeDnaColumn != null) {
gv.setModifiedDna(values[alternativeDnaColumn]);
}
......
......@@ -97,6 +97,10 @@ public enum ColorSchemaColumn {
* Contig where variant was observed.
*/
CONTIG("contig", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), //
ALLEL_FREQUENCY("allel_frequency", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), //
VARIANT_IDENTIFIER("variant_identifier", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), //
/**
* Should the direction of reaction be reversed.
......
......@@ -99,6 +99,39 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
}
}
@Test
public void testReadGeneVariantsSchemaWithAF() throws Exception {
try {
File f = new File("testFiles/coloring/gene_variants_all_freq.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());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testReadInvalidGeneVariantsSchema() 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
10146 AC A DDX11L1 upstream #ff0000 chr1 0.8 identifier_1
10439 AC A DDX11L1;WASH7P upstream;downstream #ff0001 chr1 0.5 identifier_2
10441 AC A DDX11L1;WASH7P upstream;downstream #ff0001 chr1 0.2 identifier_3
10443 AC A DDX11L1;WASH7P upstream;downstream #ff0001 chr1 0.9 identifier_4
......@@ -5,6 +5,8 @@ function GeneVariant(javaObject) {
this.setReferenceGenomeType(javaObject.referenceGenomeType);
this.setReferenceGenomeVersion(javaObject.referenceGenomeVersion);
this.setContig(javaObject.contig);
this.setAllelFrequency(javaObject.allelFrequency);
this.setVariantIdentifier(javaObject.variantIdentifier);
};
GeneVariant.prototype.setPosition = function(position) {
......@@ -39,6 +41,22 @@ GeneVariant.prototype.getContig = function() {
return this._contig;
};
GeneVariant.prototype.setAllelFrequency = function(allelFrequency) {
this._allelFrequency = allelFrequency;
};
GeneVariant.prototype.getAllelFrequency = function() {
return this._allelFrequency;
};
GeneVariant.prototype.setVariantIdentifier = function(variantIdentifier) {
this._variantIdentifier = variantIdentifier;
};
GeneVariant.prototype.getVariantIdentifier = function() {
return this._variantIdentifier;
};
GeneVariant.prototype.setReferenceGenomeType = function(referenceGenomeType) {
this._referenceGenomeType = referenceGenomeType;
};
......
Supports Markdown
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