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

Merge branch '832-genetic-variant-problem' into 'devel_13.1.x'

Resolve "MINERVANET - Error Report 75"

See merge request !799
parents 99862451 5d252147
minerva (12.3.1~beta.1) unstable; urgency=low
* Bug fix: invalid color in data overlay provides proper feedback to the user
(#822)
* Bug fix: genetic variant overlay without name caused problems (#832)
* Bug fix: tair locus identifiers were used improperly - instead of id the
name was used
* Bug fix: plugin tab header wasn't properly resized after adding plugins
......
......@@ -292,7 +292,7 @@ public class ColorSchemaReader {
gv.setContig(values[contigColumn]);
schema.addGeneVariation(gv);
if (schema.getName().contains(";")) {
if (schema.getName()!=null && schema.getName().contains(";")) {
String[] names = schema.getName().split(";");
for (String string : names) {
if (!string.trim().isEmpty()) {
......
......@@ -11,6 +11,8 @@ import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
......@@ -75,21 +77,27 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
public void testReadGeneVariantsSchema() throws Exception {
try {
File f = new File("testFiles/coloring/gene_variants.txt");
InputStream in = new FileInputStream(f);
byte[] data = fileToByteArray(f);
byte[] buff = new byte[8000];
int bytesRead = 0;
ByteArrayInputStream bin = new ByteArrayInputStream(data);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
ColorSchemaReader reader = new ColorSchemaReader();
while ((bytesRead = in.read(buff)) != -1) {
bao.write(buff, 0, bytesRead);
}
in.close();
bao.close();
Collection<ColorSchema> schemas = reader.readColorSchema(bin,
TextFileUtils.getHeaderParametersFromFile(new ByteArrayInputStream(data)));
assertNotNull(schemas);
assertEquals(3, schemas.size());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
byte[] data = bao.toByteArray();
@Test
public void testReadGeneVariantByIdSchema() throws Exception {
try {
File f = new File("testFiles/coloring/gene_variants_id.txt");
byte[] data = fileToByteArray(f);
ByteArrayInputStream bin = new ByteArrayInputStream(data);
......@@ -98,32 +106,37 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
Collection<ColorSchema> schemas = reader.readColorSchema(bin,
TextFileUtils.getHeaderParametersFromFile(new ByteArrayInputStream(data)));
assertNotNull(schemas);
assertEquals(3, schemas.size());
assertEquals(1, schemas.size());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testReadGeneVariantsWithAminoAcidChange() throws Exception {
try {
File f = new File("testFiles/coloring/gene_variants_aa_change.txt");
InputStream in = new FileInputStream(f);
private byte[] fileToByteArray(File f) throws FileNotFoundException, IOException {
InputStream in = new FileInputStream(f);
byte[] buff = new byte[8000];
byte[] buff = new byte[8000];
int bytesRead = 0;
int bytesRead = 0;
ByteArrayOutputStream bao = new ByteArrayOutputStream();
ByteArrayOutputStream bao = new ByteArrayOutputStream();
while ((bytesRead = in.read(buff)) != -1) {
bao.write(buff, 0, bytesRead);
}
in.close();
bao.close();
while ((bytesRead = in.read(buff)) != -1) {
bao.write(buff, 0, bytesRead);
}
in.close();
bao.close();
byte[] data = bao.toByteArray();
byte[] data = bao.toByteArray();
return data;
}
@Test
public void testReadGeneVariantsWithAminoAcidChange() throws Exception {
try {
File f = new File("testFiles/coloring/gene_variants_aa_change.txt");
byte[] data = fileToByteArray(f);
ByteArrayInputStream bin = new ByteArrayInputStream(data);
......@@ -151,21 +164,7 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
public void testReadGeneVariantsWithNewNamingSchema() throws Exception {
try {
File f = new File("testFiles/coloring/gene_variants_new_naming.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();
byte[] data = fileToByteArray(f);
ByteArrayInputStream bin = new ByteArrayInputStream(data);
......@@ -185,21 +184,7 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
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();
byte[] data = fileToByteArray(f);
ByteArrayInputStream bin = new ByteArrayInputStream(data);
......
#TYPE=GENETIC_VARIANT
#GENOME_TYPE=UCSC
#GENOME_VERSION=hg38
position original_dna alternative_dna Entrez gene description color contig
10146 AC A 123456 upstream #ff0000 chr1
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