Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK-5318 - Implement custom annotator to allow clients private files #262

Merged
merged 8 commits into from
Sep 26, 2024

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.opencb.biodata.formats.variant.cosmic;

import org.opencb.biodata.models.sequence.SequenceLocation;
import org.opencb.biodata.models.variant.avro.EvidenceEntry;

import java.util.List;

public interface CosmicParserCallback {
boolean processEvidenceEntries(SequenceLocation sequenceLocation, List<EvidenceEntry> evidenceEntries);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.opencb.biodata.formats.variant.cosmic;

import org.junit.Assert;
import org.junit.Test;
import org.opencb.biodata.models.sequence.SequenceLocation;
import org.opencb.biodata.models.variant.avro.EvidenceEntry;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

public class CosmicParserTest {

// Implementation of the LineCallback function
public class MyCallback implements CosmicParserCallback {
private String msg;
private int counter;

public MyCallback(String msg) {
this.msg = msg;
this.counter = 0;
}

@Override
public boolean processEvidenceEntries(SequenceLocation sequenceLocation, List<EvidenceEntry> evidenceEntries) {
System.out.println(msg);
System.out.println("Sequence location = " + sequenceLocation);
System.out.println("Num. evidences = " + evidenceEntries.size());
for (EvidenceEntry evidenceEntry : evidenceEntries) {
System.out.println("evidences = " + evidenceEntry);
counter++;
}
return true;
}

public int getCounter() {
return counter;
}
}

@Test
public void testCosmicParser() throws IOException {
Path cosmicFile = Paths.get(getClass().getResource("/cosmic.small.tsv.gz").getPath());
String version = "v95";
String name = "cosmic";
String assembly = "GRCh38";

MyCallback callback = new MyCallback(">>> Testing message");

CosmicParser.parse(cosmicFile, version, name, assembly, callback);
Assert.assertEquals(90, callback.getCounter());
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* Copyright 2015-2020 OpenCB
*
* 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 org.opencb.biodata.models.common;

import org.opencb.commons.datastore.core.ObjectMap;

import java.util.ArrayList;
import java.util.List;

public class DataVersion {

private String data;
private String name;
private String version;
private String date;
private String species;
private String assembly;
private List<String> files;
private List<String> urls;
private ObjectMap attributes;

public DataVersion() {
files = new ArrayList<>();
urls = new ArrayList<>();
attributes = new ObjectMap();
}

public DataVersion(String data, String name, String version, String date, String species, String assembly, List<String> files,
List<String> urls, ObjectMap attributes) {
this.data = data;
this.name = name;
this.version = version;
this.date = date;
this.species = species;
this.assembly = assembly;
this.files = files;
this.urls = urls;
this.attributes = attributes;
}

public String getData() {
return data;
}

public DataVersion setData(String data) {
this.data = data;
return this;
}

public String getName() {
return name;
}

public DataVersion setName(String name) {
this.name = name;
return this;
}

public String getVersion() {
return version;
}

public DataVersion setVersion(String version) {
this.version = version;
return this;
}

public String getDate() {
return date;
}

public DataVersion setDate(String date) {
this.date = date;
return this;
}

public String getSpecies() {
return species;
}

public DataVersion setSpecies(String species) {
this.species = species;
return this;
}

public String getAssembly() {
return assembly;
}

public DataVersion setAssembly(String assembly) {
this.assembly = assembly;
return this;
}

public List<String> getFiles() {
return files;
}

public DataVersion setFiles(List<String> files) {
this.files = files;
return this;
}

public List<String> getUrls() {
return urls;
}

public DataVersion setUrls(List<String> urls) {
this.urls = urls;
return this;
}

public ObjectMap getAttributes() {
return attributes;
}

public DataVersion setAttributes(ObjectMap attributes) {
this.attributes = attributes;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.opencb.biodata.models.sequence;

public class SequenceLocation {
private String chromosome;
private int start;
private int end;
private String reference;
private String alternate;
private String strand;

public SequenceLocation() {
}

SequenceLocation(String chromosome, int start, int end, String reference, String alternate) {
this(chromosome, start, end, reference, alternate, "+");
}

SequenceLocation(String chromosome, int start, int end, String reference, String alternate, String strand) {
this.chromosome = chromosome;
this.start = start;
this.end = end;
this.reference = reference;
this.alternate = alternate;
this.strand = strand;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("SequenceLocation{");
sb.append("chromosome='").append(chromosome).append('\'');
sb.append(", start=").append(start);
sb.append(", end=").append(end);
sb.append(", reference='").append(reference).append('\'');
sb.append(", alternate='").append(alternate).append('\'');
sb.append(", strand='").append(strand).append('\'');
sb.append('}');
return sb.toString();
}

public String getChromosome() {
return chromosome;
}

public int getStart() {
return start;
}

public int getEnd() {
return end;
}

public String getReference() {
return reference;
}

public String getAlternate() {
return alternate;
}

public String getStrand() {
return strand;
}

public void setChromosome(String chromosome) {
this.chromosome = chromosome;
}

public void setStart(int start) {
this.start = start;
}

public void setEnd(int end) {
this.end = end;
}

public void setReference(String reference) {
this.reference = reference;
}

public void setAlternate(String alternate) {
this.alternate = alternate;
}

public void setStrand(String strand) {
this.strand = strand;
}
}
Loading