Thread: DNA function!

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    21
    Rep Power
    0

    DNA function!


    Hello guys! Can someone help me, i have no idea how can I realize the question below! Thanks for every help...!

    Tasks:
    Deoxyribonucleic acid (DNA) is a molecule describing the genetic information of an organism. It is made up of various combinations of four different smaller molecules: adenine, thymine, guanine, and cytosine. Because of this, DNA is frequently represented as a string of A, T, G, and C characters, corresponding to the four different molecules. For example, the human genome might be described as ATATCGATCGATCG (continuing on for about 6 billion more characters).
    In this assignment, you will store a DNA sequence as a singly-linked list of strings of length one, implemented using a Node structure.



    1. Write a function percentage that inputs a linked list DNA sequence and a string of length 1
    (one of A,C,G, T) , and produces the percentage (as a floating point number between
    0 and 100) of times that character appears in the list, relative to the length of the list. Produce 0 for an empty DNA sequence.


    2. DNA sequences can be very long. One way to (potentially) conserve space is to group together
    sequences of common characters. For example, AAAGTTTACACCT could be compressed as
    A3G1T3A1C1A1C2T1.
    Write a function compress that inputs a linked list DNA sequence, and produces a new linked
    list, in which the items in the Nodes are lists of length 2, [x,y], where x is one of the strings
    A,C,G,T, and y is the number of times that character appears in consecutive positions
    in the sequence. For example, for the linked list image in Question 1, compress would produce the following linked list:
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,417
    Rep Power
    1871
    Well the first question is, do you know what a linked list is, and how to implement one?

    If you don't know what a linked list is, have you at least typed "linked list" into google, and done some reading?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481

    nice compression!


    Aaagtttacacct
    A3g1t3a1c1a1c2t1

    Comments on this post

    • bdb agrees : lol
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    21
    Rep Power
    0

    Red face


    Hey come on guys, I need your help and I will learn it! I know what a linked list is!

    For the first question:

    Linked list
    @->A -> T -> T ->G

    First Node structure for singly link list;

    struct node
    {
    int info;
    struct node *next;
    }*start

    //code code...

    1) First i have to read my input scanf ...
    2) create a new node while next == NULL
    3) output of the inserted character...!



    For the Second question;
    Linked list array??
    @->[A,1] -> [T,2] -> [T, 3]->[G,4]
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,255
    Rep Power
    2222
    Try that again, only in monospace:
    Code:
    Aaagtttacacct
    A3g1t3a1c1a1c2t1
    The "compressed" version is only longer by three characters. Not good, but not as bad as the default variable-width font made it look.

    I would suggest an improvement: represent a single base without the count of "1", but by the base alone. That would yield:
    Code:
    Aaagtttacacct
    A3gt3acac2t
  10. #6
  11. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,255
    Rep Power
    2222
    Originally Posted by machupicchu
    First Node structure for singly link list;

    struct node
    {
    int info;
    struct node *next;
    }*start
    No, not int. I would opt for char, but your assignment looks like they want you to use a "string of length one" -- which sounds as lame as the "compression" scheme -- so you'd have to make that field a char[2] array.

    Originally Posted by machupicchu
    1) First i have to read my input scanf ...
    2) create a new node while next == NULL
    3) output of the inserted character...!
    Yeah, that's about it. Except you will need to append the new node onto the end of the list. Then to output the entire list you would simply traverse the list from start to end. You would traverse it the same way to count the number of occurances of each base.

    Originally Posted by machupicchu
    For the Second question;
    Linked list array??
    @->[A,1] -> [T,2] -> [T, 3]->[G,4]
    "Linked list array"? What is that supposed to be? Sounds like an array of start pointers to a number of different lists. That "lists of length 2" wording is just weird and confusing.

    The base would be one field in the node and the number of sequential occurances would the the second field -- and, of course, the link to the next node would be the third field.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    21
    Rep Power
    0
    Whats that? the solution...?? :tbulb:

    d Code:
    Aaagtttacacct
    A3gt3acac2t
  14. #8
  15. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    A 16596 nucleotide sequence of mouse
    "compresses" to 23352 characters.
    The longest base repetitions is 8.
    The dwise1_aol improvement reduces
    the sequence to 15087 characters.
    We all know that packing the data
    2 bits per nucleotide would make higher
    density. Except that I've found
    references for 6 DNA bases.
    Code:
       WHISKER
    ACGGCCGGCGACAATTTATATGTCAATGTTTTAGTAATTTACAATTAAGACAGACATGCACTGTATTGATACATTAATCATACATAAAATGCATGCTCTAATTTTTACATATGCATGTGCAAGCATATACATATGTGTGGATACACACGTATGTGCTTTGTCACATGTATGTACTGGTTACATATTATGCATGTATTAGGACATACTATGTATTATCACCATATCATTATTTTAACCATAAAGCAGGTACATAATG...
    
       cuts=: <;.2~ (0 ,~ }. ~: }:)
    
       ,({.,":@#)@>cuts WHISKER
    A1C1G2C2G2C1G1A1C1A2T3A1T1A1T1G1T1C1A2T1G1T4A1G1T1A2T3A1C1A2T2A2G1A1C1A1G1A1C1A1T1G1C1A1C1T1G1T1A1T2G1A1T1A1C1A1T2A2T1C1A1T1A1C1A1T1A4T1G1C1A1T1G1C1T1C1T1A2T5A1C1A1T1A1T1G1C1A1T1G1T1G1C1A2G1C1A1T1A1T1A1C1A1T1A1T1G1T1G1T1G2A1T1A1C1A1C1A1C1G1T1A1T1G1T1G1C1T3...
    Last edited by b49P23TIvg; November 26th, 2012 at 05:25 PM.
    [code]Code tags[/code] are essential for python code and Makefiles!
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    21
    Rep Power
    0
    Actually i start with the programm...! First I built a structure and then a function percentag(). Suggestios?


    a Code:
    #include<stdio.h>
     
    //structure declaration for the node
    struct node{
    	char string[1];
    	struct node *next;	
    }*start
     
    void percentage(){
    	scanf("%s", &string);
    	if(start == NULL)
    		start = header;
    	else
    	   while(start->next != NULL)
    	   {
    	   start = start->next;
    	   start->next = header;
     
    }
     
    int main(){
    	percentage();
     
    	return 0;
    }
  18. #10
  19. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    I suggest you work on the second part of Salem's first question, "Well the first question is, do you know what a linked list is, and how to implement one?"

    In my sad life this is far and away the funniest thread of the week.
    Last edited by b49P23TIvg; November 26th, 2012 at 05:50 PM. Reason: insert a / character.
    [code]Code tags[/code] are essential for python code and Makefiles!
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    21
    Rep Power
    0
    When you know it, then give me the answer! With report please and not in chinese! after you can laugh so much you want. I think you was not better when you start to program! :thumbs:
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    21
    Rep Power
    0
    I have no idea! I would upload a pic, but it is not possible! The array are in nodes and letter are in char!
    d Code:
     
    "Linked list array"?  What is that supposed to be?  Sounds like an array of start pointers to a number of different lists.  That "lists of length 2" wording is just weird and confusing.
  24. #13
  25. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo