I have the following script that is concatenating files in a directory in a particular fashion. I did some testing on a toy example and it is not doing what I thought it was doing.
First, to describe the directory structure, there are three types of files(bulk, reference, and single-cell), each with a "left" and "right" polarity. I want to merge all files of the same type and polarity. That is, files labeled with "bulk_left_*" are all merged into a final file "left_bulk" and the same for the reference files. The single cells are unique in that there are a specified number of single cells and each must be merged by index. That is, if all files with the prefix single_cell_left0_* are merged together but should NOT be merged with "single_cell_left1_*" type files. In the end I should have 4 + 2*(number of singlecells) files in the directory.
Here is the current script I use to do the merging. I tested it on a directory with some made up files and I saw that it merged every single cell file into the specified outputs instead of only selecting them one index at a time. I think this has something to do with way I write the variable into the bash directory, and it is treating it as an integer instead of a string variable, but I am not sure.
WORKING_DIR=/media/drive0/USER/data
cat $WORKING_DIR/bulk_reads_left_*.fasta > $WORKING_DIR/left_all_bulk.fasta
cat $WORKING_DIR/bulk_reads_right_*.fasta > $WORKING_DIR/right_all_bulk.fasta
rm $WORKING_DIR/bulk*.fasta
cat $WORKING_DIR/reference_fast_number_left*.fasta > $WORKING_DIR/left_reference.fasta
cat $WORKING_DIR/reference_fast_number_right*.fasta > $WORKING_DIR/right_reference.fasta
rm $WORKING_DIR/reference*.fasta
NCELLS=5
for i in `seq 0 $(($NCELLS-1))`
do do
cat $WORKING_DIR/single_cell_number_left$i_*.fasta > $WORKING_DIR/left_single_cell_$i.fasta
cat $WORKING_DIR/single_cell_number_right$i_*.fasta > $WORKING_DIR/right_single_cell_$i.fasta
done
rm $WORKING_DIR/single*.fasta
~