How to use the biopandas.mol2.mol2_io.split_multimol2 function in biopandas

To help you get started, we’ve selected a few biopandas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rasbt / screenlamp / tools / overlay_molecules_rocs.py View on Github external
def run_rocs(source_file, target_file, n_processes, settings):

    prefix = ''.join(target_file.split('.mol2')[:-1])

    sys.stdout.write('Processing %s\n' % os.path.basename(source_file))
    sys.stdout.flush()

    for idx, mol2 in enumerate(split_multimol2(QUERY_FILE)):
        if idx >= 1:
            mcquery = 'true'
            break
    if not idx:
        mcquery = 'false'

    cmd = [EXECUTABLE,
           '-ref', QUERY_FILE,
           '-dbase', source_file,
           '-outputquery', 'false',
           '-prefix', prefix,
           '-mcquery', mcquery,
           '-mpi_np', str(n_processes),
           '-oformat', 'mol2']

    if settings:
github rasbt / screenlamp / tools / mol2_to_id.py View on Github external
def mol2_to_idfile(mol2_files, id_file_path, verbose=0):
    with open(id_file_path, 'w') as f:
        for mol2_file in mol2_files:

            if verbose:
                sys.stdout.write('Processing %s' % os.path.basename(mol2_file))
                sys.stdout.flush()
                start = time.time()

            for idx, mol2 in enumerate(split_multimol2(mol2_file)):
                f.write(mol2[0] + '\n')

            if verbose:
                elapsed = time.time() - start
                n_molecules = idx + 1
                sys.stdout.write(' | scanned %d molecules | %d mol/sec\n' %
                                 (n_molecules, n_molecules / elapsed))
                sys.stdout.flush()
github rasbt / screenlamp / tools / overlay_molecules_rocs.py View on Github external
def check_query(query_path):
    ids = [mol2[0] for mol2 in split_multimol2(query_path)]
    n_ids = len(ids)
    if n_ids > 1:
        n_unique_ids = len(set(ids))
        if n_unique_ids > 1:
            raise ValueError('Please Make sure that you only submit one'
                             ' molecule or, if you submit a multi-conformer'
                             ' query, that conformers of the molecule'
                             ' have all the same molecule ID labels.'
                             ' Found %d molecules and %d unique labels'
                             % (n_ids, n_unique_ids))
github rasbt / screenlamp / tools / id_to_mol2.py View on Github external
if mol2[0] in ids:
                            f.write(''.join(mol2[1]))
                else:
                    for idx, mol2 in enumerate(split_multimol2(mol2_file)):

                        if mol2[0].decode('utf-8') in ids:
                            f.write(b''.join(mol2[1]))

            else:
                if write_mode == 'w':
                    for idx, mol2 in enumerate(split_multimol2(mol2_file)):
                        if mol2[0] not in ids:
                            f.write(''.join(mol2[1]))
                else:
                    for idx, mol2 in enumerate(split_multimol2(mol2_file)):
                        if mol2[0].decode('utf-8') not in ids:
                            f.write(b''.join(mol2[1]))
            if verbose:
                elapsed = time.time() - start
                n_molecules = idx + 1
                sys.stdout.write(' | scanned %d molecules | %d mol/sec\n' %
                                 (n_molecules, n_molecules / elapsed))
                sys.stdout.flush()
github rasbt / screenlamp / tools / overlay_molecules_shapeit.py View on Github external
def check_query(query_path):
    ids = [mol2[0] for mol2 in split_multimol2(query_path)]
    n_ids = len(ids)
    if n_ids > 1:
        n_unique_ids = len(set(ids))
        if n_unique_ids > 1:
            raise ValueError('Please Make sure that you only submit one'
                             ' molecule or, if you submit a multi-conformer'
                             ' query, that conformers of the molecule'
                             ' have all the same molecule ID labels.'
                             ' Found %d molecules and %d unique labels'
                             % (n_ids, n_unique_ids))
github rasbt / screenlamp / tools / id_to_mol2.py View on Github external
write_mode = 'w'
            open_file = open

        with open_file(mol2_outpath, write_mode) as f:
            if verbose:
                start = time.time()

            if includelist_filter:

                if write_mode == 'w':
                    for idx, mol2 in enumerate(split_multimol2(mol2_file)):

                        if mol2[0] in ids:
                            f.write(''.join(mol2[1]))
                else:
                    for idx, mol2 in enumerate(split_multimol2(mol2_file)):

                        if mol2[0].decode('utf-8') in ids:
                            f.write(b''.join(mol2[1]))

            else:
                if write_mode == 'w':
                    for idx, mol2 in enumerate(split_multimol2(mol2_file)):
                        if mol2[0] not in ids:
                            f.write(''.join(mol2[1]))
                else:
                    for idx, mol2 in enumerate(split_multimol2(mol2_file)):
                        if mol2[0].decode('utf-8') not in ids:
                            f.write(b''.join(mol2[1]))
            if verbose:
                elapsed = time.time() - start
                n_molecules = idx + 1

biopandas

Machine Learning Library Extensions

BSD-3-Clause
Latest version published 3 months ago

Package Health Score

74 / 100
Full package analysis

Similar packages