本文整理汇总了Java中htsjdk.tribble.readers.LineIteratorImpl类的典型用法代码示例。如果您正苦于以下问题:Java LineIteratorImpl类的具体用法?Java LineIteratorImpl怎么用?Java LineIteratorImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LineIteratorImpl类属于htsjdk.tribble.readers包,在下文中一共展示了LineIteratorImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChromosomes
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的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;
}
示例2: grep
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的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;
}
示例3: testDecodeHeader2
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
@Test
public void testDecodeHeader2(){
TableCodec tc = new TableCodec();
final String str2= "1:1 1 2 3";
LineReader reader= makeReader(asList("HEADER a b c", str2));
LineIterator li= new LineIteratorImpl(reader);
List<String> hd = tc.readActualHeader(li);
Assert.assertEquals(hd, asList("HEADER", "a", "b", "c"));
final TableFeature decode = tc.decode(str2);
Assert.assertEquals(decode.get("a"), "1");
Assert.assertEquals(decode.get("b"), "2");
Assert.assertEquals(decode.get("c"), "3");
Assert.assertEquals(decode.getLocation().getContig(), "1");
Assert.assertEquals(decode.getContig(), "1");
Assert.assertEquals(decode.getLocation().getStart(), 1);
Assert.assertEquals(decode.getLocation().getEnd(), 1);
}
示例4: MUTCodec
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
public MUTCodec(String path, Genome genome) {
super(Mutation.class);
this.path = path;
this.genome = genome;
try {
LineIterator reader = new LineIteratorImpl(new AsciiLineReader(ParsingUtils.openInputStream(path)));
readActualHeader(reader);
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
示例5: decodeAll
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
public Iterator<D> decodeAll(InputStream is, boolean strictParsing) throws IOException {
List<D> featuresList = new ArrayList<D>();
String line;
D feat;
LineIterator lrw = new LineIteratorImpl(new AsciiLineReader(is));
lineFeatureDecoder.readActualHeader(lrw);
while (lrw.hasNext()) {
line = lrw.next();
try {
feat = decode(line);
if (feat != null) {
featuresList.add(feat);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
if (strictParsing) {
throw new RuntimeException(e);
}
}
}
is.close();
return featuresList.iterator();
}
示例6: testDecodeLoc
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
@Test(dataProvider = "stringFeature")
private void testDecodeLoc(final String pileupString, final SAMPileupFeature expected) throws Exception {
final Feature feature = CODEC.decodeLoc(new LineIteratorImpl(makeReader(pileupString)));
Assert.assertEquals(feature.getContig(), expected.getContig());
Assert.assertEquals(feature.getStart(), expected.getStart());
Assert.assertEquals(feature.getEnd(), expected.getEnd());
}
示例7: testDecodeHeader
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
@Test
public void testDecodeHeader(){
TableCodec tc = new TableCodec();
LineReader reader= makeReader(asList("HEADER a b c"));
LineIterator li= new LineIteratorImpl(reader);
List<String> hd = tc.readActualHeader(li);
Assert.assertEquals(hd, asList("HEADER", "a", "b", "c"));
}
示例8: testDecodeFailsNoHeader
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
@Test(expectedExceptions = UserException.MalformedFile.class)
public void testDecodeFailsNoHeader(){
TableCodec tc = new TableCodec();
LineReader reader= makeReader(asList("1:1 1 2 3"));
LineIterator li= new LineIteratorImpl(reader);
tc.readActualHeader(li);
}
示例9: testDecodeOnlyComments
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
@Test
public void testDecodeOnlyComments(){
TableCodec tc = new TableCodec();
LineReader reader= makeReader(asList("#HEADER a b c", "#HEADER d e f"));
LineIterator li= new LineIteratorImpl(reader);
final List<String> strings = tc.readActualHeader(li);
Assert.assertEquals(strings, emptyList());
}
示例10: testTwoHeaders
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
@Test
public void testTwoHeaders(){
TableCodec tc = new TableCodec();
LineReader reader= makeReader(asList("HEADER a b c", "HEADER d e f"));
LineIterator li= new LineIteratorImpl(reader);
final List<String> strings = tc.readActualHeader(li);
Assert.assertEquals(strings, asList("HEADER", "a", "b", "c"));
}
示例11: testTwoHeadersFailsOnRepeat
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
@Test(expectedExceptions = UserException.MalformedFile.class)
public void testTwoHeadersFailsOnRepeat(){
TableCodec tc = new TableCodec();
Assert.assertEquals(tc.readActualHeader(new LineIteratorImpl(makeReader(asList("HEADER a b c")))), asList("HEADER", "a", "b", "c"));
Assert.assertEquals(tc.readActualHeader(new LineIteratorImpl(makeReader(asList("HEADER a b c")))), asList("HEADER", "a", "b", "c"));
}
示例12: testDecodeComment
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
@Test
public void testDecodeComment(){
TableCodec tc = new TableCodec();
LineReader reader= makeReader(asList("#HEADER a b c", "HEADER d e f"));
LineIterator li= new LineIteratorImpl(reader);
List<String> hd = tc.readActualHeader(li);
Assert.assertEquals(hd, asList("HEADER", "d", "e", "f"));
}
示例13: loadEnsemblProtein
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
protected void loadEnsemblProtein() throws IOException
{
BiomartQuery q=new BiomartQuery();
q.setDataSetName("hsapiens_gene_ensembl");
q.setAttributes(
"chromosome_name",
"start_position",
"end_position",
"ensembl_peptide_id"
);
q.setUniqRows(true);
LOG.info("sending "+q);
LOG.info("invoking biomart "+q);
LineReader r=q.execute();
LineIteratorImpl iter = new LineIteratorImpl(r);
while(iter.hasNext()) {
String line=iter.next();
String param[]=line.split("[\t]");
if(param.length<4 || param[3].isEmpty()) continue;
String ensp=param[3];
if(!ensemblProtein2doid.containsKey(ensp)) continue;
ensemblProteinMap.put(new Interval(param[0],Integer.parseInt(param[1]),Integer.parseInt(param[2])),ensp);
}
iter.close();
r.close();
}
示例14: doWork
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
@SuppressWarnings("resource")
protected int doWork(InputStream in,PrintStream out)
throws IOException
{
final int chromColumn0=chromColumn1-1;
Pattern tab=Pattern.compile("[\t]");
LineIterator lr=new LineIteratorImpl(new AsciiLineReader(in));
while(lr.hasNext())
{
String line=lr.next();
if(BedLine.isBedHeader(line))
{
out.println(line);
continue;
}
final String tokens[]=tab.split(line, (chromColumn0+2));
if(chromColumn0 >=tokens.length) throw new IOException("Bad BED line : "+line+" extected at least "+(chromColumn0+2)+" columns");
final String chrom=convertName(tokens[chromColumn0]);
if(chrom==null) continue;
for(int i=0;i< tokens.length;++i)
{
if(i>0) out.print("\t");
out.print(i==chromColumn0?chrom:tokens[i]);
}
out.println();
}
out.flush();
return 0;
}
示例15: openFileForLineIterator
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
/** @return a LineIterator that should be closed with CloserUtils */
public static LineIterator openFileForLineIterator(File file) throws IOException
{
return new LineIteratorImpl(openFileForLineReader(file));
}