Results 1 to 14 of 14
Thread: Removing the double values?
- 11-11-2010, 11:55 AM #1
Removing the double values?
I was thinking of my next problem on my work.
I need to merge some files, but I also have this problem with one file:
>Contig1
text here
>Contig1
text here
>Contig2
text here
>Contig2
text here
I actualy only need the first >Contig1.
The second >Contig1 I wanna get rid of.
First >Contig2 I want, and also the second >Contig2 I also wanna get rid of.
And that continues through the file.
I was thinking of making a dictionary for this.
But I don't know how to handle his...
Becose I also have te feeling that a dictionary might not be right what I need...
- 11-11-2010, 12:27 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Depends how big the file is.
Would storing the keys (ie ">Contig1", ">Contig2") be too much (obviously not scalable)?
If that's OK then stick them in a List as you encounter them, after checking if there's one there already:
Java Code:readline String not in my list? then add to list, and do whatever it is you need to do with the text. else skip to the next key.
- 11-11-2010, 12:34 PM #3
My biggest file has about 400 >Contigs, and they all are written 2 times.
So 800 in total, of where I need 400.
I will look for that list thing.
Sounds as the right thing I might need.
Thanks.
- 11-11-2010, 12:37 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
That's nothing.
Go the route I suggest above.
You're only talking about a few bytes each, times 400, plus a bit of overhead, so a few k.
- 11-11-2010, 12:40 PM #5
Member
- Join Date
- Oct 2010
- Posts
- 6
- Rep Power
- 0
If the information is ordered as you have shown here can you not simply maintain a name/value for the last pair loaded and match against the next pair. If it is different then process it and if same discard. Then just repeat until the end of your file.
Both methods should work but this will save some processing time scanning all values as it's only one check.
- 11-11-2010, 12:48 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
That's true.
For some reason I was presuming they were not necessarily in a convenient order.
- 11-16-2010, 11:48 AM #7
I have made this so far:
Java Code:xD
I know I need an if loop over there. But if (arrayList.exists()) doesn't work.
I also tried if (arrayList >=1). But that is also not it.Last edited by Lund01; 11-16-2010 at 01:02 PM. Reason: Keeping my code. xD
- 11-16-2010, 11:51 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
You didn't look terribly closely at the API for ArrayList did you?
:)
- 11-16-2010, 12:09 PM #9
Nope. :p
I used a Java Programming book.
- 11-16-2010, 12:28 PM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
The API is your friend...:)
- 11-16-2010, 12:47 PM #11
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,568
- Rep Power
- 15
Use a Set and simply add them as you come to them.
- 11-16-2010, 12:58 PM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Doh!
:)
(damn character limit!)
- 11-16-2010, 01:01 PM #13
Finished that part.
API is idd usefull. LoL
- 11-17-2010, 12:34 PM #14
Similar Threads
-
find the unique values of a double array
By tyang in forum New To JavaReplies: 3Last Post: 09-11-2011, 03:47 PM -
Removing duplicates from double Arrays
By jhong253 in forum New To JavaReplies: 3Last Post: 10-30-2010, 11:32 PM -
Java/SQL Removing double data
By Subhero in forum AWT / SwingReplies: 2Last Post: 05-13-2010, 04:44 PM -
double a * double b = weird output
By GPB in forum New To JavaReplies: 3Last Post: 03-26-2010, 11:40 AM -
mutliplicatio of double values
By katkamravi in forum New To JavaReplies: 2Last Post: 04-13-2009, 03:28 PM
Bookmarks