-
Notifications
You must be signed in to change notification settings - Fork 571
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sort content of txt files in study dir to make order not important wh…
…ile comparing
- Loading branch information
Showing
3 changed files
with
66 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Function to display usage instructions | ||
usage() { | ||
echo "Usage: $0 <source_directory> <destination_directory>" | ||
exit 1 | ||
} | ||
|
||
# Check if the correct number of arguments is provided | ||
if [ "$#" -ne 2 ]; then | ||
usage | ||
fi | ||
|
||
# Remove trailing slashes from paths if they exist | ||
SOURCE_DIR="${1%/}" | ||
DEST_DIR="${2%/}" | ||
|
||
# Check if the source directory exists | ||
if [ ! -d "$SOURCE_DIR" ]; then | ||
echo "Error: Source directory does not exist." | ||
exit 1 | ||
fi | ||
|
||
# Create the destination directory if it does not exist | ||
mkdir -p "$DEST_DIR" | ||
|
||
# Copy files and sort text files | ||
find "$SOURCE_DIR" -type f | while read -r FILE; do | ||
REL_PATH="${FILE#$SOURCE_DIR/}" # Get relative path | ||
DEST_FILE="$DEST_DIR/$REL_PATH" # Destination file path | ||
DEST_DIR_PATH="$(dirname "$DEST_FILE")" # Destination directory path | ||
|
||
# Create the destination directory if it does not exist | ||
mkdir -p "$DEST_DIR_PATH" | ||
|
||
# Check if the file is a text file and sort its contents | ||
if file "$FILE" | grep -q "text"; then | ||
sort "$FILE" > "$DEST_FILE" | ||
else | ||
cp "$FILE" "$DEST_FILE" | ||
fi | ||
|
||
done | ||
|
||
echo "Copy and sort operation completed successfully." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# exit when any of these fails | ||
set -e | ||
|
||
echo "Importing of the test study with API validation..." | ||
metaImport.py -v -u http://cbioportal-container:8080 -o -s /cbioportal/test/test_data/study_es_0_import_export/ | ||
|
||
echo "Exporting of the test study." | ||
curl -s http://cbioportal-container:8080/export/study/study_es_0_import_export.zip > study_es_0_import_export.zip \ | ||
&& unzip study_es_0_import_export.zip -d ./output_study_es_0_import_export | ||
|
||
echo "Sort content of text files from both folders to make order during comparison unimportant." | ||
./cbioportal/test/integration/copy_and_sort.sh /cbioportal/test/test_data/study_es_0_import_export/ ./input_study_es_0_import_export_sorted/ | ||
./cbioportal/test/integration/copy_and_sort.sh ./output_study_es_0_import_export/ ./output_study_es_0_import_export_sorted/ | ||
|
||
echo "Comparing the original and exported studies." | ||
diff --recursive ./input_study_es_0_import_export_sorted/ ./output_study_es_0_import_export_sorted/ | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters