Instead of the SelfScopingFeatureCodec interface, pushed this functionality into Tribble itself. Now we can e.g. determine that a file can be parsed by the BedCodec on the fly.
This commit is contained in:
parent
66ad2b941c
commit
d64f8a89a9
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2011, The Broad Institute
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person
|
|
||||||
* obtaining a copy of this software and associated documentation
|
|
||||||
* files (the "Software"), to deal in the Software without
|
|
||||||
* restriction, including without limitation the rights to use,
|
|
||||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the
|
|
||||||
* Software is furnished to do so, subject to the following
|
|
||||||
* conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.broadinstitute.sting.gatk.refdata;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An interface marking that a given Tribble codec can look at the file and determine whether the
|
|
||||||
* codec specifically parsing the contents of the file.
|
|
||||||
*/
|
|
||||||
public interface SelfScopingFeatureCodec {
|
|
||||||
/**
|
|
||||||
* This function returns true iff the File potentialInput can be parsed by this
|
|
||||||
* codec.
|
|
||||||
*
|
|
||||||
* The GATK assumes that there's never a situation where two SelfScopingFeaetureCodecs
|
|
||||||
* return true for the same file. If this occurs the GATK splits out an error.
|
|
||||||
*
|
|
||||||
* Note this function must never throw an error. All errors should be trapped
|
|
||||||
* and false returned.
|
|
||||||
*
|
|
||||||
* @param potentialInput the file to test for parsiability with this codec
|
|
||||||
* @return true if potentialInput can be parsed, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean canDecode(final File potentialInput);
|
|
||||||
}
|
|
||||||
|
|
@ -30,16 +30,12 @@ import org.broad.tribble.Feature;
|
||||||
import org.broad.tribble.FeatureCodec;
|
import org.broad.tribble.FeatureCodec;
|
||||||
import org.broad.tribble.NameAwareCodec;
|
import org.broad.tribble.NameAwareCodec;
|
||||||
import org.broadinstitute.sting.gatk.refdata.ReferenceDependentFeatureCodec;
|
import org.broadinstitute.sting.gatk.refdata.ReferenceDependentFeatureCodec;
|
||||||
import org.broadinstitute.sting.gatk.refdata.SelfScopingFeatureCodec;
|
|
||||||
import org.broadinstitute.sting.gatk.refdata.utils.RMDTriplet;
|
import org.broadinstitute.sting.gatk.refdata.utils.RMDTriplet;
|
||||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||||
import org.broadinstitute.sting.utils.Utils;
|
|
||||||
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
||||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||||
import org.broadinstitute.sting.utils.help.GATKDocUtils;
|
import org.broadinstitute.sting.utils.help.GATKDocUtils;
|
||||||
import org.broadinstitute.sting.utils.help.HelpUtils;
|
|
||||||
|
|
||||||
import javax.mail.Header;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
@ -159,10 +155,8 @@ public class FeatureManager {
|
||||||
public FeatureDescriptor getByFiletype(File file) {
|
public FeatureDescriptor getByFiletype(File file) {
|
||||||
List<FeatureDescriptor> canParse = new ArrayList<FeatureDescriptor>();
|
List<FeatureDescriptor> canParse = new ArrayList<FeatureDescriptor>();
|
||||||
for ( FeatureDescriptor descriptor : featureDescriptors )
|
for ( FeatureDescriptor descriptor : featureDescriptors )
|
||||||
if ( descriptor.getCodec() instanceof SelfScopingFeatureCodec ) {
|
if ( descriptor.getCodec().canDecode(file) ) {
|
||||||
if ( ((SelfScopingFeatureCodec) descriptor.getCodec()).canDecode(file) ) {
|
canParse.add(descriptor);
|
||||||
canParse.add(descriptor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( canParse.size() == 0 )
|
if ( canParse.size() == 0 )
|
||||||
|
|
|
||||||
|
|
@ -249,4 +249,6 @@ public class BeagleCodec implements ReferenceDependentFeatureCodec<BeagleFeature
|
||||||
return bglFeature;
|
return bglFeature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canDecode(final File potentialInput) { return false; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
package org.broadinstitute.sting.utils.codecs.hapmap;
|
package org.broadinstitute.sting.utils.codecs.hapmap;
|
||||||
|
|
||||||
|
import org.broad.tribble.AbstractFeatureCodec;
|
||||||
import org.broad.tribble.Feature;
|
import org.broad.tribble.Feature;
|
||||||
import org.broad.tribble.FeatureCodec;
|
|
||||||
import org.broad.tribble.annotation.Strand;
|
import org.broad.tribble.annotation.Strand;
|
||||||
import org.broad.tribble.readers.LineReader;
|
import org.broad.tribble.readers.LineReader;
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ import java.util.Arrays;
|
||||||
* @author Mark DePristo
|
* @author Mark DePristo
|
||||||
* @since 2010
|
* @since 2010
|
||||||
*/
|
*/
|
||||||
public class RawHapMapCodec implements FeatureCodec {
|
public class RawHapMapCodec extends AbstractFeatureCodec {
|
||||||
// the minimum number of features in the HapMap file line
|
// the minimum number of features in the HapMap file line
|
||||||
private static final int minimumFeatureCount = 11;
|
private static final int minimumFeatureCount = 11;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||||
import org.broadinstitute.sting.utils.Utils;
|
import org.broadinstitute.sting.utils.Utils;
|
||||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -138,4 +139,7 @@ public class RefSeqCodec implements ReferenceDependentFeatureCodec<RefSeqFeature
|
||||||
public Class<RefSeqFeature> getFeatureType() {
|
public Class<RefSeqFeature> getFeatureType() {
|
||||||
return RefSeqFeature.class;
|
return RefSeqFeature.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canDecode(final File potentialInput) { return false; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
package org.broadinstitute.sting.utils.codecs.sampileup;
|
package org.broadinstitute.sting.utils.codecs.sampileup;
|
||||||
|
|
||||||
|
import org.broad.tribble.AbstractFeatureCodec;
|
||||||
import org.broad.tribble.Feature;
|
import org.broad.tribble.Feature;
|
||||||
import org.broad.tribble.FeatureCodec;
|
|
||||||
import org.broad.tribble.exception.CodecLineParsingException;
|
import org.broad.tribble.exception.CodecLineParsingException;
|
||||||
import org.broad.tribble.readers.LineReader;
|
import org.broad.tribble.readers.LineReader;
|
||||||
import org.broad.tribble.util.ParsingUtils;
|
import org.broad.tribble.util.ParsingUtils;
|
||||||
|
|
@ -76,7 +76,7 @@ import static org.broadinstitute.sting.utils.codecs.sampileup.SAMPileupFeature.V
|
||||||
* @author Matt Hanna
|
* @author Matt Hanna
|
||||||
* @since 2009
|
* @since 2009
|
||||||
*/
|
*/
|
||||||
public class SAMPileupCodec implements FeatureCodec<SAMPileupFeature> {
|
public class SAMPileupCodec extends AbstractFeatureCodec<SAMPileupFeature> {
|
||||||
// the number of tokens we expect to parse from a pileup line
|
// the number of tokens we expect to parse from a pileup line
|
||||||
private static final int expectedTokenCount = 10;
|
private static final int expectedTokenCount = 10;
|
||||||
private static final char fldDelim = '\t';
|
private static final char fldDelim = '\t';
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ package org.broadinstitute.sting.utils.codecs.samread;
|
||||||
import net.sf.samtools.Cigar;
|
import net.sf.samtools.Cigar;
|
||||||
import net.sf.samtools.TextCigarCodec;
|
import net.sf.samtools.TextCigarCodec;
|
||||||
import net.sf.samtools.util.StringUtil;
|
import net.sf.samtools.util.StringUtil;
|
||||||
|
import org.broad.tribble.AbstractFeatureCodec;
|
||||||
import org.broad.tribble.Feature;
|
import org.broad.tribble.Feature;
|
||||||
import org.broad.tribble.FeatureCodec;
|
|
||||||
import org.broad.tribble.exception.CodecLineParsingException;
|
import org.broad.tribble.exception.CodecLineParsingException;
|
||||||
import org.broad.tribble.readers.LineReader;
|
import org.broad.tribble.readers.LineReader;
|
||||||
import org.broad.tribble.util.ParsingUtils;
|
import org.broad.tribble.util.ParsingUtils;
|
||||||
|
|
@ -52,7 +52,7 @@ import org.broad.tribble.util.ParsingUtils;
|
||||||
* @author Matt Hanna
|
* @author Matt Hanna
|
||||||
* @since 2009
|
* @since 2009
|
||||||
*/
|
*/
|
||||||
public class SAMReadCodec implements FeatureCodec<SAMReadFeature> {
|
public class SAMReadCodec extends AbstractFeatureCodec<SAMReadFeature> {
|
||||||
/* SL-XBC:1:10:628:923#0 16 Escherichia_coli_K12 1 37 76M = 1 0 AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGCTTCTGA B@>87<;A@?@957:>>@AA@B>@A9AB@B>@A@@@@@A;=AAB@BBBBBCBBBB@>A>:ABB@BAABCB=CA@CB */
|
/* SL-XBC:1:10:628:923#0 16 Escherichia_coli_K12 1 37 76M = 1 0 AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGCTTCTGA B@>87<;A@?@957:>>@AA@B>@A9AB@B>@A@@@@@A;=AAB@BBBBBCBBBB@>A>:ABB@BAABCB=CA@CB */
|
||||||
|
|
||||||
// the number of tokens we expect to parse from a read line
|
// the number of tokens we expect to parse from a read line
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import org.broadinstitute.sting.gatk.refdata.ReferenceDependentFeatureCodec;
|
||||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -101,4 +102,7 @@ public class TableCodec implements ReferenceDependentFeatureCodec {
|
||||||
}
|
}
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canDecode(final File potentialInput) { return false; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import org.broad.tribble.TribbleException;
|
||||||
import org.broad.tribble.readers.LineReader;
|
import org.broad.tribble.readers.LineReader;
|
||||||
import org.broad.tribble.util.BlockCompressedInputStream;
|
import org.broad.tribble.util.BlockCompressedInputStream;
|
||||||
import org.broad.tribble.util.ParsingUtils;
|
import org.broad.tribble.util.ParsingUtils;
|
||||||
import org.broadinstitute.sting.gatk.refdata.SelfScopingFeatureCodec;
|
|
||||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
import org.broadinstitute.sting.utils.variantcontext.Allele;
|
import org.broadinstitute.sting.utils.variantcontext.Allele;
|
||||||
|
|
@ -20,7 +19,7 @@ import java.util.*;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
|
||||||
public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec, VCFParser, SelfScopingFeatureCodec {
|
public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec, VCFParser {
|
||||||
|
|
||||||
protected final static Logger log = Logger.getLogger(VCFCodec.class);
|
protected final static Logger log = Logger.getLogger(VCFCodec.class);
|
||||||
protected final static int NUM_STANDARD_FIELDS = 8; // INFO is the 8th column
|
protected final static int NUM_STANDARD_FIELDS = 8; // INFO is the 8th column
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1,3 +1,3 @@
|
||||||
<ivy-module version="1.0">
|
<ivy-module version="1.0">
|
||||||
<info organisation="org.broad" module="tribble" revision="40" status="integration" />
|
<info organisation="org.broad" module="tribble" revision="41" status="integration" />
|
||||||
</ivy-module>
|
</ivy-module>
|
||||||
Loading…
Reference in New Issue