Merge branch 'master' of github.com:broadinstitute/gsa-unstable
This commit is contained in:
commit
c2efb04657
|
|
@ -271,7 +271,18 @@ public class GATKReport {
|
||||||
* @return a simplified GATK report
|
* @return a simplified GATK report
|
||||||
*/
|
*/
|
||||||
public static GATKReport newSimpleReport(final String tableName, final String... columns) {
|
public static GATKReport newSimpleReport(final String tableName, final String... columns) {
|
||||||
GATKReportTable table = new GATKReportTable(tableName, "A simplified GATK table report", columns.length);
|
return newSimpleReportWithDescription(tableName, "A simplified GATK table report", columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #newSimpleReport(String, String...) but with a customized description
|
||||||
|
* @param tableName
|
||||||
|
* @param desc
|
||||||
|
* @param columns
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static GATKReport newSimpleReportWithDescription(final String tableName, final String desc, final String... columns) {
|
||||||
|
GATKReportTable table = new GATKReportTable(tableName, desc, columns.length);
|
||||||
|
|
||||||
for (String column : columns) {
|
for (String column : columns) {
|
||||||
table.addColumn(column, "");
|
table.addColumn(column, "");
|
||||||
|
|
|
||||||
|
|
@ -315,6 +315,20 @@ public class GenomeLoc implements Comparable<GenomeLoc>, Serializable, HasGenome
|
||||||
return ( comparison == -1 || ( comparison == 0 && this.getStop() < that.getStart() ));
|
return ( comparison == -1 || ( comparison == 0 && this.getStop() < that.getStart() ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether this genome loc starts at the same position as that.
|
||||||
|
*
|
||||||
|
* i.e., do this and that have the same contig and the same start position
|
||||||
|
*
|
||||||
|
* @param that genome loc to compare to
|
||||||
|
* @return true if this and that have the same contig and the same start position
|
||||||
|
*/
|
||||||
|
@Requires("that != null")
|
||||||
|
public final boolean startsAt( GenomeLoc that ) {
|
||||||
|
int comparison = this.compareContigs(that);
|
||||||
|
return comparison == 0 && this.getStart() == that.getStart();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether any portion of this contig is before that contig.
|
* Tests whether any portion of this contig is before that contig.
|
||||||
* @param that Other contig to test.
|
* @param that Other contig to test.
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,10 @@ public class Utils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> String join(final String separator, final T ... objects) {
|
||||||
|
return join(separator, Arrays.asList(objects));
|
||||||
|
}
|
||||||
|
|
||||||
public static String dupString(char c, int nCopies) {
|
public static String dupString(char c, int nCopies) {
|
||||||
char[] chars = new char[nCopies];
|
char[] chars = new char[nCopies];
|
||||||
Arrays.fill(chars, c);
|
Arrays.fill(chars, c);
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,17 @@ import net.sf.samtools.SAMSequenceRecord;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.broad.tribble.Feature;
|
import org.broad.tribble.Feature;
|
||||||
|
import org.broad.tribble.FeatureCodecHeader;
|
||||||
|
import org.broad.tribble.readers.PositionalBufferedStream;
|
||||||
import org.broadinstitute.sting.commandline.RodBinding;
|
import org.broadinstitute.sting.commandline.RodBinding;
|
||||||
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
||||||
import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource;
|
import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource;
|
||||||
|
import org.broadinstitute.sting.utils.collections.Pair;
|
||||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -317,4 +322,33 @@ public class VCFUtils {
|
||||||
assembly = "hg19";
|
assembly = "hg19";
|
||||||
return assembly;
|
return assembly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read all of the VCF records from source into memory, returning the header and the VariantContexts
|
||||||
|
*
|
||||||
|
* @param source the file to read, must be in VCF4 format
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static Pair<VCFHeader, List<VariantContext>> readVCF(final File source) throws IOException {
|
||||||
|
// read in the features
|
||||||
|
final List<VariantContext> vcs = new ArrayList<VariantContext>();
|
||||||
|
final VCFCodec codec = new VCFCodec();
|
||||||
|
PositionalBufferedStream pbs = new PositionalBufferedStream(new FileInputStream(source));
|
||||||
|
FeatureCodecHeader header = codec.readHeader(pbs);
|
||||||
|
pbs.close();
|
||||||
|
|
||||||
|
pbs = new PositionalBufferedStream(new FileInputStream(source));
|
||||||
|
pbs.skip(header.getHeaderEnd());
|
||||||
|
|
||||||
|
final VCFHeader vcfHeader = (VCFHeader)header.getHeaderValue();
|
||||||
|
|
||||||
|
while ( ! pbs.isDone() ) {
|
||||||
|
final VariantContext vc = codec.decode(pbs);
|
||||||
|
if ( vc != null )
|
||||||
|
vcs.add(vc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Pair<VCFHeader, List<VariantContext>>(vcfHeader, vcs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue