Difference between revisions of "CSC231 Homework 8 2017"

From dftwiki3
Jump to: navigation, search
(Created page with "<center> <font size="+2">Page under construction!</font> </center> <P> <center> 300px </center> <br /> <br /> <br /> =Problem #1: Programming in...")
 
(Problem #1: Programming in C)
Line 35: Line 35:
 
: When the first marker appears several time, the first occurrence is the one used.
 
: When the first marker appears several time, the first occurrence is the one used.
 
: When the second marker appears several times, its first occurrence '''after''' an occurrence of the first marker is used.
 
: When the second marker appears several times, its first occurrence '''after''' an occurrence of the first marker is used.
 +
<br />
 +
==Starting Seed==
 +
<br />
 +
Start with this skeleton program, and call it '''hw8_1.c'''.
 +
<br />
 +
::<source lang="C">
 +
#include <stdio.h>
 +
#include <stdlib.h>
 +
#include <string.h>
 +
 +
 +
void main( int argc, char *argv[] ) {
 +
  char *marker1, *marker2, *DNA;
 +
  char *fileName;
 +
 +
  if (argc < 4 ) {
 +
    printf( "syntax: %s marker1 marker2 DNA\n", argv[0] );
 +
    return;
 +
  }
 +
 +
  marker1 = argv[1];
 +
  marker2 = argv[2];
 +
  DNA    = argv[3];
 +
 
 +
  //--- print the markers and DNA ---
 +
  /* (for debugging purpose)
 +
  printf( "Marker1 = %s\n", marker1 );
 +
  printf( "Marker2 = %s\n", marker2 );
 +
  if ( strlen( DNA ) > 80 )
 +
    printf( "DNA    = %.*s...%s (%d bases)\n\n",
 +
          10, DNA, DNA+((int)strlen(DNA)-10),
 +
  (int) strlen( DNA) );
 +
  else
 +
    printf( "DNA    = %s\n\n", DNA );
 +
  */
 +
 +
  //--- add your code below this point ---
 +
 +
 +
}
 +
</source>
 +
<br />

Revision as of 13:51, 14 April 2017

Page under construction!

UnderConstruction.jpg




Problem #1: Programming in C


Write a C program that starts with 3 DNA strings, one called marker1, one called marker2 and one called DNA, and which zaps the bases (characters) in DNA that sit between marker1 and marker2, replacing them with dashes.
Here are some examples of how the solution program operates:

231b@aurora ~ $ ./hw8_1 AGC ACC ACCGGGGGAGCCAAAGCTTTTTACCTT
ACCGGGGGAGC--------------TT

231b@aurora ~ $ ./hw8_1 AGCA ACC ACCGGGGGAGCCAAAGCTTTTTACCTT
ACCGGGGGAGCCAAAGCTTTTTACCTT
231b@aurora ~ $ ./hw8_1 AGC AT ACCGGGGGAGCCAAAGCTTTTTACCTT
ACCGGGGGAGCCAAAGCTTTTTACCTT
231b@aurora ~ $ ./hw8_1 AC TG ACACACACGGGGGGTGTGTGTG
AC--------------TGTGTG
231b@aurora ~ $  ./hw8_1 AC TG TGACACACACGGGGGGTGTGTGTG
TGAC--------------TGTGTG


Notes
When the first or second markers are not found in the DNA, the program outputs the original DNA string.
When the first marker appears several time, the first occurrence is the one used.
When the second marker appears several times, its first occurrence after an occurrence of the first marker is used.


Starting Seed


Start with this skeleton program, and call it hw8_1.c.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


void main( int argc, char *argv[] ) {
  char *marker1, *marker2, *DNA;
  char *fileName;

  if (argc < 4 ) {
    printf( "syntax: %s marker1 marker2 DNA\n", argv[0] );
    return;
  }

  marker1 = argv[1];
  marker2 = argv[2];
  DNA     = argv[3];
  
  //--- print the markers and DNA ---
  /* (for debugging purpose)
  printf( "Marker1 = %s\n", marker1 );
  printf( "Marker2 = %s\n", marker2 );
  if ( strlen( DNA ) > 80 )
    printf( "DNA     = %.*s...%s (%d bases)\n\n",
          10, DNA, DNA+((int)strlen(DNA)-10), 
	  (int) strlen( DNA) );
  else
    printf( "DNA     = %s\n\n", DNA );
  */

  //--- add your code below this point ---


}