extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/baf/MBafParser.java

Code
Comments
Other
Rev Date Author Line
5040 19 Oct 18 nicklas 1 package net.sf.basedb.reggie.baf;
5040 19 Oct 18 nicklas 2
5040 19 Oct 18 nicklas 3 import java.io.IOException;
5040 19 Oct 18 nicklas 4 import java.io.InputStream;
5040 19 Oct 18 nicklas 5 import java.util.List;
5040 19 Oct 18 nicklas 6
5040 19 Oct 18 nicklas 7 import net.sf.basedb.reggie.vcf.VcfData;
5040 19 Oct 18 nicklas 8 import net.sf.basedb.reggie.vcf.VcfParser;
5040 19 Oct 18 nicklas 9
5040 19 Oct 18 nicklas 10 /**
5040 19 Oct 18 nicklas 11   A parser implementation for VCF files that calculates and aggregates mBAF
5040 19 Oct 18 nicklas 12   information from SNPs. 
5040 19 Oct 18 nicklas 13   
5040 19 Oct 18 nicklas 14   ....
5040 19 Oct 18 nicklas 15
5040 19 Oct 18 nicklas 16   @author nicklas
5040 19 Oct 18 nicklas 17   @since 4.20
5040 19 Oct 18 nicklas 18 */
5040 19 Oct 18 nicklas 19 public class MBafParser 
5040 19 Oct 18 nicklas 20 {
5040 19 Oct 18 nicklas 21
5040 19 Oct 18 nicklas 22   private final VcfParser vcfParser;
5040 19 Oct 18 nicklas 23   private final List<Region> regions;
5040 19 Oct 18 nicklas 24   private final MBafOptions options;
5040 19 Oct 18 nicklas 25   
5040 19 Oct 18 nicklas 26   /**
5040 19 Oct 18 nicklas 27     Creates a parser with default regions and options.
5040 19 Oct 18 nicklas 28   */
5040 19 Oct 18 nicklas 29   public MBafParser()
5040 19 Oct 18 nicklas 30   {
5040 19 Oct 18 nicklas 31     this(Region.defaultRegions(), new MBafOptions());
5040 19 Oct 18 nicklas 32   }
5040 19 Oct 18 nicklas 33   
5040 19 Oct 18 nicklas 34   /**
5040 19 Oct 18 nicklas 35     Create a parser for the given regions and options.
5040 19 Oct 18 nicklas 36   */
5040 19 Oct 18 nicklas 37   public MBafParser(List<Region> regions, MBafOptions options)
5040 19 Oct 18 nicklas 38   {
5040 19 Oct 18 nicklas 39     this.vcfParser = new VcfParser();
5040 19 Oct 18 nicklas 40     this.regions = regions == null ? Region.defaultRegions() : regions;
5040 19 Oct 18 nicklas 41     this.options = options == null ? new MBafOptions() : options;
5040 19 Oct 18 nicklas 42   }
5040 19 Oct 18 nicklas 43   
5040 19 Oct 18 nicklas 44   /**
5045 22 Oct 18 nicklas 45     Get the underlying VcfParser that is used by this parser.
5045 22 Oct 18 nicklas 46   */
5045 22 Oct 18 nicklas 47   public VcfParser getVcfParser()
5045 22 Oct 18 nicklas 48   {
5045 22 Oct 18 nicklas 49     return vcfParser;
5045 22 Oct 18 nicklas 50   }
5045 22 Oct 18 nicklas 51   
5045 22 Oct 18 nicklas 52   /**
5050 24 Oct 18 nicklas 53     Get the options used by this parser.
5050 24 Oct 18 nicklas 54   */
5050 24 Oct 18 nicklas 55   public MBafOptions getOptions()
5050 24 Oct 18 nicklas 56   {
5050 24 Oct 18 nicklas 57     return options;
5050 24 Oct 18 nicklas 58   }
5050 24 Oct 18 nicklas 59   
5050 24 Oct 18 nicklas 60   /**
5040 19 Oct 18 nicklas 61     Parse a VCF file and extract mBAF information.
5040 19 Oct 18 nicklas 62   */
5040 19 Oct 18 nicklas 63   public BafData parse(InputStream in, String fileName)
5040 19 Oct 18 nicklas 64     throws IOException
5040 19 Oct 18 nicklas 65   {
5045 22 Oct 18 nicklas 66     BafData bafData = new BafData(regions, options);
5051 24 Oct 18 nicklas 67     VcfData vcfData = vcfParser.parse(in, fileName, bafData.getVcfFilter());
5045 22 Oct 18 nicklas 68     bafData.setVcfData(vcfData);
5040 19 Oct 18 nicklas 69     return bafData;
5040 19 Oct 18 nicklas 70   }
5040 19 Oct 18 nicklas 71
5040 19 Oct 18 nicklas 72 }