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

Added script to compare sample ids #424

Merged
merged 5 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions relecov_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
""" Main relecov package file.
"""
"""Main relecov package file."""

import pkg_resources

Expand Down
39 changes: 39 additions & 0 deletions relecov_tools/assets/compare_sampleids.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Check if two arguments were provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <all_samples_file> <new_samples_file>"
exit 1
fi

# Assign arguments to variables
all_samples_file="$1"
new_samples_file="$2"

# Check if the files exist
if [ ! -f "$all_samples_file" ] || [ ! -f "$new_samples_file" ]; then
echo "Both files must exist."
exit 1
fi

# Find duplicates in the second file
duplicates_in_new_file=$(sort "$new_samples_file" | uniq -d)

if [ -n "$duplicates_in_new_file" ]; then
echo "New samples file contains duplicate samples. These samples are:"
echo "$duplicates_in_new_file"
exit 0
fi

# Find repeated samples between the two files
duplicates=$(grep -Fxf "$all_samples_file" "$new_samples_file")

if [ -n "$duplicates" ]; then
# If there are duplicate samples between the two files
echo "The second file contains samples that are already in the first file. These samples are:"
echo "$duplicates"
else
# If all samples are new
echo "All samples have been added to the first file."
cat "$new_samples_file" >> "$all_samples_file"
fi
Loading