Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * <summary> Matches all of "seq1" concurrently with "seq2" </summary>
- * <params> "seq1", "seq2" = Two strings containing the DNA sequence </params>
- * <return>
- * "1" : If the entire "seq1" matches with "seq2" concurrently
- * "0" : Otherwise
- * </return>
- * <precond> Both "seq1" and "seq2" are strings hence should be null-terminated </precond>
- */
- int match (char seq1[], char seq2[])
- {
- char correctSequence[20];
- int i = 0, seq1_length = strlen(seq1);
- /* Generate the expected matching sequence of "seq1" and store into "correctSequence" */
- while(i < seq1_length)
- {
- switch(seq1[i])
- {
- case 'A' :
- correctSequence[i] = 'T';
- break;
- case 'T' :
- correctSequence[i] = 'A';
- break;
- case 'C' :
- correctSequence[i] = 'G';
- break;
- case 'G' :
- correctSequence[i] = 'C';
- break;
- }//end of switch
- }//end of while
- /* Terminate with Null */
- correcttSequence[i] = '\0';
- /* Use the substring function to determine a match */
- return strstr(seq2, correctSequence) != NULL ? 1 : 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement