本文整理汇总了Java中htsjdk.tribble.readers.AsciiLineReader类的典型用法代码示例。如果您正苦于以下问题:Java AsciiLineReader类的具体用法?Java AsciiLineReader怎么用?Java AsciiLineReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsciiLineReader类属于htsjdk.tribble.readers包,在下文中一共展示了AsciiLineReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeHeader
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
@Override
String writeHeader(AsciiLineReader reader, PrintWriter writer) {
String nextLine;
try {
nextLine = reader.readLine();
while (nextLine.startsWith("#")) {
writer.println(nextLine);
nextLine = reader.readLine();
}
} catch (IOException e) {
throw new RuntimeIOException(e);
}
return nextLine;
}
示例2: writeHeader
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
@Override
String writeHeader(AsciiLineReader reader, PrintWriter writer) throws IOException {
String nextLine = reader.readLine();
if (nextLine.startsWith("psLayout")) {
do {
writer.println(nextLine);
nextLine = reader.readLine();
} while (!nextLine.startsWith("-"));
nextLine = reader.readLine();
}
while (nextLine.startsWith("#") ||
nextLine.startsWith("browser") ||
nextLine.startsWith("track") ||
isEmptyLine(nextLine)) {
writer.println(nextLine);
nextLine = reader.readLine();
}
return nextLine;
}
示例3: writeHeader
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
@Override
String writeHeader(AsciiLineReader reader, PrintWriter writer) {
try {
String nextLine = reader.readLine();
while (nextLine.startsWith("#")) {
writer.println(nextLine);
nextLine = reader.readLine();
}
return nextLine;
} catch (IOException e) {
LOG.error("Error writing header", e);
return null;
}
}
示例4: readSingleHeader
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
public void readSingleHeader(Path vcfPath, Configuration conf) throws IOException {
FileSystem fs = vcfPath.getFileSystem(conf);
if(!fs.exists(vcfPath))
throw new RuntimeException(vcfPath.toString() + " don't exists.");
if(!fs.isFile(vcfPath)) {
throw new RuntimeException(vcfPath.toString() + " is not a file. GaeaSingleVcfHeader parser only support one vcf file.");
}
FSDataInputStream in = fs.open(vcfPath);
AsciiLineReaderIterator it = new AsciiLineReaderIterator(new AsciiLineReader(in));
VCFCodec codec = new VCFCodec();
Object header = codec.readHeader(it);
vcfHeader = (VCFHeader)(((FeatureCodecHeader)header).getHeaderValue());
sampleNames.addAll(vcfHeader.getGenotypeSamples());
buildHeaderInfo();
it.close();
}
示例5: GaeaVCFRecordWriter
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
/** A VCFHeader is read from the input Path. */
public GaeaVCFRecordWriter(
Path output, Path input, boolean writeHeader, TaskAttemptContext ctx)
throws IOException
{
final AsciiLineReader r = new AsciiLineReader(
input.getFileSystem(ContextUtil.getConfiguration(ctx)).open(input));
final Object h = codec.readHeader(new AsciiLineReaderIterator(r));
if (!(h instanceof VCFHeader))
throw new IOException("No VCF header found in "+ input);
r.close();
init(output, (VCFHeader)h, writeHeader, ctx);
}
示例6: isValid
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
/**
* Validate cytoband file
*
* @param reader
* @param filename
* @return
*/
public static boolean isValid(AsciiLineReader reader, String filename) {
if (reader == null) {
return false;
}
try {
String nextLine;
while ((nextLine = reader.readLine()) != null) {
String[] tokens = nextLine.split("\t");
String chr = tokens[0].trim();
Cytoband cytoData = new Cytoband(chr);
parseData(tokens, cytoData);
}
return true;
} catch (Exception e) {
logger.error("Invalid Cytoband file data : file=" + filename, e);
return false;
}
}
示例7: parsableMAGE_TAB
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
public static boolean parsableMAGE_TAB(ResourceLocator file) throws IOException {
AsciiLineReader reader = null;
try {
reader = ParsingUtils.openAsciiReader(file);
String nextLine = null;
//skip first row
reader.readLine();
//check second row for MAGE_TAB identifiers
if ((nextLine = reader.readLine()) != null && (nextLine.contains("Reporter REF") ||
nextLine.contains("Composite Element REF") || nextLine.contains("Term Source REF") ||
nextLine.contains("CompositeElement REF") || nextLine.contains("TermSource REF") ||
nextLine.contains("Coordinates REF"))) {
return true;
}
} finally {
if (reader != null) {
reader.close();
}
}
return false;
}
示例8: loadSampleInfo
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
/**
* Load attributes from an ascii file in "Sample Info" format.
*/
public void loadSampleInfo(ResourceLocator locator) {
AsciiLineReader reader = null;
try {
reader = ParsingUtils.openAsciiReader(locator);
loadSampleTable(reader, locator.getPath());
loadedResources.add(locator);
if (!Globals.isHeadless()) {
IGV.getInstance().resetOverlayTracks();
IGV.getInstance().doRefresh();
}
} catch (IOException ex) {
log.error("Error loading attribute file", ex);
throw new DataLoadException("Error reading attribute file", locator.getPath());
} finally {
if (reader != null) {
reader.close();
}
firePropertyChange(this, ATTRIBUTES_LOADED_PROPERTY, null, null);
}
}
示例9: writeHeader
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
@Override
String writeHeader(AsciiLineReader reader, PrintWriter writer) {
String nextLine = null;
try {
nextLine = reader.readLine();
while (nextLine.startsWith("#")) {
writer.println(nextLine);
nextLine = reader.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
return nextLine;
}
示例10: writeHeader
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
@Override
String writeHeader(AsciiLineReader reader, PrintWriter writer) throws IOException {
String nextLine = reader.readLine();
if (nextLine.startsWith("psLayout")) {
do {
writer.println(nextLine);
nextLine = reader.readLine();
} while (!nextLine.startsWith("-"));
nextLine = reader.readLine();
}
// TODO -- check "browser" line syntax, is it a multi-line directive?
while (nextLine.startsWith("#") ||
nextLine.startsWith("browser") ||
nextLine.startsWith("track") ||
nextLine.trim().length() == 0) {
writer.println(nextLine);
nextLine = reader.readLine();
}
return nextLine;
}
示例11: writeHeader
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
@Override
String writeHeader(AsciiLineReader reader, PrintWriter writer) throws IOException {
String nextLine;
// TODO -- check "browser" line syntax, is it a multi-line directive?
while ((nextLine = reader.readLine()).startsWith("#")) {
writer.println(nextLine); // Comments, directives
}
writer.println(nextLine); // Header
// Contract is to return the first data line!
nextLine = reader.readLine();
return nextLine;
}
示例12: writeHeader
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
@Override
String writeHeader(AsciiLineReader reader, PrintWriter writer) {
try {
String nextLine = reader.readLine();
// TODO -- check "browser" line syntax, is it a multi-line directive?
while (nextLine.startsWith("#")) {
writer.println(nextLine);
nextLine = reader.readLine();
}
return nextLine;
} catch (IOException e) {
log.error("Error writing header", e);
return null;
}
}
示例13: isWiggle
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
/**
* Utility method. Returns true if this looks like a wiggle locator. The criteria is to scan
* the first 100 lines looking for a valid "track" line. According to UCSC documentation
* track lines must contain a type attribute, which must be equal to "wiggle_0".
*
* @param file
* @return
*/
public static boolean isWiggle(ResourceLocator file) {
AsciiLineReader reader = null;
try {
reader = ParsingUtils.openAsciiReader(file);
String nextLine = null;
int lineNo = 0;
while ((nextLine = reader.readLine()) != null && (nextLine.trim().length() > 0)) {
if (nextLine.startsWith("track") && nextLine.contains("wiggle_0")) {
return true;
}
if (lineNo++ > 100) {
break;
}
}
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
if (reader != null) {
reader.close();
}
}
return false;
}
示例14: getChromosomes
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
/**
* Gets the set (no duplicates) of chromosomes from a bed file.
*
* @param bedFilePath Path to the bed file.
*
* @return The set of chromosomes (no duplicates)
*
* @throws FileNotFoundException, IOException
*/
public static Set<String> getChromosomes(String bedFilePath) throws FileNotFoundException, IOException {
Set<String> chrs = new LinkedHashSet<>();
File bedFile = FileUtils.getFile(bedFilePath);
try (InputStream is = new FileInputStream(bedFile);
AsciiLineReader alr = new AsciiLineReader(is);
LineIteratorImpl lineIterator = new LineIteratorImpl(alr);) {
BEDCodec bc = new BEDCodec();
while (!bc.isDone(lineIterator)) {
BEDFeature bf = bc.decode(lineIterator);
if (bf != null) {
//see https://github.com/samtools/htsjdk/issues/197
chrs.add(bf.getContig());
}
}
}
return chrs;
}
示例15: grep
import htsjdk.tribble.readers.AsciiLineReader; //导入依赖的package包/类
/** returns the number of lines in the file that contain a regular expression (decorated with "MV=" and
* expected to be in an INFO field in a vcf)
*
* @param file File to examine
* @param regex String containing a regular expression to look for in the file
* @return the number of lines that contain regex
*/
private int grep(final File file, final String regex) {
int results = 0;
final Pattern pattern = Pattern.compile(".*"+regex+".*");
try (final LineIteratorImpl li = new LineIteratorImpl(new AsciiLineReader(IOUtil.openFileForReading(file)))) {
while (li.hasNext()) {
final String line = li.next();
if (pattern.matcher(line).matches()) {
results++;
}
}
} catch (final IOException e) {
e.printStackTrace();
}
return results;
}