Skip to content

Commit a11dcb6

Browse files
committed
Merge branch 'release-2.2.x'
2 parents 1b47117 + 1859250 commit a11dcb6

File tree

7 files changed

+57
-44
lines changed

7 files changed

+57
-44
lines changed

biodata-external/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>biodata</artifactId>
88
<groupId>org.opencb.biodata</groupId>
9-
<version>2.2.0</version>
9+
<version>2.2.1</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

biodata-formats/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.opencb.biodata</groupId>
2424
<artifactId>biodata</artifactId>
25-
<version>2.2.0</version>
25+
<version>2.2.1</version>
2626
<relativePath>../pom.xml</relativePath>
2727
</parent>
2828

biodata-formats/src/main/java/org/opencb/biodata/formats/variant/vcf4/FullVcfCodec.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,8 @@ public LazyGenotypesContext.LazyData createGenotypeMap(final String str,
203203
return new LazyGenotypesContext.LazyData(genotypes, header.getSampleNamesInOrder(), header.getSampleNameToOffset());
204204
}
205205

206+
public void setLineNumber(int lineNumber) {
207+
lineNo = lineNumber;
208+
}
209+
206210
}

biodata-models/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.opencb.biodata</groupId>
2424
<artifactId>biodata</artifactId>
25-
<version>2.2.0</version>
25+
<version>2.2.1</version>
2626
<relativePath>../pom.xml</relativePath>
2727
</parent>
2828

biodata-tools/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.opencb.biodata</groupId>
2424
<artifactId>biodata</artifactId>
25-
<version>2.2.0</version>
25+
<version>2.2.1</version>
2626
<relativePath>../pom.xml</relativePath>
2727
</parent>
2828

biodata-tools/src/main/java/org/opencb/biodata/tools/variant/normalizer/extensions/SvVariantNormalizerExtension.java

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -71,61 +71,70 @@ public void init() {
7171

7272
@Override
7373
protected boolean canUseExtension(VariantFileMetadata fileMetadata) {
74-
// canCalculateVaf is calculated in the init() method after checking the VCF header fields
75-
return SUPPORTED_SVTYPE_CALLERS.containsKey(caller) || SUPPORTED_SVLEN_CALLERS.containsKey(caller);
74+
// First, check if the caller is registered because it does not use standard names
75+
if (SUPPORTED_SVTYPE_CALLERS.containsKey(caller) || SUPPORTED_SVLEN_CALLERS.containsKey(caller)) {
76+
return true;
77+
}
78+
79+
// Second, if the VCF header contains standard SV info fields, in this case we always add EXT fields
80+
for (VariantFileHeaderComplexLine complexLine : fileMetadata.getHeader().getComplexLines()) {
81+
if (complexLine.getKey().equals("INFO")) {
82+
if (complexLine.getId().equals("SVTYPE") || complexLine.getId().equals("SVLEN")) {
83+
return true;
84+
}
85+
}
86+
}
87+
88+
return false;
7689
}
7790

7891
@Override
7992
protected void normalizeHeader(VariantFileMetadata fileMetadata) {
80-
if (SUPPORTED_SVTYPE_CALLERS.containsKey(caller)) {
81-
// Add EXT_SVTYPE
82-
VariantFileHeaderComplexLine newSampleMetadataLine = new VariantFileHeaderComplexLine( "INFO",
83-
EXT_SVTYPE,
84-
"Variant SVTYPE obtained from " + SUPPORTED_SVTYPE_CALLERS.get(caller)
85-
+ ", several variant callers supported. NOTE: this is a OpenCB extension field.",
86-
"1",
87-
"String",
88-
Collections.emptyMap());
89-
fileMetadata.getHeader().getComplexLines().add(newSampleMetadataLine);
90-
}
91-
92-
if (SUPPORTED_SVLEN_CALLERS.containsKey(caller)) {
93-
// Add EXT_SVLEN
94-
VariantFileHeaderComplexLine newSampleMetadataLine = new VariantFileHeaderComplexLine( "INFO",
95-
EXT_SVLEN,
96-
"Variant SVLEN obtained from " + SUPPORTED_SVLEN_CALLERS.get(caller)
97-
+ ", several variant callers supported. NOTE: this is a OpenCB extension field.",
98-
"1",
99-
"Integer",
100-
Collections.emptyMap());
101-
fileMetadata.getHeader().getComplexLines().add(newSampleMetadataLine);
102-
}
93+
// Add EXT_SVTYPE
94+
VariantFileHeaderComplexLine extSvtypeFileMetadataLine = new VariantFileHeaderComplexLine( "INFO",
95+
EXT_SVTYPE,
96+
"Variant SVTYPE obtained from " + SUPPORTED_SVTYPE_CALLERS.getOrDefault(caller, "SVTYPE")
97+
+ ", several variant callers supported. NOTE: this is a OpenCB extension field.",
98+
"1",
99+
"String",
100+
Collections.emptyMap());
101+
fileMetadata.getHeader().getComplexLines().add(extSvtypeFileMetadataLine);
102+
103+
// Add EXT_SVLEN
104+
VariantFileHeaderComplexLine extSvlenFileMetadataLine = new VariantFileHeaderComplexLine( "INFO",
105+
EXT_SVLEN,
106+
"Variant SVLEN obtained from " + SUPPORTED_SVLEN_CALLERS.getOrDefault(caller, "SVLEN")
107+
+ ", several variant callers supported. NOTE: this is a OpenCB extension field.",
108+
"1",
109+
"Integer",
110+
Collections.emptyMap());
111+
fileMetadata.getHeader().getComplexLines().add(extSvlenFileMetadataLine);
103112
}
104113

105114
@Override
106115
protected void normalizeFile(Variant variant, StudyEntry study, FileEntry file) {
107-
// Check if we can get SVTYPE from this caller
108-
if (SUPPORTED_SVTYPE_CALLERS.containsKey(caller)) {
109-
VariantType svtype = parseSvtype(file);
110-
// Check returned svtype, some variants could miss the svtype
111-
if (svtype != null) {
112-
study.addFileData(file.getFileId(), EXT_SVTYPE, svtype.name());
113-
}
116+
// GET SVTYPE and check value, some variants could miss the SVTYPE
117+
VariantType svtype = parseSvtype(file);
118+
if (svtype != null) {
119+
study.addFileData(file.getFileId(), EXT_SVTYPE, svtype.name());
114120
}
115121

116-
// Check if we can get SVLEN from this caller
117-
if (SUPPORTED_SVLEN_CALLERS.containsKey(caller)) {
118-
String svlen = file.getData().get(SUPPORTED_SVLEN_CALLERS.get(caller));
119-
// Check returned svlen, some variants could miss the svlen
120-
if (StringUtils.isNotEmpty(svlen)) {
122+
// Get SVLEN and check value, some variants could miss the SVLEN
123+
String svlen = file.getData().get(SUPPORTED_SVLEN_CALLERS.getOrDefault(caller, "SVLEN"));
124+
if (StringUtils.isNotEmpty(svlen)) {
125+
try {
126+
// Make sure SVLEN is a positive number
127+
int i = Math.abs(Integer.parseInt(svlen));
128+
study.addFileData(file.getFileId(), EXT_SVLEN, String.valueOf(i));
129+
} catch (NumberFormatException e) {
121130
study.addFileData(file.getFileId(), EXT_SVLEN, svlen);
122131
}
123132
}
124133
}
125134

126135
private VariantType parseSvtype(FileEntry file) {
127136
VariantType SVTYPE = null;
128-
String fileSvType = file.getData().get(SUPPORTED_SVTYPE_CALLERS.get(caller));
137+
String fileSvType = file.getData().get(SUPPORTED_SVTYPE_CALLERS.getOrDefault(caller, "SVTYPE"));
129138

130139
if (StringUtils.isNotEmpty(fileSvType)) {
131140
switch (fileSvType.toUpperCase()) {

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<groupId>org.opencb.biodata</groupId>
2222
<artifactId>biodata</artifactId>
23-
<version>2.2.0</version>
23+
<version>2.2.1</version>
2424
<packaging>pom</packaging>
2525

2626
<name>Biodata</name>
@@ -35,7 +35,7 @@
3535
</modules>
3636

3737
<properties>
38-
<biodata.version>2.2.0</biodata.version>
38+
<biodata.version>2.2.1</biodata.version>
3939
<commons.version>4.2.0</commons.version>
4040
<collections.version>4.4</collections.version>
4141
<avro.version>1.7.7</avro.version>

0 commit comments

Comments
 (0)