def loadStatsXml(args): dset = DataSet(args.infile, strict=args.strict) dset.loadStats(args.statsfile) if args.outfile: dset.write(args.outfile, validate=False) else: dset.write(args.infile, validate=False)
def test_build(self): # Progs like pbalign provide a .bam file: # e.g. d = DataSet("aligned.bam") # Something like the test files we have: inBam = data.getBam() self.assertTrue(inBam.endswith('.bam')) d = DataSet(inBam) # A UniqueId is generated, despite being a BAM input self.assertTrue(d.uuid != '') dOldUuid = d.uuid # They can write this BAM to an XML: # e.g. d.write("alignmentset.xml") outdir = tempfile.mkdtemp(suffix="dataset-unittest") outXml = os.path.join(outdir, 'tempfile.xml') d.write(outXml) # And then recover the same XML (or a different one): # e.g. d = DataSet("alignmentset.xml") d = DataSet(outXml) # The UniqueId will be the same self.assertTrue(d.uuid == dOldUuid) # Inputs can be many and varied ds1 = DataSet(data.getXml(11), data.getBam()) self.assertEquals(ds1.numExternalResources, 2) ds1 = DataSet(data.getFofn()) self.assertEquals(ds1.numExternalResources, 2) # New! Use the correct constructor: self.assertEquals(type(SubreadSet(data.getSubreadSet())).__name__, 'SubreadSet') # Even with untyped inputs self.assertTrue(str(SubreadSet(data.getBam())).startswith( '<SubreadSet')) self.assertEquals(type(SubreadSet(data.getBam())).__name__, 'SubreadSet') self.assertEquals(type(DataSet(data.getBam())).__name__, 'DataSet') # You can also cast up and down, but casting between siblings # is limited (abuse at your own risk) self.assertEquals( type(DataSet(data.getBam()).copy(asType='SubreadSet')).__name__, 'SubreadSet') self.assertEquals( type(SubreadSet(data.getBam()).copy(asType='DataSet')).__name__, 'DataSet') # Add external Resources: ds = DataSet() ds.externalResources.addResources(["IdontExist.bam"]) self.assertTrue( ds.externalResources[-1].resourceId == "IdontExist.bam") # Add an index file ds.externalResources[-1].addIndices(["IdontExist.bam.pbi"]) self.assertTrue( ds.externalResources[-1].indices[0].resourceId == "IdontExist.bam.pbi")
def test_build(self): # Progs like pbalign provide a .bam file: # e.g. d = DataSet("aligned.bam") # Something like the test files we have: inBam = data.getBam() self.assertTrue(inBam.endswith('.bam')) d = DataSet(inBam) # A UniqueId is generated, despite being a BAM input self.assertTrue(d.uuid != '') dOldUuid = d.uuid # They can write this BAM to an XML: # e.g. d.write("alignmentset.xml") outdir = tempfile.mkdtemp(suffix="dataset-unittest") outXml = os.path.join(outdir, 'tempfile.xml') d.write(outXml) # And then recover the same XML (or a different one): # e.g. d = DataSet("alignmentset.xml") d = DataSet(outXml) # The UniqueId will be the same self.assertTrue(d.uuid == dOldUuid) # Inputs can be many and varied ds1 = DataSet(data.getXml(11), data.getBam()) self.assertEquals(ds1.numExternalResources, 2) ds1 = DataSet(data.getFofn()) self.assertEquals(ds1.numExternalResources, 2) # New! Use the correct constructor: self.assertEquals( type(SubreadSet(data.getSubreadSet())).__name__, 'SubreadSet') # Even with untyped inputs self.assertTrue( str(SubreadSet(data.getBam())).startswith('<SubreadSet')) self.assertEquals( type(SubreadSet(data.getBam())).__name__, 'SubreadSet') self.assertEquals(type(DataSet(data.getBam())).__name__, 'DataSet') # You can also cast up and down, but casting between siblings # is limited (abuse at your own risk) self.assertEquals( type(DataSet(data.getBam()).copy(asType='SubreadSet')).__name__, 'SubreadSet') self.assertEquals( type(SubreadSet(data.getBam()).copy(asType='DataSet')).__name__, 'DataSet') # Add external Resources: ds = DataSet() ds.externalResources.addResources(["IdontExist.bam"]) self.assertTrue( ds.externalResources[-1].resourceId == "IdontExist.bam") # Add an index file ds.externalResources[-1].addIndices(["IdontExist.bam.pbi"]) self.assertTrue(ds.externalResources[-1].indices[0].resourceId == "IdontExist.bam.pbi")
def filterXml(args): log.error("Adding filters via CLI is temporarily out of order") exit(1) if args.infile.endswith('xml'): dataSet = DataSet(args.infile, strict=args.strict) filters = [] separators = ['<=', '>=', '!=', '==', '>', '<', '='] for filt in args.filters: for sep in separators: if sep in filt: param, condition = filt.split(sep) condition = sep + condition filters[param] = condition break dataSet.addFilters([filters]) log.info("{i} filters added".format(i=len(filters))) dataSet.write(args.outfile) else: raise IOError("No files found/found to be compatible")