本文整理汇总了Java中htsjdk.tribble.readers.LineIteratorImpl类的典型用法代码示例。如果您正苦于以下问题:Java LineIteratorImpl类的具体用法?Java LineIteratorImpl怎么用?Java LineIteratorImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LineIteratorImpl类属于htsjdk.tribble.readers包,在下文中一共展示了LineIteratorImpl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:oicr-gsi,项目名称:gatk3,代码行数:27,代码来源:BEDFileUtils.java
示例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;
}
开发者ID:broadinstitute,项目名称:picard,代码行数:25,代码来源:FindMendelianViolationsTest.java
示例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);
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:19,代码来源:TableCodecUnitTest.java
示例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);
}
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:12,代码来源:MUTCodec.java
示例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();
}
开发者ID:hyounesy,项目名称:ALEA,代码行数:28,代码来源:AsciiDecoder.java
示例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());
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:8,代码来源:SAMPileupCodecUnitTest.java
示例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"));
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:9,代码来源:TableCodecUnitTest.java
示例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);
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:8,代码来源:TableCodecUnitTest.java
示例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());
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:9,代码来源:TableCodecUnitTest.java
示例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"));
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:9,代码来源:TableCodecUnitTest.java
示例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"));
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:8,代码来源:TableCodecUnitTest.java
示例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"));
}
开发者ID:broadinstitute,项目名称:gatk,代码行数:9,代码来源:TableCodecUnitTest.java
示例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();
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:30,代码来源:AbstractVCFDiseaseOntology.java
示例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;
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:33,代码来源:ConvertBedChromosomes.java
示例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));
}
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:6,代码来源:IOUtils.java
示例16: openStreamForLineIterator
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
/** @return a LineIterator that should be closed with CloserUtils */
public static LineIterator openStreamForLineIterator(final InputStream in) throws IOException
{
return new LineIteratorImpl(openStreamForLineReader(in));
}
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:6,代码来源:IOUtils.java
示例17: openURIForLineIterator
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
/** @return a LineIterator that should be closed with CloserUtils */
public static LineIterator openURIForLineIterator(String uri) throws IOException
{
return new LineIteratorImpl(openURIForLineReader(uri));
}
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:6,代码来源:IOUtils.java
示例18: loadEntrezGenes
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
protected void loadEntrezGenes(SAMSequenceDictionary dict) throws IOException
{
this.ncbiGeneMap=new IntervalTreeMap<Integer>();
BiomartQuery q=new BiomartQuery();
q.setDataSetName("hsapiens_gene_ensembl");
q.setAttributes(
"chromosome_name",
"start_position",
"end_position",
"entrezgene"
);
q.setUniqRows(true);
LOG.info("sending "+q);
LOG.info("invoking biomart "+q);
LineReader r=q.execute();
@SuppressWarnings("resource")
LineIterator lr=new LineIteratorImpl(r);
Pattern pattern=Pattern.compile("[\t]");
while(lr.hasNext())
{
String line=lr.next();
String param[]=pattern.split(line);
if(param.length<4 || param[3].isEmpty()) continue;
SAMSequenceRecord rec=null;
if((rec=dict.getSequence(param[0]))==null) continue;
try
{
int start=Integer.parseInt(param[0]);
int end=Integer.parseInt(param[1]);
int ncbiGene=Integer.parseInt(param[3]);
if(!gene2doid.containsKey(ncbiGene)) continue;
ncbiGeneMap.put(new Interval(rec.getSequenceName(),start,end),ncbiGene);
}
catch (Exception e)
{
LOG.warning(e);
continue;
}
}
r.close();
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:46,代码来源:AbstractVCFDiseaseOntology.java
示例19: scan
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
private void scan(Graphics2D g,InputStream input) throws IOException
{
Set<String> unknownC=new HashSet<String>();
Pattern tab=Pattern.compile("[\t]");
LineIterator in=new LineIteratorImpl(new SynchronousLineReader(input));
while(in.hasNext())
{
String line=in.next();
String tokens[]=tab.split(line,5);
if(tokens.length<4)
{
LOG.warning("Ignoring "+line);
continue;
}
SAMSequenceRecord rec=this.context.getDictionary().getSequence(tokens[0]);
if(rec==null)
{
LOG.warning("unknown chromosome "+tokens[0]);
continue;
}
String country=tokens[3].toLowerCase().replaceAll("[ ]", "");
Shape shape=this.country2shape.get(country);
if(shape==null)
{
if(!unknownC.contains(country))
{
unknownC.add(country);
LOG.warning("unknown country "+country);
}
continue;
}
seen.incr(country);
int midpos=(Integer.parseInt(tokens[1])+Integer.parseInt(tokens[2]))/2;
//country center
Point2D.Double pt1 =new Point2D.Double(shape.getBounds2D().getCenterX(),shape.getBounds2D().getCenterY());
//circle point
Point2D pt3= this.context.convertPositionToPoint(tokens[0],midpos,getRadiusInt());
double angle= this.context.convertPositionToRadian(rec, midpos);
double angle2=angle-=Math.PI/10.0;
double distance13= context.getCenter().distance(new Point2D.Double(
(pt1.getX()+pt3.getX())/2.0,
(pt1.getY()+pt3.getY())/2.0
));
//mid point
Point2D pt2 =new Point2D.Double(
context.getCenterX()+distance13*Math.cos(angle2),
context.getCenterX()+distance13*Math.sin(angle2)
);
Composite old=g.getComposite();
Stroke olds=g.getStroke();
g.setStroke(new BasicStroke(0.8f));
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.02f));
g.setColor(Color.DARK_GRAY);
GeneralPath p=new GeneralPath();
p.moveTo(pt1.getX(), pt1.getY());
p.quadTo(pt2.getX(), pt2.getY(),pt3.getX(), pt3.getY());
p.closePath();
g.draw(p);
g.setComposite(old);
g.setStroke(olds);
}
CloserUtil.close(in);
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:66,代码来源:WorldMapGenome.java
示例20: doWork
import htsjdk.tribble.readers.LineIteratorImpl; //导入依赖的package包/类
@Override
public int doWork(List<String> args) {
if(jasparUri==null)
{
LOG.error("Undefined jaspar-uri");
return -1;
}
PrintWriter out=null;
try
{
out = super.openFileOrStdoutAsPrintWriter(OUT);
LOG.info("Reading "+jasparUri);
LineReader lr= IOUtils.openURIForLineReader(jasparUri);
LineIterator liter=new LineIteratorImpl(lr);
Iterator<Matrix> miter=Matrix.iterator(liter);
while(miter.hasNext())
{
Matrix matrix = miter.next();
this.jasparDb.add(matrix.convertToPWM());
}
lr.close();
LOG.info("JASPAR size: "+this.jasparDb.size());
if(args.isEmpty())
{
LOG.info("Reading from stdin");
run(out,new InputStreamReader(stdin()));
}
else
{
for(final String fname:args)
{
LOG.info("Opening "+fname);
Reader in=IOUtils.openURIForBufferedReading(fname);
run(out,in);
in.close();
}
}
out.flush();
out.close();
out=null;
return 0;
}
catch(Throwable err)
{
LOG.error(err);
return -1;
}
finally
{
CloserUtil.close(out);
}
}
开发者ID:lindenb,项目名称:jvarkit,代码行数:56,代码来源:GenomicJaspar.java
注:本文中的htsjdk.tribble.readers.LineIteratorImpl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论