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

feat: Split .tsv.gz files into two #173

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions misc/split_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
#SBATCH --job-name=split
#SBATCH --time=01:00:00
#SBATCH --mem=4G
#SBATCH --cpus-per-task=1
#SBATCH --partition=datamover
#SBATCH --mail-type=ALL
#SBATCH --mail-user=karatugo@ebi.ac.uk

# TODO: Define the full file paths
INPUT_FILE=""
OUTPUT_FILE_1=""
OUTPUT_FILE_2=""

# Extract the header
HEADER=$(zcat "$INPUT_FILE" | head -n 1)

# Count the total number of lines in the file
TOTAL_LINES=$(zcat "$INPUT_FILE" | wc -l)

# Calculate the midpoint
MIDPOINT=$(( (TOTAL_LINES - 1) / 2 ))

# Split the file into two parts
zcat "$INPUT_FILE" | head -n $((MIDPOINT + 1)) | gzip > "$OUTPUT_FILE_1"
{
echo "$HEADER"
zcat "$INPUT_FILE" | tail -n +$((MIDPOINT + 2))
} | gzip > "$OUTPUT_FILE_2"

echo "File has been split into two parts:"
echo "First part: $OUTPUT_FILE_1"
echo "Second part: $OUTPUT_FILE_2"