Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dealing with nested subdirectories #40

Open
jomimc opened this issue Oct 18, 2023 · 2 comments
Open

Dealing with nested subdirectories #40

jomimc opened this issue Oct 18, 2023 · 2 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@jomimc
Copy link

jomimc commented Oct 18, 2023

I have a lot of data to compress, and they are stored in nested subdirectories (e.g. /Data/Protein/Mutation/...pdb).

Default behavior of "foldcomp compress -r" seems to be to create an output folder, and to put everything in there. So I encounter the "Output file already exists" error.

Is there a way to either create a new directory with the same subdirectory structure? Or to output the ".fcz" files in the same directories as the uncompressed pdb files?

@khb7840 khb7840 added enhancement New feature or request question Further information is requested labels Oct 19, 2023
@khb7840
Copy link
Member

khb7840 commented Oct 20, 2023

I think you can write a script that iterate through nested sub-directories.

#!/bin/bash
# Usage: ./foldcomp_recursive.sh <path> <threads>
threads=$2

function run_command_in_dir {
    for dir in "$1"/*; do
        if [ -d "$dir" ]; then
            run_command_in_dir "$dir"
        fi
    done

    # Check if pdb or cif files exist in the directory
    if ls "$1"/*.pdb 1> /dev/null 2>&1 || ls "$1"/*.cif 1> /dev/null 2>&1; then
        foldcomp compress -t $threads "$1" "$1"
    fi
}

run_command_in_dir "$1"

This one is an example bash script that iterate through the input directory recursively and check if there are pdb or cif files in the directory while compressing if there are wanted files.

@jomimc
Copy link
Author

jomimc commented Oct 21, 2023

That's what I did, thanks. I managed to get all ~ 60,000 pdb files compressed within an hour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants