C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 26th, 2012, 11:29 AM
machupicchu machupicchu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 17 machupicchu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 13 sec
Reputation 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:

Reply With Quote
  #2  
Old November 26th, 2012, 12:14 PM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,836 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 16 h 15 m 5 sec
Reputation Power: 1774
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

Reply With Quote
  #3  
Old November 26th, 2012, 01:02 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,354 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 8 h 30 m 8 sec
Reputation Power: 383
nice compression!

Aaagtttacacct
A3g1t3a1c1a1c2t1
Comments on this post
bdb agrees: lol
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #4  
Old November 26th, 2012, 01:51 PM
machupicchu machupicchu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 17 machupicchu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 13 sec
Reputation 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]

Reply With Quote
  #5  
Old November 26th, 2012, 01:53 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is online now
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,127 dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 17 h 44 m
Reputation Power: 1949
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

Reply With Quote
  #6  
Old November 26th, 2012, 02:11 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is online now
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,127 dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 17 h 44 m
Reputation Power: 1949
Quote:
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.

Quote:
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.

Quote:
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.

Reply With Quote
  #7  
Old November 26th, 2012, 03:51 PM
machupicchu machupicchu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 17 machupicchu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 13 sec
Reputation Power: 0
Whats that? the solution...??

d Code:
Original - d Code
  1. Aaagtttacacct
  2. A3gt3acac2t

Reply With Quote
  #8  
Old November 26th, 2012, 04:19 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,354 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 8 h 30 m 8 sec
Reputation Power: 383
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
ACGGCCGGCGACAATTTATATGTCAATGTTTTAGTAATTTACAATTAAGACAGACATGCACTGTATTGATACATTAATCATACATAAAATGCATGCTCTA  ATTTTTACATATGCATGTGCAAGCATATACATATGTGTGGATACACACGTATGTGCTTTGTCACATGTATGTACTGGTTACATATTATGCATGTATTAGG  ACATACTATGTATTATCACCATATCATTATTTTAACCATAAAGCAGGTACATAATG...

   cuts=: <;.2~ (0 ,~ }. ~: }:)

   ,({.,":@#)@>cuts WHISKER
A1C1G2C2G2C1G1A1C1A2T3A1T1A1T1G1T1C1A2T1G1T4A1G1T1A2T3A1C1A2T2A2G1A1C1A1G1A1C1A1T1G1C1A1C1T1G1T1A1T2  G1A1T1A1C1A1T2A2T1C1A1T1A1C1A1T1A4T1G1C1A1T1G1C1T1C1T1A2T5A1C1A1T1A1T1G1C1A1T1G1T1G1C1A2G1C1A1T1A1T1  A1C1A1T1A1T1G1T1G1T1G2A1T1A1C1A1C1A1C1G1T1A1T1G1T1G1C1T3...
   

Last edited by b49P23TIvg : November 26th, 2012 at 04:25 PM.

Reply With Quote
  #9  
Old November 26th, 2012, 04:39 PM
machupicchu machupicchu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 17 machupicchu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 13 sec
Reputation Power: 0
Actually i start with the programm...! First I built a structure and then a function percentag(). Suggestios?


a Code:
Original - 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; }

Reply With Quote
  #10  
Old November 26th, 2012, 04:50 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,354 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 8 h 30 m 8 sec
Reputation Power: 383
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 04:50 PM. Reason: insert a / character.

Reply With Quote
  #11  
Old November 26th, 2012, 05:04 PM
machupicchu machupicchu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 17 machupicchu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 13 sec
Reputation 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!

Reply With Quote
  #12  
Old November 26th, 2012, 05:24 PM
machupicchu machupicchu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 17 machupicchu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 13 sec
Reputation 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:
Original - d Code
  1.  
  2. "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.   

Reply With Quote
  #13  
Old November 26th, 2012, 05:55 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,354 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 8 h 30 m 8 sec
Reputation Power: 383

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > DNA function!

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap