Skip to content

Commit feddd13

Browse files
committed
Process files in one go using find and xargs
1 parent 8dd3cbd commit feddd13

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

workflows/litscan/litscan-search-new-ids.nf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ process submit_ids {
7676
script:
7777
"""
7878
# create file with IDs (without URS)
79-
for i in $baseDir/workflows/litscan/submit/*.txt;do sed '/^URS/d' \$i >> all_ids.txt;done
80-
tr A-Z a-z < all_ids.txt > all_ids_lower.txt
81-
sort all_ids_lower.txt | uniq > all_ids_sorted.txt
79+
find $baseDir/workflows/litscan/submit/ -name "*.txt" -print0 | xargs -0 sed '/^URS/d' > all_ids.txt
80+
tr A-Z a-z < all_ids.txt | sort -u > all_ids_sorted.txt
8281
8382
# get ids already scanned by LitScan (Expert DB ids only)
8483
psql -v ON_ERROR_STOP=1 -c "COPY (SELECT job_id FROM litscan_job WHERE job_id not like 'urs%' ORDER BY job_id) TO STDOUT;" $PGDATABASE > old_ids.txt
@@ -115,9 +114,8 @@ process submit_urs {
115114
script:
116115
"""
117116
# create file with URS only
118-
for i in $baseDir/workflows/litscan/submit/*.txt;do sed '/^URS/!d' \$i >> output.txt;done
119-
tr a-z A-Z < output.txt > output_uppercase.txt
120-
sort output_uppercase.txt | uniq > urs.txt
117+
find $baseDir/workflows/litscan/submit/ -name "*.txt" -print0 | xargs -0 sed '/^URS/!d' > output.txt
118+
tr a-z A-Z < output.txt | sort -u > urs.txt
121119
122120
# get URS already scanned by LitScan
123121
psql -v ON_ERROR_STOP=1 -c "COPY (SELECT job_id FROM litscan_job WHERE job_id like 'urs%' ORDER BY job_id) TO STDOUT;" $PGDATABASE > urs_lower.txt

0 commit comments

Comments
 (0)