added the ability to pass in a csv file of ROD triplets (one triplet per line) to the -B option
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1412 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
e4acd14675
commit
d101c20b30
|
|
@ -186,7 +186,7 @@ public class GenomeAnalysisEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse out the rod bindings
|
// parse out the rod bindings
|
||||||
ReferenceOrderedData.parseBindings(logger, argCollection.RODBindings, rods);
|
ReferenceOrderedData.parseBindings(argCollection.RODBindings, rods);
|
||||||
|
|
||||||
validateSuppliedReferenceOrderedDataAgainstWalker( my_walker, rods );
|
validateSuppliedReferenceOrderedDataAgainstWalker( my_walker, rods );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,11 @@ package org.broadinstitute.sting.gatk.refdata;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.broadinstitute.sting.utils.MalformedGenomeLocException;
|
import org.broadinstitute.sting.utils.MalformedGenomeLocException;
|
||||||
|
import org.broadinstitute.sting.utils.StingException;
|
||||||
import org.broadinstitute.sting.utils.Utils;
|
import org.broadinstitute.sting.utils.Utils;
|
||||||
import org.broadinstitute.sting.utils.xReadLines;
|
import org.broadinstitute.sting.utils.xReadLines;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
@ -16,7 +14,7 @@ import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for representing arbitrary reference ordered data sets
|
* Class for representing arbitrary reference ordered data sets
|
||||||
*
|
* <p/>
|
||||||
* User: mdepristo
|
* User: mdepristo
|
||||||
* Date: Feb 27, 2009
|
* Date: Feb 27, 2009
|
||||||
* Time: 10:47:14 AM
|
* Time: 10:47:14 AM
|
||||||
|
|
@ -27,13 +25,15 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
private File file = null;
|
private File file = null;
|
||||||
private String fieldDelimiter;
|
private String fieldDelimiter;
|
||||||
|
|
||||||
/**
|
/** Header object returned from the datum */
|
||||||
* Header object returned from the datum
|
|
||||||
*/
|
|
||||||
private Object header = null;
|
private Object header = null;
|
||||||
|
|
||||||
private Class<ROD> type = null; // runtime type information for object construction
|
private Class<ROD> type = null; // runtime type information for object construction
|
||||||
|
|
||||||
|
/** our log, which we want to capture anything from this class */
|
||||||
|
private static Logger logger = Logger.getLogger(ReferenceOrderedData.class);
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Static ROD type management
|
// Static ROD type management
|
||||||
|
|
@ -42,6 +42,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
public static class RODBinding {
|
public static class RODBinding {
|
||||||
public final String name;
|
public final String name;
|
||||||
public final Class<? extends ReferenceOrderedDatum> type;
|
public final Class<? extends ReferenceOrderedDatum> type;
|
||||||
|
|
||||||
public RODBinding(final String name, final Class<? extends ReferenceOrderedDatum> type) {
|
public RODBinding(final String name, final Class<? extends ReferenceOrderedDatum> type) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
@ -49,9 +50,10 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, RODBinding> Types = new HashMap<String, RODBinding>();
|
public static HashMap<String, RODBinding> Types = new HashMap<String, RODBinding>();
|
||||||
|
|
||||||
public static void addModule(final String name, final Class<? extends ReferenceOrderedDatum> rodType) {
|
public static void addModule(final String name, final Class<? extends ReferenceOrderedDatum> rodType) {
|
||||||
final String boundName = name.toLowerCase();
|
final String boundName = name.toLowerCase();
|
||||||
if ( Types.containsKey(boundName) ) {
|
if (Types.containsKey(boundName)) {
|
||||||
throw new RuntimeException(String.format("GATK BUG: adding ROD module %s that is already bound", boundName));
|
throw new RuntimeException(String.format("GATK BUG: adding ROD module %s that is already bound", boundName));
|
||||||
}
|
}
|
||||||
System.out.printf("* Adding rod class %s%n", name);
|
System.out.printf("* Adding rod class %s%n", name);
|
||||||
|
|
@ -85,30 +87,36 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
* name, of type, ready to read from the file. This function does check for the strings to be well formed
|
* name, of type, ready to read from the file. This function does check for the strings to be well formed
|
||||||
* and such.
|
* and such.
|
||||||
*
|
*
|
||||||
* @param logger
|
|
||||||
* @param bindings
|
* @param bindings
|
||||||
* @param rods
|
* @param rods
|
||||||
*/
|
*/
|
||||||
public static void parseBindings(Logger logger, ArrayList<String> bindings, List<ReferenceOrderedData<? extends ReferenceOrderedDatum> > rods)
|
public static void parseBindings(ArrayList<String> bindings, List<ReferenceOrderedData<? extends ReferenceOrderedDatum>> rods) {
|
||||||
{
|
// pre-process out any files that were passed in as rod binding command line options
|
||||||
|
for (int x = 0; x < bindings.size(); x++) {
|
||||||
|
if (new File(bindings.get(x)).exists()) {
|
||||||
|
extractRodsFromFile(bindings, bindings.get(x));
|
||||||
|
bindings.remove(x);
|
||||||
|
x--;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Loop over triplets
|
// Loop over triplets
|
||||||
for( String bindingSets: bindings ) {
|
for (String bindingSets : bindings) {
|
||||||
String[] bindingTokens = bindingSets.split(",");
|
String[] bindingTokens = bindingSets.split(",");
|
||||||
if( bindingTokens.length % 3 != 0 )
|
if (bindingTokens.length % 3 != 0)
|
||||||
Utils.scareUser(String.format("Invalid ROD specification: requires triplets of <name>,<type>,<file> but got %s", Utils.join(",", bindings)));
|
Utils.scareUser(String.format("Invalid ROD specification: requires triplets of <name>,<type>,<file> but got %s", Utils.join(",", bindings)));
|
||||||
|
|
||||||
for ( int bindingSet = 0; bindingSet < bindingTokens.length; bindingSet += 3 ) {
|
for (int bindingSet = 0; bindingSet < bindingTokens.length; bindingSet += 3) {
|
||||||
logger.info("Processing ROD bindings: " + bindings.size() + " -> " + Utils.join(" : ", bindingTokens));
|
logger.info("Processing ROD bindings: " + bindings.size() + " -> " + Utils.join(" : ", bindingTokens));
|
||||||
|
|
||||||
final String name = bindingTokens[bindingSet];
|
final String name = bindingTokens[bindingSet];
|
||||||
final String typeName = bindingTokens[bindingSet + 1];
|
final String typeName = bindingTokens[bindingSet + 1];
|
||||||
final String fileName = bindingTokens[bindingSet + 2];
|
final String fileName = bindingTokens[bindingSet + 2];
|
||||||
|
|
||||||
ReferenceOrderedData<?> rod = parse1Binding(logger, name, typeName, fileName);
|
ReferenceOrderedData<?> rod = parse1Binding(name, typeName, fileName);
|
||||||
|
|
||||||
// check that we're not generating duplicate bindings
|
// check that we're not generating duplicate bindings
|
||||||
for ( ReferenceOrderedData rod2 : rods )
|
for (ReferenceOrderedData rod2 : rods)
|
||||||
if ( rod2.getName().equals(rod.getName()) )
|
if (rod2.getName().equals(rod.getName()))
|
||||||
Utils.scareUser(String.format("Found duplicate rod bindings", rod.getName()));
|
Utils.scareUser(String.format("Found duplicate rod bindings", rod.getName()));
|
||||||
|
|
||||||
rods.add(rod);
|
rods.add(rod);
|
||||||
|
|
@ -116,20 +124,42 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* given a existing file, open it and append all the valid triplet lines to an existing list
|
||||||
|
*
|
||||||
|
* @param rodTripletList the list of existing triplets
|
||||||
|
* @param filename the file to attempt to extract ROD triplets from
|
||||||
|
*/
|
||||||
|
protected static void extractRodsFromFile(List<String> rodTripletList, String filename) {
|
||||||
|
BufferedReader str;
|
||||||
|
try {
|
||||||
|
str = new BufferedReader(new FileReader(new File(filename)));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
throw new StingException("Unable to load the ROD input file " + filename,e);
|
||||||
|
}
|
||||||
|
String line = "NO LINES READ IN";
|
||||||
|
try {
|
||||||
|
while ((line = str.readLine()) != null) {
|
||||||
|
if (line.matches(".+,.+,.+")) rodTripletList.add(line.trim());
|
||||||
|
else logger.warn("the following file line didn't parsing into a triplet -> " + line);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new StingException("Failed reading the input rod file " + filename + " last line read was " + line,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helpful function that parses a single triplet of <name> <type> <file> and returns the corresponding ROD with
|
* Helpful function that parses a single triplet of <name> <type> <file> and returns the corresponding ROD with
|
||||||
* <name>, of type <type> that reads its input from <file>.
|
* <name>, of type <type> that reads its input from <file>.
|
||||||
*
|
*
|
||||||
* @param logger
|
|
||||||
* @param trackName
|
* @param trackName
|
||||||
* @param typeName
|
* @param typeName
|
||||||
* @param fileName
|
* @param fileName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static ReferenceOrderedData<?> parse1Binding( Logger logger, final String trackName, final String typeName, final String fileName )
|
private static ReferenceOrderedData<?> parse1Binding(final String trackName, final String typeName, final String fileName) {
|
||||||
{
|
|
||||||
// Gracefully fail if we don't have the type
|
// Gracefully fail if we don't have the type
|
||||||
if ( ReferenceOrderedData.Types.get(typeName.toLowerCase()) == null )
|
if (ReferenceOrderedData.Types.get(typeName.toLowerCase()) == null)
|
||||||
Utils.scareUser(String.format("Unknown ROD type: %s", typeName));
|
Utils.scareUser(String.format("Unknown ROD type: %s", typeName));
|
||||||
|
|
||||||
// Lookup the type
|
// Lookup the type
|
||||||
|
|
@ -160,34 +190,36 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
* Special equals override to see if this ROD is compatible with the given
|
* Special equals override to see if this ROD is compatible with the given
|
||||||
* name and type. 'Compatible' means that this ROD has the name that's passed
|
* name and type. 'Compatible' means that this ROD has the name that's passed
|
||||||
* in and its data can fit into the container specified by type.
|
* in and its data can fit into the container specified by type.
|
||||||
|
*
|
||||||
* @param name Name to check.
|
* @param name Name to check.
|
||||||
* @param type Type to check.
|
* @param type Type to check.
|
||||||
|
*
|
||||||
* @return True if these parameters imply this rod. False otherwise.
|
* @return True if these parameters imply this rod. False otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean matches( String name, Class<? extends ReferenceOrderedDatum> type ) {
|
public boolean matches(String name, Class<? extends ReferenceOrderedDatum> type) {
|
||||||
return this.name.equals(name) && type.isAssignableFrom(this.type);
|
return this.name.equals(name) && type.isAssignableFrom(this.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RODIterator<ROD> iterator() {
|
public RODIterator<ROD> iterator() {
|
||||||
Iterator<ROD> it;
|
Iterator<ROD> it;
|
||||||
try {
|
try {
|
||||||
Method m = type.getDeclaredMethod("createIterator", String.class,java.io.File.class);
|
Method m = type.getDeclaredMethod("createIterator", String.class, java.io.File.class);
|
||||||
it = (Iterator<ROD>) m.invoke(null, name, file);
|
it = (Iterator<ROD>) m.invoke(null, name, file);
|
||||||
} catch ( java.lang.NoSuchMethodException e ) {
|
} catch (java.lang.NoSuchMethodException e) {
|
||||||
it = new SimpleRODIterator();
|
it = new SimpleRODIterator();
|
||||||
} catch ( java.lang.NullPointerException e ) {
|
} catch (java.lang.NullPointerException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch ( java.lang.SecurityException e ) {
|
} catch (java.lang.SecurityException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (java.lang.IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (java.lang.IllegalArgumentException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (java.lang.reflect.InvocationTargetException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch ( java.lang.IllegalAccessException e ) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch ( java.lang.IllegalArgumentException e ) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch ( java.lang.reflect.InvocationTargetException e ) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
return new RODIterator<ROD>(it);
|
return new RODIterator<ROD>(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|
@ -195,12 +227,12 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
public void testMe() {
|
public void testMe() {
|
||||||
for ( ReferenceOrderedDatum rec : this ) {
|
for (ReferenceOrderedDatum rec : this) {
|
||||||
System.out.println(rec.toString());
|
System.out.println(rec.toString());
|
||||||
|
|
||||||
rodGFF gff = (rodGFF)rec;
|
rodGFF gff = (rodGFF) rec;
|
||||||
String[] keys = {"LENGTH", "ALT", "FOBARBAR"};
|
String[] keys = {"LENGTH", "ALT", "FOBARBAR"};
|
||||||
for ( String key : keys) {
|
for (String key : keys) {
|
||||||
System.out.printf(" -> %s is (%s)%n", key, gff.containsAttribute(key) ? gff.getAttribute(key) : "none");
|
System.out.printf(" -> %s is (%s)%n", key, gff.containsAttribute(key) ? gff.getAttribute(key) : "none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -214,7 +246,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
public ArrayList<ReferenceOrderedDatum> readAll() {
|
public ArrayList<ReferenceOrderedDatum> readAll() {
|
||||||
ArrayList<ReferenceOrderedDatum> elts = new ArrayList<ReferenceOrderedDatum>();
|
ArrayList<ReferenceOrderedDatum> elts = new ArrayList<ReferenceOrderedDatum>();
|
||||||
for ( ReferenceOrderedDatum rec : this ) {
|
for (ReferenceOrderedDatum rec : this) {
|
||||||
elts.add(rec);
|
elts.add(rec);
|
||||||
}
|
}
|
||||||
elts.trimToSize();
|
elts.trimToSize();
|
||||||
|
|
@ -228,7 +260,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
public static void write(ArrayList<ReferenceOrderedDatum> data, File output) throws IOException {
|
public static void write(ArrayList<ReferenceOrderedDatum> data, File output) throws IOException {
|
||||||
final FileWriter out = new FileWriter(output);
|
final FileWriter out = new FileWriter(output);
|
||||||
|
|
||||||
for ( ReferenceOrderedDatum rec : data ) {
|
for (ReferenceOrderedDatum rec : data) {
|
||||||
out.write(rec.repl() + "\n");
|
out.write(rec.repl() + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,12 +269,12 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
|
|
||||||
public boolean validateFile() throws Exception {
|
public boolean validateFile() throws Exception {
|
||||||
ReferenceOrderedDatum last = null;
|
ReferenceOrderedDatum last = null;
|
||||||
for ( ReferenceOrderedDatum rec : this ) {
|
for (ReferenceOrderedDatum rec : this) {
|
||||||
if ( last != null && last.compareTo(rec) == 1 ) {
|
if (last != null && last.compareTo(rec) == 1) {
|
||||||
// It's out of order
|
// It's out of order
|
||||||
throw new Exception("Out of order elements at \n" + last.toString() + "\n" + rec.toString());
|
throw new Exception("Out of order elements at \n" + last.toString() + "\n" + rec.toString());
|
||||||
}
|
}
|
||||||
last = rec;
|
last = rec;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -262,7 +294,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
public SimpleRODIterator() {
|
public SimpleRODIterator() {
|
||||||
try {
|
try {
|
||||||
parser = new xReadLines(file);
|
parser = new xReadLines(file);
|
||||||
} catch ( FileNotFoundException e ) {
|
} catch (FileNotFoundException e) {
|
||||||
Utils.scareUser("Couldn't open file: " + file);
|
Utils.scareUser("Couldn't open file: " + file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -291,12 +323,12 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
// TODO: Clean this up so that all errors are handled in one spot.
|
// TODO: Clean this up so that all errors are handled in one spot.
|
||||||
success = (n != null);
|
success = (n != null);
|
||||||
}
|
}
|
||||||
catch( MalformedGenomeLocException ex ) {
|
catch (MalformedGenomeLocException ex) {
|
||||||
if( firstFailure ) {
|
if (firstFailure) {
|
||||||
Utils.warnUser("Failed to parse contig on line '" + line + "'. The reason given was: " + ex.getMessage() + " Skipping ahead to the next recognized GenomeLoc. ");
|
Utils.warnUser("Failed to parse contig on line '" + line + "'. The reason given was: " + ex.getMessage() + " Skipping ahead to the next recognized GenomeLoc. ");
|
||||||
firstFailure = false;
|
firstFailure = false;
|
||||||
}
|
}
|
||||||
if( !parser.hasNext() )
|
if (!parser.hasNext())
|
||||||
Utils.warnUser("Unable to find more valid reference-ordered data. Giving up.");
|
Utils.warnUser("Unable to find more valid reference-ordered data. Giving up.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -315,26 +347,31 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
// Parsing
|
// Parsing
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
private Constructor<ROD> parsing_constructor;
|
private Constructor<ROD> parsing_constructor;
|
||||||
private ROD newROD( final String name, final Class<ROD> type ) {
|
|
||||||
|
private ROD newROD(final String name, final Class<ROD> type) {
|
||||||
try {
|
try {
|
||||||
return (ROD)parsing_constructor.newInstance(name);
|
return (ROD) parsing_constructor.newInstance(name);
|
||||||
} catch ( java.lang.InstantiationException e ) {
|
} catch (java.lang.InstantiationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch ( java.lang.IllegalAccessException e ) {
|
} catch (java.lang.IllegalAccessException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch ( InvocationTargetException e ) {
|
} catch (InvocationTargetException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object initializeROD(final String name, final File file, final Class<ROD> type) {
|
private Object initializeROD(final String name, final File file, final Class<ROD> type) {
|
||||||
try { parsing_constructor = type.getConstructor(String.class); }
|
try {
|
||||||
catch (java.lang.NoSuchMethodException e) { throw new RuntimeException(e); }
|
parsing_constructor = type.getConstructor(String.class);
|
||||||
|
}
|
||||||
|
catch (java.lang.NoSuchMethodException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
ROD rod = newROD(name, type);
|
ROD rod = newROD(name, type);
|
||||||
try {
|
try {
|
||||||
return rod.initialize(file);
|
return rod.initialize(file);
|
||||||
} catch ( FileNotFoundException e ) {
|
} catch (FileNotFoundException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -343,7 +380,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
|
||||||
//System.out.printf("Parsing GFFLine %s%n", Utils.join(" ", parts));
|
//System.out.printf("Parsing GFFLine %s%n", Utils.join(" ", parts));
|
||||||
ROD obj = newROD(name, type);
|
ROD obj = newROD(name, type);
|
||||||
try {
|
try {
|
||||||
if ( ! obj.parseLine(header, parts) )
|
if (!obj.parseLine(header, parts))
|
||||||
obj = null;
|
obj = null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Badly formed ROD: " + e);
|
throw new RuntimeException("Badly formed ROD: " + e);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.broadinstitute.sting.gatk.refdata;
|
||||||
|
|
||||||
|
import org.broadinstitute.sting.BaseTest;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author aaron
|
||||||
|
*
|
||||||
|
* Class ReferenceOrderedDataTest
|
||||||
|
*
|
||||||
|
* some functionality to test parts of the reference ordered data system that I've added. This is by NO MEANS
|
||||||
|
* a complete test suite, but additions would be extremely welcome
|
||||||
|
*/
|
||||||
|
public class ReferenceOrderedDataTest extends BaseTest {
|
||||||
|
@Test
|
||||||
|
public void extractRodsFromFileTest() {
|
||||||
|
String file = "/humgen/gsa-scr1/GATK_Data/Validation_Data/testRODFileImpl.csv";
|
||||||
|
List<String> lst = new ArrayList<String>();
|
||||||
|
ReferenceOrderedData.extractRodsFromFile(lst,file);
|
||||||
|
Assert.assertEquals(6,lst.size());
|
||||||
|
int index = 0;
|
||||||
|
for (String entry: lst) {
|
||||||
|
String first = entry.subSequence(0,entry.indexOf(",")).toString();
|
||||||
|
Assert.assertTrue(first.equals("rod" + String.valueOf(++index)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void extractRodsFromMultiFileTest() {
|
||||||
|
String file = "/humgen/gsa-scr1/GATK_Data/Validation_Data/testRODFileImpl.csv";
|
||||||
|
String file2 = "/humgen/gsa-scr1/GATK_Data/Validation_Data/testRODFileImpl2.csv";
|
||||||
|
List<String> lst = new ArrayList<String>();
|
||||||
|
ReferenceOrderedData.extractRodsFromFile(lst,file);
|
||||||
|
ReferenceOrderedData.extractRodsFromFile(lst,file2);
|
||||||
|
Assert.assertEquals(12,lst.size());
|
||||||
|
int index = 0;
|
||||||
|
for (String entry: lst) {
|
||||||
|
String first = entry.subSequence(0,entry.indexOf(",")).toString();
|
||||||
|
Assert.assertTrue(first.equals("rod" + String.valueOf(++index)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue