本文整理汇总了Java中htsjdk.tribble.readers.AsciiLineReader.close方法的典型用法代码示例。如果您正苦于以下问题:Java AsciiLineReader.close方法的具体用法?Java AsciiLineReader.close怎么用?Java AsciiLineReader.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.tribble.readers.AsciiLineReader
的用法示例。
在下文中一共展示了AsciiLineReader.close方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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);
}
}
示例4: 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;
}
示例5: VCFRecordWriter
import htsjdk.tribble.readers.AsciiLineReader; //导入方法依赖的package包/类
/** A VCFHeader is read from the input Path. */
public VCFRecordWriter(
Path output, Path input, boolean writeHeader, TaskAttemptContext ctx)
throws IOException
{
final AsciiLineReader r = new AsciiLineReader(
input.getFileSystem(ctx.getConfiguration()).open(input));
final FeatureCodecHeader h = codec.readHeader(new AsciiLineReaderIterator(r));
if (h == null || !(h.getHeaderValue() instanceof VCFHeader))
throw new IOException("No VCF header found in "+ input);
r.close();
init(output, (VCFHeader) h.getHeaderValue(), writeHeader, ctx);
}
示例6: loadFromFile
import htsjdk.tribble.readers.AsciiLineReader; //导入方法依赖的package包/类
/**
* Load segmented data from a file could be remote)
* Return a map of trackId -> segment datasource
*
* @return
*/
public SegmentedAsciiDataSet loadFromFile() {
dataset = new SegmentedAsciiDataSet(genome);
if (birdsuite) {
dataset.setTrackType(TrackType.CNV);
}
AsciiLineReader reader = null;
String nextLine = null;
int lineNumber = 0;
IParser<String[], Integer> parser = IParserFactory.getIndexParser(new String[0]);
try {
reader = ParsingUtils.openAsciiReader(locator);
lineNumber = readHeader(reader);
while ((nextLine = reader.readLine()) != null && (nextLine.trim().length() > 0)) {
lineNumber++;
String[] tokens = Globals.tabPattern.split(nextLine, -1);
parseLine(parser, tokens);
}
} catch (IOException e) {
if (nextLine != null && lineNumber != 0) {
throw new ParserException(e.getMessage(), e, lineNumber, nextLine);
} else {
throw new RuntimeException(e);
}
} finally {
if (reader != null) {
reader.close();
}
}
dataset.sortLists();
return dataset;
}
示例7: loadKnownSnps
import htsjdk.tribble.readers.AsciiLineReader; //导入方法依赖的package包/类
/**
* Load the set of known snps from a tab delimited file, format
* chr < tab> location
* The location is "1 base" (first nucleotide is position 1).
*
* @param snpFile
*/
private static synchronized void loadKnownSnps(String snpFile) {
// This method might get called many times concurrently, but we only want to load these once.
if (knownSnps != null) {
return;
}
knownSnps = new HashMap();
AsciiLineReader reader = null;
try {
reader = ParsingUtils.openAsciiReader(new ResourceLocator(snpFile));
String nextLine = "";
while ((nextLine = reader.readLine()) != null) {
String[] tokens = nextLine.split("\t");
String chr = tokens[0];
Set<Integer> snps = knownSnps.get(chr);
if (snps == null) {
snps = new HashSet(10000);
knownSnps.put(chr, snps);
}
snps.add(new Integer(tokens[1]));
}
} catch (Exception e) {
knownSnps = null;
log.error("", e);
MessageUtils.showMessage("Error loading snps file: " + snpFile + " (" + e.toString() + ")");
} finally {
reader.close();
}
}
示例8: 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"))) {
int count = 0;
// check if this mage_tab data matrix can be parsed by this class
while ((nextLine = reader.readLine()) != null && count < 5) {
nextLine = nextLine.trim();
if (nextLine.startsWith("SNP_A") || nextLine.startsWith("CN_")) {
return true;
}
count++;
}
return false;
}
} finally {
if (reader != null) {
reader.close();
}
}
return false;
}
示例9: parse
import htsjdk.tribble.readers.AsciiLineReader; //导入方法依赖的package包/类
public static MultiFileWrapper parse(ResourceLocator rl) {
AsciiLineReader reader = null;
try {
reader = ParsingUtils.openAsciiReader(rl);
String name = reader.readLine();
String serverURL = reader.readLine();
Map<String, ResourceLocator> locators = new LinkedHashMap();
String nextLine = null;
while ((nextLine = reader.readLine()) != null) {
String[] tokens = nextLine.split("\t");
String chr = tokens[0];
String file = tokens[1];
ResourceLocator loc = new ResourceLocator(file);
locators.put(chr, loc);
}
return new MultiFileWrapper(name, locators);
}
catch (IOException e) {
e.printStackTrace();
return null;
}
finally {
if (reader != null) {
reader.close();
}
}
}
示例10: parseHeader
import htsjdk.tribble.readers.AsciiLineReader; //导入方法依赖的package包/类
private void parseHeader() {
AsciiLineReader reader = null;
// The DataConsumer interface takes an array of data per position, however wig
// files contain a single data point. Create an "array" once that can
// be resused
try {
reader = ParsingUtils.openAsciiReader(resourceLocator);
while ((nextLine = reader.readLine()) != null && (nextLine.trim().length() > 0)) {
// Skip comment lines
if (nextLine.startsWith("#") || nextLine.startsWith("data") || nextLine.startsWith(
"browser") || nextLine.trim().length() == 0) {
continue;
}
if (nextLine.startsWith("track")) {
trackLine = nextLine;
} else {
return;
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
reader.close();
}
}
}
示例11: loadMutations
import htsjdk.tribble.readers.AsciiLineReader; //导入方法依赖的package包/类
/**
* Return a map of runId -> list of mutation objects. The "runId" field
* is the track identifier (name) for mutation files.
*
* @return
*/
private Map<String, List<htsjdk.tribble.Feature>> loadMutations() {
AsciiLineReader reader = null;
String nextLine = null;
try {
MUTCodec codec = new MUTCodec(locator.getPath(), genome);
Map<String, List<htsjdk.tribble.Feature>> mutationMap = new LinkedHashMap();
reader = ParsingUtils.openAsciiReader(locator);
// Skip header - handled in codec
while ((nextLine = reader.readLine()) != null) {
if (nextLine.startsWith("#")) continue;
else break;
}
while ((nextLine = reader.readLine()) != null) {
Mutation mut = codec.decode(nextLine);
if (mut != null) {
String sampleId = mut.getSampleId();
List<htsjdk.tribble.Feature> features = mutationMap.get(sampleId);
if (features == null) {
features = new ArrayList<Feature>();
mutationMap.put(sampleId, features);
}
features.add(mut);
}
}
return mutationMap;
} catch (IOException e) {
log.error("Error loading mutation file", e);
throw new DataLoadException("IO Exception: " + e.toString(), locator.getPath());
} finally {
reader.close();
}
}
示例12: parse
import htsjdk.tribble.readers.AsciiLineReader; //导入方法依赖的package包/类
public GWASData parse() throws IOException {
AsciiLineReader reader = null;
String nextLine = null;
int rowCounter = 0;
Set<String> chromos = new HashSet<String>();
GWASEntry lastEntry = null;
try {
reader = ParsingUtils.openAsciiReader(locator);
String headerLine = reader.readLine();
if (!this.columns.parseHeader(headerLine))
throw new ParserException("Error while parsing columns line.", 0, nextLine);
GWASData gData = new GWASData();
int indexCounter = 0;
while ((nextLine = reader.readLine()) != null && (nextLine.trim().length() > 0)) {
nextLine = nextLine.trim();
rowCounter++;
GWASEntry entry = parseLine(nextLine, rowCounter);
if (entry == null) continue;
gData.addLocation(entry.chr, entry.start);
gData.addValue(entry.chr, entry.p);
//Check that file is sorted
if(lastEntry != null){
if(entry.chr.equals(lastEntry.chr)){
if(entry.start < lastEntry.start){
throw new ParserException("File is not sorted, found start position lower than previous", rowCounter);
}
}else{
if(chromos.contains(entry.chr)){
throw new ParserException("File is not sorted; chromosome repeated", rowCounter);
}
chromos.add(entry.chr);
}
}
indexCounter++;
int indexSize = 10000;
if (indexCounter == indexSize) {
gData.getFileIndex().add((int) reader.getPosition());
indexCounter = 0;
}
lastEntry = entry;
}
return gData;
} catch (Exception e) {
if (nextLine != null && rowCounter != 0) {
throw new ParserException(e.getMessage(), e, rowCounter, nextLine);
} else {
throw new RuntimeException(e);
}
} finally {
if(reader != null) reader.close();
}
}