diff --git a/src/main/java/uk/ac/ebi/eva/contigalias/datasource/ENAAssemblyDataSource.java b/src/main/java/uk/ac/ebi/eva/contigalias/datasource/ENAAssemblyDataSource.java index 5279357a..80d8bdf7 100644 --- a/src/main/java/uk/ac/ebi/eva/contigalias/datasource/ENAAssemblyDataSource.java +++ b/src/main/java/uk/ac/ebi/eva/contigalias/datasource/ENAAssemblyDataSource.java @@ -25,7 +25,6 @@ import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Repository; import uk.ac.ebi.eva.contigalias.dus.ENAAssemblyReportReader; -import uk.ac.ebi.eva.contigalias.dus.ENAAssemblyReportReaderFactory; import uk.ac.ebi.eva.contigalias.dus.ENABrowser; import uk.ac.ebi.eva.contigalias.dus.ENABrowserFactory; import uk.ac.ebi.eva.contigalias.entities.ChromosomeEntity; @@ -34,7 +33,6 @@ import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -45,16 +43,12 @@ public class ENAAssemblyDataSource { private final ENABrowserFactory factory; - private final ENAAssemblyReportReaderFactory readerFactory; - @Value("${asm.file.download.dir}") private String asmFileDownloadDir; @Autowired - public ENAAssemblyDataSource(ENABrowserFactory factory, - ENAAssemblyReportReaderFactory readerFactory) { + public ENAAssemblyDataSource(ENABrowserFactory factory) { this.factory = factory; - this.readerFactory = readerFactory; } public Optional downloadAssemblyReport(String accession) throws IOException { @@ -97,14 +91,7 @@ public Optional downloadAssemblyReport(ENABrowser enaBrowser, String acces } public List getChromosomeEntityList(List chrDataList) { - List chromosomeEntityList = new ArrayList<>(); - for (String chrData : chrDataList) { - ChromosomeEntity chromosomeEntity = getChromosomeEntity(chrData); - if (chromosomeEntity != null) { - chromosomeEntityList.add(chromosomeEntity); - } - } - return chromosomeEntityList; + return ENAAssemblyReportReader.getChromosomeEntity(chrDataList); } public ChromosomeEntity getChromosomeEntity(String chrLine) { diff --git a/src/main/java/uk/ac/ebi/eva/contigalias/datasource/NCBIAssemblyDataSource.java b/src/main/java/uk/ac/ebi/eva/contigalias/datasource/NCBIAssemblyDataSource.java index 0e7046f0..2ef26d09 100644 --- a/src/main/java/uk/ac/ebi/eva/contigalias/datasource/NCBIAssemblyDataSource.java +++ b/src/main/java/uk/ac/ebi/eva/contigalias/datasource/NCBIAssemblyDataSource.java @@ -25,7 +25,6 @@ import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Repository; import uk.ac.ebi.eva.contigalias.dus.NCBIAssemblyReportReader; -import uk.ac.ebi.eva.contigalias.dus.NCBIAssemblyReportReaderFactory; import uk.ac.ebi.eva.contigalias.dus.NCBIBrowser; import uk.ac.ebi.eva.contigalias.dus.NCBIBrowserFactory; import uk.ac.ebi.eva.contigalias.entities.AssemblyEntity; @@ -35,7 +34,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -47,16 +45,12 @@ public class NCBIAssemblyDataSource { private final NCBIBrowserFactory factory; - private final NCBIAssemblyReportReaderFactory readerFactory; - @Value("${asm.file.download.dir}") private String asmFileDownloadDir; @Autowired - public NCBIAssemblyDataSource(NCBIBrowserFactory factory, - NCBIAssemblyReportReaderFactory readerFactory) { + public NCBIAssemblyDataSource(NCBIBrowserFactory factory) { this.factory = factory; - this.readerFactory = readerFactory; } public AssemblyEntity getAssemblyEntity(Path downloadFilePath) throws IOException { @@ -71,13 +65,8 @@ public AssemblyEntity getAssemblyEntity(List asmDataLines) { } public List getChromosomeEntityList(AssemblyEntity assemblyEntity, List chrDataList) { - List chromosomeEntityList = new ArrayList<>(); - for (String chrData : chrDataList) { - ChromosomeEntity chromosomeEntity = getChromosomeEntity(assemblyEntity, chrData); - if (chromosomeEntity != null) { - chromosomeEntityList.add(chromosomeEntity); - } - } + List chromosomeEntityList = NCBIAssemblyReportReader.getChromosomeEntity(chrDataList); + chromosomeEntityList.stream().forEach(c -> c.setAssembly(assemblyEntity)); return chromosomeEntityList; } diff --git a/src/main/java/uk/ac/ebi/eva/contigalias/dus/ENAAssemblyReportReader.java b/src/main/java/uk/ac/ebi/eva/contigalias/dus/ENAAssemblyReportReader.java index 3e857885..96512f98 100644 --- a/src/main/java/uk/ac/ebi/eva/contigalias/dus/ENAAssemblyReportReader.java +++ b/src/main/java/uk/ac/ebi/eva/contigalias/dus/ENAAssemblyReportReader.java @@ -16,90 +16,24 @@ package uk.ac.ebi.eva.contigalias.dus; -import uk.ac.ebi.eva.contigalias.entities.AssemblyEntity; import uk.ac.ebi.eva.contigalias.entities.ChromosomeEntity; import uk.ac.ebi.eva.contigalias.entities.SequenceEntity; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; -public class ENAAssemblyReportReader extends AssemblyReportReader { +public class ENAAssemblyReportReader { - public ENAAssemblyReportReader(InputStreamReader inputStreamReader, boolean isScaffoldsEnabled) { - super(inputStreamReader, isScaffoldsEnabled); - } - - protected void parseReport() throws IOException, NullPointerException { - if (reader == null) { - throw new NullPointerException("Cannot use AssemblyReportReader without having a valid InputStreamReader."); - } - String line = reader.readLine(); - while (line != null) { - if (line.startsWith("accession")) { - if (assemblyEntity == null) { - assemblyEntity = new AssemblyEntity(); - } - parseAssemblyData(line); - } else if (!line.startsWith("accession")) { - String[] columns = line.split("\t", -1); - if (columns.length >= 6) { - if (columns[5].equals("Chromosome") && columns[3].equals("assembled-molecule")) { - parseChromosomeLine(columns); - } else if (isScaffoldsEnabled) { - parseScaffoldLine(columns); - } - } + public static List getChromosomeEntity(List lines) { + List chromosomeEntityList = new ArrayList<>(); + for (String line : lines) { + ChromosomeEntity chromosomeEntity = getChromosomeEntity(line); + if (chromosomeEntity != null) { + chromosomeEntityList.add(chromosomeEntity); } - line = reader.readLine(); - } - reportParsed = true; - reader.close(); - } - - // Not present in ENA assembly reports - protected void parseAssemblyData(String line) { - } - - protected void parseChromosomeLine(String[] columns) { - ChromosomeEntity chromosomeEntity = getChromosome(columns); - if (chromosomeEntity == null) { - return; - } - - if (assemblyEntity == null) { - assemblyEntity = new AssemblyEntity(); - } - chromosomeEntity.setAssembly(this.assemblyEntity); - chromosomeEntity.setContigType(SequenceEntity.ContigType.CHROMOSOME); - - List chromosomes = this.assemblyEntity.getChromosomes(); - if (chromosomes == null) { - chromosomes = new LinkedList<>(); - assemblyEntity.setChromosomes(chromosomes); } - chromosomes.add(chromosomeEntity); - } - protected void parseScaffoldLine(String[] columns) { - ChromosomeEntity scaffoldEntity = getScaffold(columns); - if (scaffoldEntity == null) { - return; - } - - if (assemblyEntity == null) { - assemblyEntity = new AssemblyEntity(); - } - scaffoldEntity.setAssembly(this.assemblyEntity); - scaffoldEntity.setContigType(SequenceEntity.ContigType.SCAFFOLD); - - List scaffolds = this.assemblyEntity.getChromosomes(); - if (scaffolds == null) { - scaffolds = new LinkedList<>(); - assemblyEntity.setChromosomes(scaffolds); - } - scaffolds.add(scaffoldEntity); + return chromosomeEntityList; } public static ChromosomeEntity getChromosomeEntity(String line) { diff --git a/src/main/java/uk/ac/ebi/eva/contigalias/dus/ENAAssemblyReportReaderFactory.java b/src/main/java/uk/ac/ebi/eva/contigalias/dus/ENAAssemblyReportReaderFactory.java deleted file mode 100644 index f6d608ae..00000000 --- a/src/main/java/uk/ac/ebi/eva/contigalias/dus/ENAAssemblyReportReaderFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2021 EMBL - European Bioinformatics Institute - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package uk.ac.ebi.eva.contigalias.dus; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import java.io.InputStream; -import java.io.InputStreamReader; - -@Component -public class ENAAssemblyReportReaderFactory { - - @Value("${config.scaffolds.enabled:false}") - private boolean SCAFFOLDS_ENABLED; - - public ENAAssemblyReportReader build(InputStream inputStream) { - return new ENAAssemblyReportReader(new InputStreamReader(inputStream), SCAFFOLDS_ENABLED); - } - - public ENAAssemblyReportReader build(InputStreamReader inputStreamReader) { - return new ENAAssemblyReportReader(inputStreamReader, SCAFFOLDS_ENABLED); - } - -} diff --git a/src/main/java/uk/ac/ebi/eva/contigalias/dus/NCBIAssemblyReportReader.java b/src/main/java/uk/ac/ebi/eva/contigalias/dus/NCBIAssemblyReportReader.java index 28417ab7..fcf99462 100644 --- a/src/main/java/uk/ac/ebi/eva/contigalias/dus/NCBIAssemblyReportReader.java +++ b/src/main/java/uk/ac/ebi/eva/contigalias/dus/NCBIAssemblyReportReader.java @@ -20,119 +20,12 @@ import uk.ac.ebi.eva.contigalias.entities.ChromosomeEntity; import uk.ac.ebi.eva.contigalias.entities.SequenceEntity; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -public class NCBIAssemblyReportReader extends AssemblyReportReader { - - public NCBIAssemblyReportReader(InputStreamReader inputStreamReader, boolean isScaffoldsEnabled) { - super(inputStreamReader, isScaffoldsEnabled); - } - - protected void parseReport() throws IOException, NullPointerException { - if (reader == null) { - throw new NullPointerException("Cannot use AssemblyReportReader without having a valid InputStreamReader."); - } - String line = reader.readLine(); - while (line != null) { - if (line.startsWith("# ")) { - if (assemblyEntity == null) { - assemblyEntity = new AssemblyEntity(); - } - parseAssemblyData(line); - } else if (!line.startsWith("#")) { - String[] columns = line.split("\t", -1); - if (columns.length >= 6 && (columns[5].equals("=") || columns[5].equals("<>")) && - (columns[4] != null && !columns[4].isEmpty() && !columns[4].equals("na"))) { - if (columns[3].equals("Chromosome") && columns[1].equals("assembled-molecule")) { - parseChromosomeLine(columns); - } else if (isScaffoldsEnabled) { - parseScaffoldLine(columns); - } - } - } - line = reader.readLine(); - } - reportParsed = true; - reader.close(); - } - - protected void parseAssemblyData(String line) { - int tagEnd = line.indexOf(':'); - if (tagEnd == -1) { - return; - } - String tag = line.substring(2, tagEnd); - String tagData = line.substring(tagEnd + 1).trim(); - switch (tag) { - case "Assembly name": { - assemblyEntity.setName(tagData); - break; - } - case "Organism name": { - assemblyEntity.setOrganism(tagData); - break; - } - case "Taxid": { - assemblyEntity.setTaxid(Long.parseLong(tagData)); - break; - } - case "GenBank assembly accession": { - assemblyEntity.setInsdcAccession(tagData); - break; - } - case "RefSeq assembly accession": { - assemblyEntity.setRefseq(tagData); - break; - } - case "RefSeq assembly and GenBank assemblies identical": { - assemblyEntity.setGenbankRefseqIdentical(tagData.equals("yes")); - break; - } - } - } - - protected void parseChromosomeLine(String[] columns) { - ChromosomeEntity chromosomeEntity = getChromosome(columns); - if (chromosomeEntity == null) { - return; - } - - if (assemblyEntity == null) { - assemblyEntity = new AssemblyEntity(); - } - chromosomeEntity.setAssembly(this.assemblyEntity); - - List chromosomes = this.assemblyEntity.getChromosomes(); - if (chromosomes == null) { - chromosomes = new LinkedList<>(); - assemblyEntity.setChromosomes(chromosomes); - } - chromosomes.add(chromosomeEntity); - } - - protected void parseScaffoldLine(String[] columns) { - ChromosomeEntity scaffoldEntity = getScaffold(columns); - if (scaffoldEntity == null) { - return; - } - - if (assemblyEntity == null) { - assemblyEntity = new AssemblyEntity(); - } - scaffoldEntity.setAssembly(this.assemblyEntity); - - List scaffolds = this.assemblyEntity.getChromosomes(); - if (scaffolds == null) { - scaffolds = new LinkedList<>(); - assemblyEntity.setChromosomes(scaffolds); - } - scaffolds.add(scaffoldEntity); - } +public class NCBIAssemblyReportReader { public static AssemblyEntity getAssemblyEntity(List lines) { Map tagAndValuesMap = lines.stream() @@ -175,6 +68,17 @@ public static AssemblyEntity getAssemblyEntity(List lines) { return asmEntity; } + public static List getChromosomeEntity(List lines) { + List chromosomeEntityList = new ArrayList<>(); + for (String line : lines) { + ChromosomeEntity chromosomeEntity = getChromosomeEntity(line); + if (chromosomeEntity != null) { + chromosomeEntityList.add(chromosomeEntity); + } + } + return chromosomeEntityList; + } + public static ChromosomeEntity getChromosomeEntity(String line) { String[] columns = line.split("\t", -1); if (columns.length >= 6 && (columns[5].equals("=") || columns[5].equals("<>")) && diff --git a/src/main/java/uk/ac/ebi/eva/contigalias/dus/NCBIAssemblyReportReaderFactory.java b/src/main/java/uk/ac/ebi/eva/contigalias/dus/NCBIAssemblyReportReaderFactory.java deleted file mode 100644 index 6dfb49a8..00000000 --- a/src/main/java/uk/ac/ebi/eva/contigalias/dus/NCBIAssemblyReportReaderFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2020 EMBL - European Bioinformatics Institute - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package uk.ac.ebi.eva.contigalias.dus; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import java.io.InputStream; -import java.io.InputStreamReader; - -@Component -public class NCBIAssemblyReportReaderFactory { - - @Value("${config.scaffolds.enabled:false}") - private boolean SCAFFOLDS_ENABLED; - - public NCBIAssemblyReportReader build(InputStream inputStream) { - return new NCBIAssemblyReportReader(new InputStreamReader(inputStream), SCAFFOLDS_ENABLED); - } - - public NCBIAssemblyReportReader build(InputStreamReader inputStreamReader) { - return new NCBIAssemblyReportReader(inputStreamReader, SCAFFOLDS_ENABLED); - } - -} diff --git a/src/test/java/uk/ac/ebi/eva/contigalias/dus/ENAAssemblyReportReaderTest.java b/src/test/java/uk/ac/ebi/eva/contigalias/dus/ENAAssemblyReportReaderTest.java index 2276c1c9..5d5d71c0 100644 --- a/src/test/java/uk/ac/ebi/eva/contigalias/dus/ENAAssemblyReportReaderTest.java +++ b/src/test/java/uk/ac/ebi/eva/contigalias/dus/ENAAssemblyReportReaderTest.java @@ -16,22 +16,16 @@ package uk.ac.ebi.eva.contigalias.dus; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; - -import uk.ac.ebi.eva.contigalias.entities.AssemblyEntity; import uk.ac.ebi.eva.contigalias.entities.ChromosomeEntity; import uk.ac.ebi.eva.contigalias.entities.SequenceEntity; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.List; import java.util.stream.Collectors; @@ -52,49 +46,23 @@ class ENAAssemblyReportReaderTest { private static final String SCAFFOLD_GENBANK_ACCESSION = "GJ057137.1"; - private InputStreamReader streamReader; - - private InputStream stream; - - @Autowired - private ENAAssemblyReportReaderFactory readerFactory; - - private ENAAssemblyReportReader reader; - - @BeforeEach - void setup() throws FileNotFoundException { - stream = new FileInputStream("src/test/resources/GCA_000003055.3_sequence_report.txt"); - streamReader = new InputStreamReader(stream); - reader = readerFactory.build(streamReader); - } - - @AfterEach - void tearDown() throws IOException { - stream.close(); - streamReader.close(); - } - - @Test - void getAssemblyReportReader() throws IOException { - assertTrue(reader.ready()); - } + private static final Path assemblyReportPath = Paths.get("src/test/resources/GCA_000003055.3_sequence_report.txt"); - AssemblyEntity getAssemblyEntity() throws IOException { - return reader.getAssemblyEntity(); + List getChromosomes() throws IOException { + List lines = Files.lines(assemblyReportPath).collect(Collectors.toList()); + return ENAAssemblyReportReader.getChromosomeEntity(lines); } @Test void verifyAssemblyHasChromosomes() throws IOException { - AssemblyEntity assembly = getAssemblyEntity(); - List chromosomes = assembly.getChromosomes(); + List chromosomes = getChromosomes(); assertNotNull(chromosomes); assertEquals(3316, chromosomes.size()); } @Test void verifyChromosomeMetadata() throws IOException { - AssemblyEntity assembly = getAssemblyEntity(); - List chromosomes = assembly.getChromosomes(); + List chromosomes = getChromosomes(); ChromosomeEntity chromosome = chromosomes.get(0); assertEquals(CHROMOSOME_ENA_SEQUENCE_NAME, chromosome.getEnaSequenceName()); assertEquals(CHROMOSOME_GENBANK_ACCESSION, chromosome.getInsdcAccession()); @@ -103,8 +71,7 @@ void verifyChromosomeMetadata() throws IOException { @Test void verifyAssemblyHasScaffolds() throws IOException { - AssemblyEntity assembly = getAssemblyEntity(); - List scaffolds = assembly.getChromosomes().stream() + List scaffolds = getChromosomes().stream() .filter(e -> e.getContigType().equals(SequenceEntity.ContigType.SCAFFOLD)).collect(Collectors.toList()); assertNotNull(scaffolds); assertEquals(3286, scaffolds.size()); @@ -112,8 +79,7 @@ void verifyAssemblyHasScaffolds() throws IOException { @Test void assertParsedScaffoldValid() throws IOException { - AssemblyEntity assembly = getAssemblyEntity(); - List scaffolds = assembly.getChromosomes().stream() + List scaffolds = getChromosomes().stream() .filter(e -> e.getContigType().equals(SequenceEntity.ContigType.SCAFFOLD)).collect(Collectors.toList()); assertNotNull(scaffolds); assertTrue(scaffolds.size() > 0); diff --git a/src/test/java/uk/ac/ebi/eva/contigalias/dus/NCBIAssemblyReportReaderTest.java b/src/test/java/uk/ac/ebi/eva/contigalias/dus/NCBIAssemblyReportReaderTest.java index 9107baeb..ed32c95c 100644 --- a/src/test/java/uk/ac/ebi/eva/contigalias/dus/NCBIAssemblyReportReaderTest.java +++ b/src/test/java/uk/ac/ebi/eva/contigalias/dus/NCBIAssemblyReportReaderTest.java @@ -16,23 +16,18 @@ package uk.ac.ebi.eva.contigalias.dus; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; - import uk.ac.ebi.eva.contigalias.entities.AssemblyEntity; import uk.ac.ebi.eva.contigalias.entities.ChromosomeEntity; import uk.ac.ebi.eva.contigalias.entities.SequenceEntity; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.List; import java.util.stream.Collectors; @@ -65,23 +60,11 @@ class NCBIAssemblyReportReaderTest { private static final Long CHROMOSOME_CHR1_SEQ_LENGTH = 158337067l; + private static final Path assemblyReportPath = Paths.get("src/test/resources/GCA_000003055.3_Bos_taurus_UMD_3.1_assembly_report.txt"); private ChromosomeEntity scaffoldEntity; - private InputStreamReader streamReader; - - private InputStream stream; - - @Autowired - private NCBIAssemblyReportReaderFactory readerFactory; - - private NCBIAssemblyReportReader reader; - @BeforeEach - void setup() throws FileNotFoundException { - stream = new FileInputStream( - new File("src/test/resources/GCA_000003055.3_Bos_taurus_UMD_3.1_assembly_report.txt")); - streamReader = new InputStreamReader(stream); - reader = readerFactory.build(streamReader); + void setup() { scaffoldEntity = (ChromosomeEntity) new ChromosomeEntity() .setGenbankSequenceName("ChrU_1") .setInsdcAccession("GJ057137.1") @@ -90,19 +73,18 @@ void setup() throws FileNotFoundException { .setUcscName(null); } - @AfterEach - void tearDown() throws IOException { - stream.close(); - streamReader.close(); - } - - @Test - void getAssemblyReportReader() throws IOException { - assertTrue(reader.ready()); + AssemblyEntity getAssemblyEntity() throws IOException { + List asmDataLines = Files.lines(assemblyReportPath) + .filter(line -> line.startsWith("#")) + .collect(Collectors.toList()); + return NCBIAssemblyReportReader.getAssemblyEntity(asmDataLines); } - AssemblyEntity getAssemblyEntity() throws IOException { - return reader.getAssemblyEntity(); + List getChromosomes() throws IOException { + List chrDataLines = Files.lines(assemblyReportPath) + .filter(line -> !line.startsWith("#")) + .collect(Collectors.toList()); + return NCBIAssemblyReportReader.getChromosomeEntity(chrDataLines); } @Test @@ -118,16 +100,14 @@ void verifyAssemblyMetadata() throws IOException { @Test void verifyAssemblyHasChromosomes() throws IOException { - AssemblyEntity assembly = getAssemblyEntity(); - List chromosomes = assembly.getChromosomes(); + List chromosomes = getChromosomes(); assertNotNull(chromosomes); assertEquals(3316, chromosomes.size()); } @Test void verifyChromosomeMetadata() throws IOException { - AssemblyEntity assembly = getAssemblyEntity(); - List chromosomes = assembly.getChromosomes(); + List chromosomes = getChromosomes(); ChromosomeEntity chromosome = chromosomes.get(0); assertEquals(CHROMOSOME_CHR1_SEQUENCE_NAME, chromosome.getGenbankSequenceName()); assertEquals(CHROMOSOME_CHR1_GENBANK_ACCESSION, chromosome.getInsdcAccession()); @@ -138,8 +118,7 @@ void verifyChromosomeMetadata() throws IOException { @Test void verifyAssemblyHasScaffolds() throws IOException { - AssemblyEntity assembly = getAssemblyEntity(); - List scaffolds = assembly.getChromosomes().stream() + List scaffolds = getChromosomes().stream() .filter(e -> e.getContigType().equals(SequenceEntity.ContigType.SCAFFOLD)).collect(Collectors.toList()); assertNotNull(scaffolds); assertEquals(3286, scaffolds.size()); @@ -147,8 +126,7 @@ void verifyAssemblyHasScaffolds() throws IOException { @Test void assertParsedScaffoldValid() throws IOException { - AssemblyEntity assembly = getAssemblyEntity(); - List scaffolds = assembly.getChromosomes().stream() + List scaffolds = getChromosomes().stream() .filter(e -> e.getContigType().equals(SequenceEntity.ContigType.SCAFFOLD)).collect(Collectors.toList()); assertNotNull(scaffolds); assertTrue(scaffolds.size() > 0);