本文整理了Java中org.broadinstitute.gatk.utils.Utils
类的一些代码示例,展示了Utils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils
类的具体详情如下:
包路径:org.broadinstitute.gatk.utils.Utils
类名称:Utils
[英]Created by IntelliJ IDEA. User: depristo Date: Feb 24, 2009 Time: 10:12:31 AM To change this template use File | Settings | File Templates.
[中]由IntelliJ IDEA创建。用户:depristo日期:2009年2月24日时间:上午10:12:31要更改此模板,请使用文件|设置|文件模板。
代码示例来源:origin: broadgsa/gatk
/**
* join an array of strings given a seperator
* @param separator the string to insert between each array element
* @param strings the array of strings
* @return a string, which is the joining of all array values with the separator
*/
public static String join(String separator, String[] strings) {
return join(separator, strings, 0, strings.length);
}
代码示例来源:origin: broadgsa/gatk
private byte[] getDeterministicRandomData ( int size ) {
Utils.resetRandomGenerator();
Random rand = Utils.getRandomGenerator();
byte[] randomData = new byte[size];
rand.nextBytes(randomData);
return randomData;
}
}
代码示例来源:origin: broadgsa/gatk-protected
PairHMMTestData(String ref, String nextRef, String read, final byte qual) {
this.ref = ref;
this.nextRef = nextRef;
this.read = read;
this.baseQuals = this.insQuals = this.delQuals = Utils.dupBytes(qual, read.length());
this.gcp = Utils.dupBytes((byte)10, read.length());
this.log10l = -1;
this.newRead = true;
}
代码示例来源:origin: broadgsa/gatk
/**
* Get a random int between min and max (inclusive) using the global GATK random number generator
*
* @param min lower bound of the range
* @param max upper bound of the range
* @return a random int >= min and <= max
*/
public static int randomIntegerInRange( final int min, final int max ) {
return Utils.getRandomGenerator().nextInt(max - min + 1) + min;
}
代码示例来源:origin: broadgsa/gatk
public String toString() {
StringBuilder s = new StringBuilder();
s.append(Utils.dupString('-', 80) + "\n");
s.append(String.format("Number of examined reads %d%n", nTotalReads));
s.append(String.format("Number of clipped reads %d%n", nClippedReads));
s.append(String.format("Percent of clipped reads %.2f%n", (100.0 * nClippedReads) / nTotalReads));
s.append(String.format("Number of examined bases %d%n", nTotalBases));
s.append(String.format("Number of clipped bases %d%n", nClippedBases));
s.append(String.format("Percent of clipped bases %.2f%n", (100.0 * nClippedBases) / nTotalBases));
s.append(String.format("Number of quality-score clipped bases %d%n", nQClippedBases));
s.append(String.format("Number of range clipped bases %d%n", nRangeClippedBases));
s.append(String.format("Number of sequence clipped bases %d%n", nSeqClippedBases));
for (Map.Entry<String, Long> elt : seqClipCounts.entrySet()) {
s.append(String.format(" %8d clip sites matching %s%n", elt.getValue(), elt.getKey()));
}
s.append(Utils.dupString('-', 80) + "\n");
return s.toString();
}
}
代码示例来源:origin: broadgsa/gatk
String[] command = Utils.escapeExpressions(args);
final String cmdline = Utils.join(" ",command);
System.out.println(String.format("[%s] Executing test %s:%s with GATK arguments: %s", now, testClassName, testName, cmdline));
代码示例来源:origin: broadgsa/gatk-protected
@DataProvider(name = "GetBasesData")
public Object[][] makeGetBasesData() {
List<Object[]> tests = new ArrayList<>();
final List<String> frags = Arrays.asList("ACT", "GAC", "CAT");
for ( int n = 1; n <= frags.size(); n++ ) {
for ( final List<String> comb : Utils.makePermutations(frags, n, false) ) {
tests.add(new Object[]{comb});
}
}
return tests.toArray(new Object[][]{});
}
代码示例来源:origin: broadgsa/gatk
/**
* Splits expressions in command args by spaces and returns the array of expressions.
* Expressions may use single or double quotes to group any individual expression, but not both.
* @param args Arguments to parse.
* @return Parsed expressions.
*/
public static String[] escapeExpressions(String args) {
// special case for ' and " so we can allow expressions
if (args.indexOf('\'') != -1)
return escapeExpressions(args, "'");
else if (args.indexOf('\"') != -1)
return escapeExpressions(args, "\"");
else
return args.trim().split(" +");
}
代码示例来源:origin: broadgsa/gatk-protected
Utils.warnUser(logger, String.format(
"Rscript not found in environment path. %s will be generated but PDF plots will not.",
RSCRIPT_FILE));
replicate.add(Utils.getRandomGenerator().nextDouble());
代码示例来源:origin: broadgsa/gatk
@BeforeMethod
public void initializeWalkerTests() {
logger.debug("Initializing walker tests");
Utils.resetRandomGenerator();
}
代码示例来源:origin: broadgsa/gatk
public static void warnUser(final String msg) {
warnUser(logger, msg);
}
代码示例来源:origin: broadgsa/gatk
/**
* Return a random base index, excluding some base index.
*
* @param excludeBaseIndex the base index to exclude
* @return a random base index, excluding the one specified (A=0, C=1, G=2, T=3)
*/
static public int getRandomBaseIndex(int excludeBaseIndex) {
int randomBaseIndex = excludeBaseIndex;
while (randomBaseIndex == excludeBaseIndex) {
randomBaseIndex = Utils.getRandomGenerator().nextInt(4);
}
return randomBaseIndex;
}
代码示例来源:origin: broadgsa/gatk
@Override
public String toString(int offset) {
String off = offset > 0 ? Utils.dupString(' ', offset) : "";
StringBuilder b = new StringBuilder();
b.append("(").append("\n");
Collection<DiffElement> atomicElts = getAtomicElements();
for ( DiffElement elt : atomicElts ) {
b.append(elt.toString(offset + 2)).append('\n');
}
for ( DiffElement elt : getCompoundElements() ) {
b.append(elt.toString(offset + 4)).append('\n');
}
b.append(off).append(")").append("\n");
return b.toString();
}
代码示例来源:origin: broadgsa/gatk
@DataProvider(name = "ArrayMinData")
public Object[][] makeArrayMinData() {
List<Object[]> tests = new ArrayList<>();
// this functionality can be adapted to provide input data for whatever you might want in your data
tests.add(new Object[]{Arrays.asList(10), 10});
tests.add(new Object[]{Arrays.asList(-10), -10});
for ( final List<Integer> values : Utils.makePermutations(Arrays.asList(1,2,3), 3, false) ) {
tests.add(new Object[]{values, 1});
}
for ( final List<Integer> values : Utils.makePermutations(Arrays.asList(1,2,-3), 3, false) ) {
tests.add(new Object[]{values, -3});
}
return tests.toArray(new Object[][]{});
}
代码示例来源:origin: broadgsa/gatk
private List<String> getListArguments(File file) throws IOException {
ArrayList<String> argsList = new ArrayList<String>();
for (String line: FileUtils.readLines(file))
argsList.addAll(Arrays.asList(Utils.escapeExpressions(line)));
return argsList;
}
代码示例来源:origin: broadgsa/gatk
@Test(dataProvider = "DownsamplingReadsIteratorTestDataProvider")
public void runDownsamplingReadsIteratorTest( DownsamplingReadsIteratorTest test ) {
logger.warn("Running test: " + test);
Utils.resetRandomGenerator();
test.run();
}
}
代码示例来源:origin: broadgsa/gatk-protected
/**
* Checks whether the last-modification-time of the inputs is consistent with their relative roles.
*
* This routine does not thrown an exception but may output a warning message if inconsistencies are spotted.
*
* @param beforeFile the before report file.
* @param afterFile the after report file.
*/
private void checkInputReportFileLMT(final File beforeFile, final File afterFile) {
if (ignoreLastModificationTime || beforeFile == null || afterFile == null) {
return; // nothing to do here
} else if (beforeFile.lastModified() > afterFile.lastModified()) {
Utils.warnUser("Last modification timestamp for 'Before' and 'After'"
+ "recalibration reports are in the wrong order. Perhaps, have they been swapped?");
}
}
代码示例来源:origin: broadgsa/gatk
/**
* Provide an initial value for reduce computations.
*
* @return Initial value of reduce.
*/
public Integer reduceInit() {
out.println(Utils.join(" \t", Arrays.asList("ReadGroup", "ReadLength", "NClippingEvents", "NClippedBases", "PercentClipped")));
return 0;
}
代码示例来源:origin: broadgsa/gatk
@DataProvider(name = "SimplePositionalDownsamplerTestDataProvider")
public Object[][] createSimplePositionalDownsamplerTestData() {
Utils.resetRandomGenerator();
for ( int targetCoverage = 1; targetCoverage <= 10000; targetCoverage *= 10 ) {
for ( int contigs = 1; contigs <= 2; contigs++ ) {
for ( int numStacks = 0; numStacks <= 10; numStacks++ ) {
List<Integer> stackSizes = new ArrayList<Integer>(numStacks);
for ( int stack = 1; stack <= numStacks; stack++ ) {
stackSizes.add(Utils.getRandomGenerator().nextInt(targetCoverage * 2) + 1);
}
new SimplePositionalDownsamplerTest(targetCoverage, stackSizes, contigs > 1);
}
}
}
return SimplePositionalDownsamplerTest.getTests(SimplePositionalDownsamplerTest.class);
}
代码示例来源:origin: broadgsa/gatk
/**
* Create random read qualities
*
* @param length the length of the read
* @return an array with randomized base qualities between 0 and 50
*/
public static byte[] createRandomReadQuals(int length) {
Random random = Utils.getRandomGenerator();
byte[] quals = new byte[length];
for (int i = 0; i < length; i++)
quals[i] = (byte) random.nextInt(50);
return quals;
}
内容来源于网络,如有侵权,请联系作者删除!