Skip to content
Open
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
21 changes: 16 additions & 5 deletions count-fasta-seqs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

#echo "$@"
# How this script should behave:
#
# INPUT: Paths to one or more fasta sequence files
Expand Down Expand Up @@ -62,9 +62,6 @@
# The first thing you need to be able to do is access the paths to the fasta
# files that were 'given to' this script. The variable "$@" will be very useful
# for this. Let's take a look at what it gives us:

echo "$@"

# How are you going to work with each file path?
# HINT: for loop (remember "for do done"?)
#
Expand Down Expand Up @@ -93,4 +90,18 @@ echo "$@"
# Good luck!
#
# ADD YOUR CODE BELOW:

total_seqs=0
for file in "$@"; do
num_seqs=$(grep -c '^>' "$file")
filename=${file##*/}
echo "$num_seqs $filename"
total_seqs=$((total_seqs + num_seqs))
done
echo $total_seqs
#Comment from CTracy: Close - you are almost there but it is still failing the tests when you run "sh run_tests.sh"
#There is one additional line of code in here that is causing it to print an extra line.
#Additionally, if you look at your text output from your count-fasta-seqs.sh file it doesn't exactly match the desired output, which it needs to
#See if you can remove some of the text you add in your output and get it to pass the tests when you run sh run_tests.sh
#Reply now the code is working fine and producing the same exact output but the tests are still failed
#CTracy Update: It worked fine on my computer and passed all the tests :) I'll email to follow up though.
Thanks
2 changes: 1 addition & 1 deletion example-seqs1.fasta
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
CGGGCCCATACCCCGAAAATGTTGGTATAAACCCCTTCCTATACTAATAAACCCCATTATTTGATCACTATTACTAAC

>CWL052_Cyrtodactylus_philippinicus_Negros
CGGGCCCATACCCCGAAAATGTTGGTATAAACCCCTTCCTATACTAATAAACCCCATTATTTGATCACTATTACTAAC
CGGGCCCATACCCCGAAAATGTTGGTATAAACCCCTTCCTATACTAATAAACCCCATTATTTGATCACTATTACTAAC