コード例 #1
0
ファイル: gbsubmit.py プロジェクト: tanghaibao/jcvi
def parse_description(s):
    """
    Returns a dictionary based on the FASTA header, assuming JCVI data
    """
    s = "".join(s.split()[1:]).replace("/", ";")
    a = parse_qs(s)
    return a
コード例 #2
0
ファイル: gbsubmit.py プロジェクト: wroldwiedbwe/jcvi
def parse_description(s):
    """
    Returns a dictionary based on the FASTA header, assuming JCVI data
    """
    s = "".join(s.split()[1:]).replace("/", ";")
    a = parse_qs(s)
    return a
コード例 #3
0
ファイル: gff.py プロジェクト: linlifeng/jcvi
def make_attributes(s, gff3=True):
    """
    In GFF3, the last column is typically:
    ID=cds00002;Parent=mRNA00002;

    In GFF2, the last column is typically:
    Gene 22240.t000374; Note "Carbonic anhydrase"
    """
    if gff3:
        d = parse_qs(s)

    else:
        attributes = s.split("; ")
        d = DefaultOrderedDict(list)
        for a in attributes:
            key, val = a.strip().split(' ', 1)
            val = val.replace('"', '')
            d[key].append(val)

    for key, val in d.items():
        d[key] = list(flatten([v.split(",") for v in val]))

    return d
コード例 #4
0
def make_attributes(s, gff3=True):
    """
    In GFF3, the last column is typically:
    ID=cds00002;Parent=mRNA00002;

    In GFF2, the last column is typically:
    Gene 22240.t000374; Note "Carbonic anhydrase"
    """
    if gff3:
        d = parse_qs(s)

    else:
        attributes = s.split("; ")
        d = DefaultOrderedDict(list)
        for a in attributes:
            key, val = a.strip().split(' ', 1)
            val = val.replace('"', '')
            d[key].append(val)

    for key, val in d.items():
        d[key] = list(flatten([v.split(",") for v in val]))

    return d
コード例 #5
0
def test_parse_qs(querystr, expected):
    attributes = parse_qs(querystr)
    assert attributes == expected