Mercurial > repos > fubar > jbrowse2
comparison jbrowse2.py @ 120:af482048ca1a draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 59fe39774d791bc684811b6ce03e13ef093d074e
author | fubar |
---|---|
date | Tue, 24 Sep 2024 03:57:09 +0000 |
parents | 794aecef8327 |
children | 478ee3e780de |
comparison
equal
deleted
inserted
replaced
119:2fff478aca4b | 120:af482048ca1a |
---|---|
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import re | 10 import re |
11 import shutil | 11 import shutil |
12 import ssl | 12 import ssl |
13 import string | |
13 import struct | 14 import struct |
14 import subprocess | 15 import subprocess |
15 import tempfile | 16 import tempfile |
16 import urllib.request | 17 import urllib.request |
17 import xml.etree.ElementTree as ET | 18 import xml.etree.ElementTree as ET |
1598 parser.add_argument("--outdir", help="Output directory", default="out") | 1599 parser.add_argument("--outdir", help="Output directory", default="out") |
1599 parser.add_argument("--version", "-V", action="version", version=JB2VER) | 1600 parser.add_argument("--version", "-V", action="version", version=JB2VER) |
1600 args = parser.parse_args() | 1601 args = parser.parse_args() |
1601 tree = ET.parse(args.xml) | 1602 tree = ET.parse(args.xml) |
1602 root = tree.getroot() | 1603 root = tree.getroot() |
1603 | 1604 removeMe = string.punctuation.replace('.','').replace('/','').replace('-','') |
1605 nopunct = str.maketrans(dict.fromkeys(removeMe)) | |
1604 # This should be done ASAP | 1606 # This should be done ASAP |
1605 GALAXY_INFRASTRUCTURE_URL = root.find("metadata/galaxyUrl").text | 1607 GALAXY_INFRASTRUCTURE_URL = root.find("metadata/galaxyUrl").text |
1606 # Sometimes this comes as `localhost` without a protocol | 1608 # Sometimes this comes as `localhost` without a protocol |
1607 if not GALAXY_INFRASTRUCTURE_URL.startswith("http"): | 1609 if not GALAXY_INFRASTRUCTURE_URL.startswith("http"): |
1608 # so we'll prepend `http://` and hope for the best. Requests *should* | 1610 # so we'll prepend `http://` and hope for the best. Requests *should* |
1615 trackI = 0 | 1617 trackI = 0 |
1616 for ass in root.findall("assembly"): | 1618 for ass in root.findall("assembly"): |
1617 genomes = [ | 1619 genomes = [ |
1618 { | 1620 { |
1619 "path": x.attrib["path"], | 1621 "path": x.attrib["path"], |
1620 "label": x.attrib["label"].split(" ")[0].replace(",", ""), | 1622 "label": x.attrib["label"].split(" ")[0].translate(nopunct), |
1621 "useuri": x.attrib["useuri"], | 1623 "useuri": x.attrib["useuri"], |
1622 "meta": metadata_from_node(x.find("metadata")), | 1624 "meta": metadata_from_node(x.find("metadata")), |
1623 } | 1625 } |
1624 for x in ass.findall("metadata/genomes/genome") | 1626 for x in ass.findall("metadata/genomes/genome") |
1625 ] | 1627 ] |
1653 for x in trackfiles: | 1655 for x in trackfiles: |
1654 isBed = False | 1656 isBed = False |
1655 if x.attrib['ext'] == "bed": | 1657 if x.attrib['ext'] == "bed": |
1656 isBed = True | 1658 isBed = True |
1657 track_conf["label"] = "%s_%d" % ( | 1659 track_conf["label"] = "%s_%d" % ( |
1658 x.attrib["label"].replace(" ", "_").replace(",", "_").replace("/", "_"), | 1660 x.attrib["label"].translate(nopunct), |
1659 trackI, | 1661 trackI, |
1660 ) | 1662 ) |
1661 trackI += 1 | 1663 trackI += 1 |
1662 track_conf["useuri"] = x.attrib["useuri"] | 1664 track_conf["useuri"] = x.attrib["useuri"] |
1663 if is_multi_bigwig: | 1665 if is_multi_bigwig: |
1664 multi_bigwig_paths.append( | 1666 multi_bigwig_paths.append( |
1665 ( | 1667 ( |
1666 track_conf["label"], | 1668 track_conf["label"].translate(nopunct), |
1667 track_conf["useuri"], | 1669 track_conf["useuri"], |
1668 os.path.realpath(x.attrib["path"]), | 1670 os.path.realpath(x.attrib["path"]), |
1669 ) | 1671 ) |
1670 ) | 1672 ) |
1671 else: | 1673 else: |