Discuss Dna compress in the C Programming forum on Dev Shed. Dna compress C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
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.
Posts: 3,458
Time spent in forums: 1 Month 2 Weeks 4 Days 6 h 26 m 43 sec
Reputation Power: 403
Quote:
Originally Posted by instructor
Write a function compress
compress is the function name I expect. Not compressed.
Quote:
Originally Posted by instructor
that inputs a linked list DNA sequence,
I expect compress to take an argument, the head of a singly linked list.
Quote:
Originally Posted by instructor
and produces a new linked list,
Function compress should return a linked list, be it an array or a pointer to some sort of complicated node. void is incorrect.
Quote:
Originally Posted by instructor
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.
Admittedly confusing. Let's clarify "lists of length 2" as "members x and y, x is a character, y is an (perhaps unsigned) int."
We need a new structure. I'd write (others know how to use typedef) (well, actually I'd use someone else's linked list, that of glib)
Code:
#define CB struct compressed_base
CB {
CB*next;
char x; /* base is a better name, in my opinion */
int y; /* I prefer repeats */
};
Now we know our function signature.
Code:
CB*compress(SEQUENCE*dna) {
;/* your code here */
}
Dreadfully different from your concept!
Please read the documentation for a function you might find useful,
malloc
__________________
[code]Code tags[/code] are essential for python code!
Last edited by b49P23TIvg : December 4th, 2012 at 07:55 PM.
It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Me, I just made it up
The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw
Posts: 5,538
Time spent in forums: 2 Weeks 4 Days 2 h 38 m 46 sec
Reputation Power: 242
You might be interested in the National Center for Biotechnology Information (www.ncbi.nlm.nih.gov), they have a toolkit that does all sorts of biology related stuff, including compression of DNA sequences.
Posts: 21
Time spent in forums: 5 h 52 m 44 sec
Reputation Power: 0
I would write the compress function like this, I have already counted my molecules and I want to compress it. I dont know how can I do it in array, but here I tried something. Below you will see my complete program.
c Code:
Original
- c Code
//This function will display all the element(s) in the linked list