本文整理汇总了Python中htsworkflow.pipelines.ElementTree类的典型用法代码示例。如果您正苦于以下问题:Python ElementTree类的具体用法?Python ElementTree怎么用?Python ElementTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ElementTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_runfolder
def test_runfolder(self):
runs = runfolder.get_runs(self.runfolder_dir)
# do we get the flowcell id from the filename?
self.assertEqual(len(runs), 1)
# firecrest's date depends on filename not the create time.
name = 'run_207BTAAXX_2009-02-22.xml'
self.assertEqual(runs[0].serialization_filename, name)
# do we get the flowcell id from the FlowcellId.xml file
make_flowcell_id(self.runfolder_dir, '207BTAAXY')
runs = runfolder.get_runs(self.runfolder_dir)
self.assertEqual(len(runs), 1)
name = 'run_207BTAAXY_2009-02-22.xml'
self.assertEqual(runs[0].serialization_filename, name)
r1 = runs[0]
xml = r1.get_elements()
xml_str = ElementTree.tostring(xml)
r2 = runfolder.PipelineRun(xml=xml)
self.assertEqual(r1.serialization_filename, r2.serialization_filename)
self.assertNotEqual(r2.image_analysis, None)
self.assertNotEqual(r2.bustard, None)
self.assertNotEqual(r2.gerald, None)
示例2: bustard_from_hiseq
def bustard_from_hiseq(pathname, config_filename):
b = Bustard()
b.pathname = pathname
bustard_config_root = ElementTree.parse(config_filename)
b.bustard_config = bustard_config_root.getroot()
add_phasing(b)
return b
示例3: gerald
def gerald(pathname):
LOGGER.info("Parsing gerald config.xml")
pathname = os.path.expanduser(pathname)
config_pathname = os.path.join(pathname, 'config.xml')
config_tree = ElementTree.parse(config_pathname).getroot()
# parse Summary.htm file
summary_xml = os.path.join(pathname, 'Summary.xml')
summary_htm = os.path.join(pathname, 'Summary.htm')
report_summary = os.path.join(pathname, '..', 'Data',
'reports', 'Summary', )
if os.path.exists(summary_xml):
g = Gerald(pathname = pathname, tree=config_tree)
LOGGER.info("Parsing Summary.xml")
g.summary = SummaryGA(summary_xml)
g.eland_results = eland(g.pathname, g)
elif os.path.exists(summary_htm):
g = Gerald(pathname=pathname, tree=config_tree)
LOGGER.info("Parsing Summary.htm")
g.summary = SummaryGA(summary_htm)
g.eland_results = eland(g.pathname, g)
elif os.path.isdir(report_summary):
g = CASAVA(pathname=pathname, tree=config_tree)
LOGGER.info("Parsing %s" % (report_summary,))
g.summary = SummaryHiSeq(report_summary)
g.eland_results = eland(g.pathname, g)
# parse eland files
return g
示例4: test_runfolder
def test_runfolder(self):
runs = runfolder.get_runs(self.runfolder_dir)
# do we get the flowcell id from the filename?
self.assertEqual(len(runs), 1)
name = 'run_4286GAAXX_%s.xml' % ( date.today().strftime('%Y-%m-%d'),)
self.assertEqual(runs[0].serialization_filename, name)
self.assertEqual(runs[0].runfolder_name, '090220_HWI-EAS229_0093_30VR0AAXX')
# do we get the flowcell id from the FlowcellId.xml file
make_flowcell_id(self.runfolder_dir, '207BTAAXY')
runs = runfolder.get_runs(self.runfolder_dir)
self.assertEqual(len(runs), 1)
name = 'run_207BTAAXY_%s.xml' % ( date.today().strftime('%Y-%m-%d'),)
self.assertEqual(runs[0].serialization_filename, name)
r1 = runs[0]
xml = r1.get_elements()
xml_str = ElementTree.tostring(xml)
r2 = runfolder.PipelineRun(xml=xml)
self.assertEqual(r1.serialization_filename, r2.serialization_filename)
self.assertNotEqual(r2.image_analysis, None)
self.assertNotEqual(r2.bustard, None)
self.assertNotEqual(r2.gerald, None)
示例5: test_genomesizes_xml
def test_genomesizes_xml(self):
xml = ElementTree.fromstring(MINI_GENOME_XML)
g = genomemap.GenomeMap()
g.build_map_from_element(xml)
self.assertTrue('chr1.fa' in g)
self.assertEqual(g['chr1.fa'], 'mm9/chr1.fa')
示例6: _initialize_from_file
def _initialize_from_file(self, pathname):
path, name = os.path.split(pathname)
basename, ext = os.path.splitext(name)
# the last character of the param base filename should be the
# lane number
tree = ElementTree.parse(pathname).getroot()
self.set_elements(tree)
self.lane = int(basename[-1])
示例7: _get_flowcell_id_from_flowcellid
def _get_flowcell_id_from_flowcellid(self):
"""Extract flowcell id from a Config/FlowcellId.xml file
:return: flowcell_id or None if not found
"""
config_dir = os.path.join(self.pathname, 'Config')
flowcell_id_path = os.path.join(config_dir, 'FlowcellId.xml')
if os.path.exists(flowcell_id_path):
flowcell_id_tree = ElementTree.parse(flowcell_id_path)
return flowcell_id_tree.findtext('Text')
示例8: main
def main(cmdline=None):
"""Run eland extraction against the specified gerald directory"""
from optparse import OptionParser
parser = OptionParser("%prog: <gerald dir>+")
opts, args = parser.parse_args(cmdline)
logging.basicConfig(level=logging.DEBUG)
for a in args:
LOGGER.info("Starting scan of %s" % (a,))
e = eland(a)
print(ElementTree.tostring(e.get_elements()))
return
示例9: main
def main(cmdline):
parser = make_cmdline_parser()
opts, args = parser.parse_args(cmdline)
for bustard_dir in args:
print(u'analyzing bustard directory: ' + str(bustard_dir))
bustard_object = bustard(bustard_dir)
bustard_object.dump()
bustard_object2 = Bustard(xml=bustard_object.get_elements())
print('-------------------------------------')
bustard_object2.dump()
print('=====================================')
b1_tree = bustard_object.get_elements()
b1 = ElementTree.tostring(b1_tree).split(os.linesep)
b2_tree = bustard_object2.get_elements()
b2 = ElementTree.tostring(b2_tree).split(os.linesep)
for line1, line2 in zip(b1, b2):
if b1 != b2:
print("b1: ", b1)
print("b2: ", b2)
示例10: load_pipeline_run_xml
def load_pipeline_run_xml(pathname):
"""
Load and instantiate a Pipeline run from a run xml file
:Parameters:
- `pathname` location of an run xml file
:Returns: initialized PipelineRun object
"""
tree = ElementTree.parse(pathname).getroot()
run = PipelineRun(xml=tree)
return run
示例11: load
def load(self, filename):
"""Load a run xml into this object.
:Parameters:
- `filename` location of a run xml file
:Types:
- `filename` str
"""
LOGGER.info("Loading run report from " + filename)
tree = ElementTree.parse(filename).getroot()
self.set_elements(tree)
示例12: _get_flowcell_id_from_runinfo
def _get_flowcell_id_from_runinfo(self):
"""Read RunInfo file for flowcell id
:return: flowcell_id or None if not found
"""
runinfo = os.path.join(self.pathname, 'RunInfo.xml')
if os.path.exists(runinfo):
tree = ElementTree.parse(runinfo)
root = tree.getroot()
fc_nodes = root.xpath('/RunInfo/Run/Flowcell')
if len(fc_nodes) == 1:
return fc_nodes[0].text
示例13: load_ipar_param_tree
def load_ipar_param_tree(paramfile):
"""
look for a .param file and load it if it is an IPAR tree
"""
tree = ElementTree.parse(paramfile).getroot()
run = tree.find('Run')
if run.attrib.get('Name', None) in SOFTWARE_NAMES:
return run
else:
LOGGER.info("No run found")
return None
示例14: test_eland
def test_eland(self):
hg_map = {'Lambda.fa': 'Lambda.fa'}
for i in range(1,22):
short_name = 'chr%d.fa' % (i,)
long_name = 'hg18/chr%d.fa' % (i,)
hg_map[short_name] = long_name
genome_maps = { 1:hg_map, 2:hg_map, 3:hg_map, 4:hg_map,
5:hg_map, 6:hg_map, 7:hg_map, 8:hg_map }
eland = gerald.eland(self.gerald_dir, genome_maps=genome_maps)
for key in eland:
lane = eland[key]
self.assertEqual(lane.reads, 6)
self.assertEqual(lane.sample_name, "s")
self.assertEqual(lane.lane_id, key.lane)
self.assertEqual(len(lane.mapped_reads), 17)
self.assertEqual(lane.mapped_reads['hg18/chr5.fa'], 4)
self.assertEqual(lane.mapped_reads['spike.fa/sample1'], 1)
self.assertEqual(lane.mapped_reads['spike.fa/sample2'], 1)
self.assertEqual(lane.match_codes['U0'], 3)
self.assertEqual(lane.match_codes['R0'], 2)
self.assertEqual(lane.match_codes['U1'], 1)
self.assertEqual(lane.match_codes['R1'], 9)
self.assertEqual(lane.match_codes['U2'], 0)
self.assertEqual(lane.match_codes['R2'], 12)
self.assertEqual(lane.match_codes['NM'], 1)
self.assertEqual(lane.match_codes['QC'], 0)
xml = eland.get_elements()
# just make sure that element tree can serialize the tree
xml_str = ElementTree.tostring(xml)
e2 = gerald.ELAND(xml=xml)
for key in eland:
l1 = eland[key]
l2 = e2[key]
self.assertEqual(l1.reads, l2.reads)
self.assertEqual(l1.sample_name, l2.sample_name)
self.assertEqual(l1.lane_id, l2.lane_id)
self.assertEqual(len(l1.mapped_reads), len(l2.mapped_reads))
self.assertEqual(len(l1.mapped_reads), 17)
for k in l1.mapped_reads.keys():
self.assertEqual(l1.mapped_reads[k],
l2.mapped_reads[k])
self.assertEqual(len(l1.match_codes), 9)
self.assertEqual(len(l1.match_codes), len(l2.match_codes))
for k in l1.match_codes.keys():
self.assertEqual(l1.match_codes[k],
l2.match_codes[k])
示例15: test_ipar
def test_ipar(self):
"""
Construct a firecrest object
"""
i = ipar.ipar(self.image_analysis_dir)
self.assertEqual(i.version, '1.4.6.0')
self.assertEqual(i.start, 1)
self.assertEqual(i.stop, 38)
xml = i.get_elements()
# just make sure that element tree can serialize the tree
xml_str = ElementTree.tostring(xml)
i2 = ipar.IPAR(xml=xml)
self.assertEqual(i.version, i2.version)
self.assertEqual(i.start, i2.start)
self.assertEqual(i.stop, i2.stop)
self.assertEqual(i.date, i2.date)