Code Duplication    Length = 17-25 lines in 2 locations

rna_tools/rna_tools_lib.py 2 locations

@@ 2394-2418 (lines=25) @@
2391
    return npath
2392
2393
2394
def fetch_ba(pdb_id, path="."):
2395
    """fetch biological assembly pdb file from RCSB.org
2396
2397
    >>> fetch_ba('1xjr')
2398
    ...
2399
    """
2400
    try:
2401
        import urllib3
2402
    except ImportError:
2403
        print('urllib3 is required')
2404
        return
2405
    http = urllib3.PoolManager()
2406
    # try:
2407
    response = http.request('GET', url='https://files.rcsb.org/download/' +
2408
                            pdb_id.lower() + '.pdb1')
2409
    if not response.status == 200:
2410
        raise PDBFetchError()
2411
    txt = response.data
2412
2413
    npath = path + os.sep + pdb_id + '_ba.pdb'
2414
    print('downloading...' + npath)
2415
    with open(npath, 'wb') as f:
2416
        f.write(txt)
2417
    print('ok')
2418
    return pdb_id + '_ba.pdb'
2419
2420
2421
def fetch_cif_ba(cif_id, path="."):
@@ 2421-2437 (lines=17) @@
2418
    return pdb_id + '_ba.pdb'
2419
2420
2421
def fetch_cif_ba(cif_id, path="."):
2422
    """fetch biological assembly cif file from RCSB.org"""
2423
    import urrlib3
2424
    http = urllib3.PoolManager()
2425
    # try:
2426
    response = http.request('GET', url='https://files.rcsb.org/download/' +
2427
                            cif_id.lower() + '-assembly1.cif')
2428
    if not response.status == 200:
2429
        raise PDBFetchError()
2430
    txt = response.data
2431
2432
    npath = path + os.sep + cif_id + '_ba.cif'
2433
    print('downloading...' + npath)
2434
    with open(npath, 'wb') as f:
2435
        f.write(txt)
2436
    print('ok')
2437
    return cif_id + '_ba.cif'
2438
2439
def fetch_cif(cif_id, path="."):
2440
    """fetch biological assembly cif file from RCSB.org"""