From f4f1d49ead2d431446691317ddd1fe31a060b9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Coll=20Morag=C3=B3n?= Date: Fri, 23 Sep 2022 17:56:55 +0100 Subject: [PATCH 1/2] tools: Remove apache-commons v3 usage. Exclude unused avro-ipc #TASK-2094 --- biodata-tools/pom.xml | 6 ++++++ .../tools/variant/stats/SampleVariantStatsCalculator.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/biodata-tools/pom.xml b/biodata-tools/pom.xml index 21f704d4..96c50350 100644 --- a/biodata-tools/pom.xml +++ b/biodata-tools/pom.xml @@ -42,6 +42,12 @@ org.opencb.ga4gh ga4gh 0.6.0a5 + + + org.apache.avro + avro-ipc + + diff --git a/biodata-tools/src/main/java/org/opencb/biodata/tools/variant/stats/SampleVariantStatsCalculator.java b/biodata-tools/src/main/java/org/opencb/biodata/tools/variant/stats/SampleVariantStatsCalculator.java index a877affb..ac6027c8 100644 --- a/biodata-tools/src/main/java/org/opencb/biodata/tools/variant/stats/SampleVariantStatsCalculator.java +++ b/biodata-tools/src/main/java/org/opencb/biodata/tools/variant/stats/SampleVariantStatsCalculator.java @@ -1,7 +1,7 @@ package org.opencb.biodata.tools.variant.stats; import htsjdk.variant.vcf.VCFConstants; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.opencb.biodata.models.clinical.pedigree.Member; From 4bde5db3619ca8144503c9058894ff0ef40f440c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Coll=20Morag=C3=B3n?= Date: Mon, 26 Sep 2022 22:11:50 +0100 Subject: [PATCH 2/2] tools: Remove usages of apache.commons.collections v3 #TASK-2094 --- .../org/opencb/biodata/tools/alignment/BamManager.java | 2 +- .../tools/clinical/DefaultClinicalVariantCreator.java | 4 ++-- .../tools/clinical/TeamClinicalVariantCreator.java | 4 ++-- .../opencb/biodata/tools/pedigree/ModeOfInheritance.java | 4 ++-- .../opencb/biodata/tools/variant/VariantJsonReader.java | 9 +++++++-- .../variant/metadata/VariantMetadataManagerTest.java | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/biodata-tools/src/main/java/org/opencb/biodata/tools/alignment/BamManager.java b/biodata-tools/src/main/java/org/opencb/biodata/tools/alignment/BamManager.java index a22e15ef..895767e9 100644 --- a/biodata-tools/src/main/java/org/opencb/biodata/tools/alignment/BamManager.java +++ b/biodata-tools/src/main/java/org/opencb/biodata/tools/alignment/BamManager.java @@ -27,7 +27,7 @@ import htsjdk.samtools.util.BlockCompressedFilePointerUtil; import htsjdk.samtools.util.BlockCompressedInputStream; import htsjdk.samtools.util.Log; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import org.ga4gh.models.ReadAlignment; import org.opencb.biodata.models.alignment.RegionCoverage; import org.opencb.biodata.models.core.Region; diff --git a/biodata-tools/src/main/java/org/opencb/biodata/tools/clinical/DefaultClinicalVariantCreator.java b/biodata-tools/src/main/java/org/opencb/biodata/tools/clinical/DefaultClinicalVariantCreator.java index d05506c6..a74bde2a 100644 --- a/biodata-tools/src/main/java/org/opencb/biodata/tools/clinical/DefaultClinicalVariantCreator.java +++ b/biodata-tools/src/main/java/org/opencb/biodata/tools/clinical/DefaultClinicalVariantCreator.java @@ -19,8 +19,8 @@ package org.opencb.biodata.tools.clinical; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.opencb.biodata.models.clinical.ClinicalDiscussion; import org.opencb.biodata.models.clinical.ClinicalProperty; import org.opencb.biodata.models.clinical.ClinicalProperty.ModeOfInheritance; diff --git a/biodata-tools/src/main/java/org/opencb/biodata/tools/clinical/TeamClinicalVariantCreator.java b/biodata-tools/src/main/java/org/opencb/biodata/tools/clinical/TeamClinicalVariantCreator.java index 06deeb38..71270a88 100644 --- a/biodata-tools/src/main/java/org/opencb/biodata/tools/clinical/TeamClinicalVariantCreator.java +++ b/biodata-tools/src/main/java/org/opencb/biodata/tools/clinical/TeamClinicalVariantCreator.java @@ -19,8 +19,8 @@ package org.opencb.biodata.tools.clinical; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.opencb.biodata.models.clinical.ClinicalDiscussion; import org.opencb.biodata.models.clinical.ClinicalProperty.ModeOfInheritance; import org.opencb.biodata.models.clinical.ClinicalProperty.Penetrance; diff --git a/biodata-tools/src/main/java/org/opencb/biodata/tools/pedigree/ModeOfInheritance.java b/biodata-tools/src/main/java/org/opencb/biodata/tools/pedigree/ModeOfInheritance.java index a1edbbec..590689a4 100644 --- a/biodata-tools/src/main/java/org/opencb/biodata/tools/pedigree/ModeOfInheritance.java +++ b/biodata-tools/src/main/java/org/opencb/biodata/tools/pedigree/ModeOfInheritance.java @@ -1,7 +1,7 @@ package org.opencb.biodata.tools.pedigree; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.opencb.biodata.models.clinical.ClinicalProperty.Penetrance; diff --git a/biodata-tools/src/main/java/org/opencb/biodata/tools/variant/VariantJsonReader.java b/biodata-tools/src/main/java/org/opencb/biodata/tools/variant/VariantJsonReader.java index 27397c65..83c37fe5 100644 --- a/biodata-tools/src/main/java/org/opencb/biodata/tools/variant/VariantJsonReader.java +++ b/biodata-tools/src/main/java/org/opencb/biodata/tools/variant/VariantJsonReader.java @@ -1,9 +1,9 @@ package org.opencb.biodata.tools.variant; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import org.mortbay.util.ajax.JSON; import org.opencb.biodata.formats.variant.io.VariantReader; import org.opencb.biodata.models.variant.Variant; import org.opencb.biodata.models.variant.VariantBuilder; @@ -109,7 +109,12 @@ public List read(int batchSize) { String line; int i = 0; while ((i < batchSize) && (line = readLine()) != null) { - Variant variant = new Variant(jsonObjectMapper.convertValue(JSON.parse(line), VariantAvro.class)); + Variant variant; + try { + variant = new Variant(jsonObjectMapper.readValue(line, VariantAvro.class)); + } catch (JsonProcessingException e) { + throw new UncheckedIOException(e); + } // Read variants may not have the variant type set and this might cause NPE if (variant.getType() == null) { diff --git a/biodata-tools/src/test/java/org/opencb/biodata/tools/variant/metadata/VariantMetadataManagerTest.java b/biodata-tools/src/test/java/org/opencb/biodata/tools/variant/metadata/VariantMetadataManagerTest.java index b89be271..eaf11dd5 100644 --- a/biodata-tools/src/test/java/org/opencb/biodata/tools/variant/metadata/VariantMetadataManagerTest.java +++ b/biodata-tools/src/test/java/org/opencb/biodata/tools/variant/metadata/VariantMetadataManagerTest.java @@ -1,6 +1,6 @@ package org.opencb.biodata.tools.variant.metadata; -import org.apache.commons.collections.map.HashedMap; +import org.apache.commons.collections4.map.HashedMap; import org.junit.Before; import org.junit.Test; import org.opencb.biodata.models.metadata.Individual;