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

    Default arrayList in a while loop

    I got a little bit of code I am kinda stuck with.

    I got this arrayList where we stored a fasta file.
    Java Code:
     
    Fasta file example: 
    >seq1 
    guguurguorgungun 
    ionjlimlmo 
    >seq2 
    jjkliuihlni 
    >seq3 
    ppokkpdgstdcbch
    mdhdgsvtxtgsgwd
    jdbuydfyhedgy
    Now I would like to make a while loop where he constantly takes the next >seq... (and the lines below) and do something with it.

    But the problem is, how do I get it to take the next >seq...

    I was thinking of letting it count++;
    But overall, how can I find a certain ietm in the arrayList? (Like this ">")
    I don't know if indexOf would help?

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default Re: arrayList in a while loop

    how can I find a certain ietm in the arrayList? (Like this ">")
    If the ArrayList contains String objects, then you should be able to find the String: ">"
    But if the '>' is embedded in a longer String or class, you will have to get each object in the list and look in the object's contents.

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

    Default Re: arrayList in a while loop

    We now made a function getProtein. And what getProtein does is he takes every >seq and the lines below.
    Now the idea was something like this:

    int count = 0;

    // Do something to continue to the next with getProtein function (>seq2 etc.)

    count++;

    Do you maybe have any idea on this one?
    Like how to get the next >seq...

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default Re: arrayList in a while loop

    Like how to get the next >seq...
    To look at the contents of a String you could use the indexOf() method.

Similar Threads

  1. How to run a for-each loop through an ArrayList?
    By simon.black325 in forum New To Java
    Replies: 6
    Last Post: 09-08-2011, 04:18 AM
  2. foreach loop on ArrayList<Stack<String>>
    By Ciwan in forum New To Java
    Replies: 21
    Last Post: 06-27-2011, 07:29 PM
  3. Problems with a loop calling data from an ArrayList.
    By moriarty in forum New To Java
    Replies: 30
    Last Post: 03-28-2010, 02:00 AM
  4. Iterating through ArrayList using For loop
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-20-2008, 08:53 AM
  5. Replies: 0
    Last Post: 11-14-2007, 03:22 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
  •