Results 1 to 14 of 14
  1. #1
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default 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...

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    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.

  3. #3
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    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.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    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.

  5. #5
    wjncross is offline Member
    Join Date
    Oct 2010
    Posts
    6
    Rep Power
    0

    Default

    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.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    That's true.
    For some reason I was presuming they were not necessarily in a convenient order.

  7. #7
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    I have made this so far:

    Java Code:
     
    xD
    Only, how do I look if there is already something in the arrayList with a certain name? (Like Contig1?)
    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 12:02 PM. Reason: Keeping my code. xD

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    You didn't look terribly closely at the API for ArrayList did you?
    :)

  9. #9
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    Nope. :p
    I used a Java Programming book.

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    The API is your friend...:)

  11. #11
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Use a Set and simply add them as you come to them.

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    Doh!
    :)
    (damn character limit!)

  13. #13
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    Finished that part.
    API is idd usefull. LoL

  14. #14
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    Finished with this one. :)
    Last edited by Lund01; 11-18-2010 at 09:56 AM.

Similar Threads

  1. find the unique values of a double array
    By tyang in forum New To Java
    Replies: 3
    Last Post: 09-11-2011, 02:47 PM
  2. Removing duplicates from double Arrays
    By jhong253 in forum New To Java
    Replies: 3
    Last Post: 10-30-2010, 10:32 PM
  3. Java/SQL Removing double data
    By Subhero in forum AWT / Swing
    Replies: 2
    Last Post: 05-13-2010, 03:44 PM
  4. double a * double b = weird output
    By GPB in forum New To Java
    Replies: 3
    Last Post: 03-26-2010, 10:40 AM
  5. mutliplicatio of double values
    By katkamravi in forum New To Java
    Replies: 2
    Last Post: 04-13-2009, 02:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •