folding@home progress monitor

Discussion in 'Distributed Computing' started by bousozoku, Mar 1, 2003.

  1. Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #1
    Okay, Here's the first working version of my progress monitor. Yes, it's very, very un-Mac-like.


    // read a text file and match certain items on separate lines



    import java.io.*;



    class Keyboard

    {

    InputStreamReader inStream;

    BufferedReader stdInStream;



    // override implicit constructor to open the input stream and attach it

    // to a stream reader

    Keyboard()

    {

    inStream = new InputStreamReader(System.in);

    stdInStream = new BufferedReader(inStream);

    }



    // get one character

    char read()

    {

    char aChar = ' ';



    try

    {

    aChar = (char)stdInStream.read();

    }

    // empty exception handling

    catch (Exception e)

    {

    }

    return aChar;

    } // end of read()



    // get a whole line and return it as a String

    String readln()

    {

    String aString = " ";



    try

    {

    aString = (String)stdInStream.readLine();

    }

    // empty exception handling

    catch (Exception e)

    {

    }

    return aString;

    } // end of readln()



    } // end of Keyboard class



    class ReadAndParse

    {

    private static String fileName;

    private static String line;

    private static String proteinName = "";

    private static float completed = -1;

    private static float remaining = -1;

    private static float totalNbrOfFrames = -1;

    private static float currentFrame = -1;

    private static int progressPercentage = -1;

    private static String junk;

    private static boolean proteinFound = false;

    private static boolean totalsFound = false;

    private static boolean framesFound = false;



    public static String match(String toSearch, String toMatch, String start, String end)

    {

    int posFrom = -1, posTo = -1;

    String matchFound = "";



    posFrom = toSearch.indexOf(toMatch);



    if(posFrom >= 0)

    {

    posFrom = toSearch.indexOf(start, posFrom); // character after search word



    posFrom++;

    posTo = toSearch.indexOf(end , posFrom); // character after parameter

    if(posTo >= 0)

    {

    // get the token that follows

    matchFound = toSearch.substring(posFrom, posTo);

    }

    else

    {

    // extra space not found before end of line

    // get the token that follows

    matchFound = toSearch.substring(posFrom);

    }



    }



    return matchFound;

    }



    public static void main(String []args)

    {

    Keyboard kb = new Keyboard();



    System.out.println("Please enter the file name to be searched");



    fileName = new String(kb.readln());



    try

    {



    BufferedReader inputFile = new BufferedReader(new FileReader(fileName));



    // file should be open, read it



    proteinFound = false;

    line = inputFile.readLine();

    while(line != null && proteinFound == false)

    {



    // find Protein name



    proteinName = match(line, "Protein:", " ", " ");

    if(proteinName != "") // non-blank

    {

    proteinFound = true;

    break;

    }

    line = inputFile.readLine();

    } // end while ! proteinFound



    framesFound = false;

    line = inputFile.readLine();

    while(line != null && totalsFound == false)

    {

    // find total number of frames



    junk = match(line, "Completed:", " ", ",");

    if(junk != "")

    {

    completed = Float.parseFloat(junk);

    }



    junk = match(line, "Remaining:", " ", " ");

    if(junk != "")

    {

    remaining = Float.parseFloat(junk);

    totalNbrOfFrames = completed + remaining;

    totalsFound = true;

    }

    line = inputFile.readLine();

    } // while ! totalsFound



    // find highest frame number

    framesFound = false;

    line = inputFile.readLine();

    while(line != null && framesFound == false)

    {

    junk = match(line, "Finished a frame", "(", ")");

    if(junk != "")

    {

    currentFrame = Float.parseFloat(junk);

    framesFound = true;

    }

    line = inputFile.readLine();

    } // end while ! framesFound



    // got at least one, check for the highest

    line = inputFile.readLine();

    while(line != null && framesFound == true)

    {

    junk = match(line, "Finished a frame", "(", ")");

    if(junk != "")

    {

    currentFrame = Float.parseFloat(junk);

    }

    else

    {

    framesFound = false;

    }

    line = inputFile.readLine();

    } // end while framesFound



    // do the math



    progressPercentage = (int) ( 100 * (currentFrame / totalNbrOfFrames));



    System.out.println("Protein is " + proteinName);

    System.out.println("Latest frame is " + currentFrame);

    System.out.println("Total number of frames are " + totalNbrOfFrames);

    System.out.println("Progress is currently at: " + progressPercentage + "%");



    }

    catch(IOException e)

    {

    System.out.println("The file was not found. Please check file name and/or path");

    }

    } // end main()

    } // end class



    You may compile it by putting it in a folder and typing javac ReadAndParse.java.

    This will produce two class files:

    Keyboard.class
    ReadAndParse.class

    You may then run it within the Terminal app. by typing java ReadAndParse.

    When it requests, please provide it the file name (and full path if it's in a different folder) where the logfile exists.

    If I put it in the same folder with the logfile, it asks for the file name and I type logfile_01.txt.

    If I put in in a different folder, I must type something like ~/FAH2/work/logfile_01.txt or if I can see the file in the Finder, I can drag it to the Terminal and the name will magically be pasted there.

    Anyway, it's a start. I should have a working GUI version sometime in the coming week.
     
  2. macrumors 6502

    Joined:
    Oct 27, 2002
    Location:
    Los Angeles, California
    #2
    I copied the code and pasted it into Project Builder, saved as "ReadAndParse.java," followed your insturctions and it works perfectly. Just wondering if the percentages are displayed in integers only? My percentage is currently at 0.3, so thats probably why the program was returning 0%. It's nice to see how many frames you have done, and how many are left without looking through the log file though. Also, is there anyway to keep the app open and refreshing every couple of seconds? If so, let me know, otherwise, thanks for making this, I'm sure it will be useful to everyone thats folding. I'm looking forward to the GUI version :) .
     
  3. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #3
    I actually did the percentage as an integer because most thermometers, progress bars, etc. use an integer value. Since I'm going toward GUI, I felt it was just as well to push it that way early.

    As far as automatically updating the figures, I want to do that, but I have to learn that part of Java first. It's probably not a big deal, but I haven't encountered that yet. :D The first version will have an Update button to give the user absolute control.
     
  4. macrumors newbie

    Joined:
    Dec 4, 2002
    Location:
    My chair
    #4
    Re: folding@home progress monitor

    Absolutely wonderful! is there a chance you can make it so we can pass the filename into the command line (IE java ReadAndParse /users/volumes/dave/F@H1/work/logfile_01.txt) that way I can make a quick little shell script to display the info more quickly?
     
  5. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #5
    Here's an early screenshot of the application actually running.
     

    Attached Files:

  6. macrumors 604

    MrMacMan

    Joined:
    Jul 4, 2001
    Location:
    1 Block away from NYC.
    #6
    Ohhhhh

    Ahhhhh

    :crowd applauds:
    Are you gonna give a readme and or tech support for your app? Or is it - it works, good. doesn't- too bad. basis?
     
  7. macrumors 6502

    Joined:
    Oct 27, 2002
    Location:
    Los Angeles, California
    #7
    Very nice, I can't wait :confused: :D :confused: :D . Thanks again for making this program. Is the first version going to include the option to display the progress in the dock as well? Because that would be amazing :) .
     
  8. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #8
    How about i make it open source and the community can take care of it? <ducks>

    I'm usually more particular than most so I will do my best to give you all something that won't break or cause trouble.
     
  9. macrumors 68000

    mc68k

    Joined:
    Apr 16, 2002
    #9
    very nice, can't wait to try it out! :D
     
  10. macrumors 604

    MrMacMan

    Joined:
    Jul 4, 2001
    Location:
    1 Block away from NYC.
    #10
    Now... Does this mean I can shut down my graphical client and the Folding processor still runs or can I hide it.

    Or (when this comes out) someone will need to help me on putting it in the terminal. :eek:
     
  11. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #11
    This is only a progress monitor. It does not initiate folding or control it in any other way.

    I really intended it for all of us who use the command line client, and because it's written using Java, that means that it will work on any platform supporting JDK 1.2 or higher.
     
  12. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #12
    Okay, here's a better version. Some clean up, some new stuff. I finally figured out how to get Java preferences to work--in part. I have to figure out at what point to write them before exiting the application. In C++, I would put them in the destructor, but..there isn't such a thing in Java. I suppose the finalize() method may be okay.

    If anyone knows how to work a checkbox and tell the state without a state change, please let me know. Otherwise, we won't have a 2nd processor progress bar active--at least, with the checkbox.
     

    Attached Files:

  13. macrumors 604

    MrMacMan

    Joined:
    Jul 4, 2001
    Location:
    1 Block away from NYC.
    #13
    Very nice work man. Post it up here whever you feel it is ready for some people ready to see it (and check it is macrumors public worthy).
     
  14. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #14
    Okay, I just loaded the new Java 1.4.1 update. Things look different as you can see. In contrast, I will also upload the thing running on Windows.

    Things are improving but there is so much documentation to read to get even little things done. Thanks for your patience--it's coming.

    The checkbox is working and properties (preferences) are partially implemented. Along with that, I need to change the file chooser dialog to select directories only.
     

    Attached Files:

  15. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #15
    Now for something different, a Windows/Metal look-and-feel.
     

    Attached Files:

  16. macrumors 604

    MrMacMan

    Joined:
    Jul 4, 2001
    Location:
    1 Block away from NYC.
    #16
    Sweet. :D

    It looks weird on java 1.4.1 do I need to upgrade it looks worse. :rolleyes:

    BTW, get on AIM :D
     
  17. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #17
    You know something...that would be amazing. I found the code and it's...well, it's QuickDraw. I need to find someone who knows how to convert QD code to Quartz.

    I'd like to make everything work in the first version but it's going to take a lot. I'm learning a lot too. :D
     
  18. macrumors 604

    MrMacMan

    Joined:
    Jul 4, 2001
    Location:
    1 Block away from NYC.
    #18
    First came genius then came the product.

    Wait till it is nice and good. Then we will all say 'ohhhh, ahhh' and praise you. :D
     
  19. macrumors 65816

    maradong

    Joined:
    Mar 7, 2003
    Location:
    Luxembourg
    #19
    Looks very nice.
    I might perhaps help you, if you are interessted in. Actually my java knowledge is not the best but perhaps i can grap some of your tricks and you some of mine :)
     
  20. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #20
    Thanks much!

    I may need the help.

    I finally figured out how to use a FilenameFilter with a File so that I can automatically use my path settings to avoid selecting the files each time. It's funny. The FilenameFilter class is so powerful and yet, it's barely shown in examples at all.

    I'll probably have a feature-complete version ready this weekend for everyone to test.
     
  21. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #21
    Okay, it's working and I've added some web pages to host it. The double-click-able file is only 12K, so you might just have the space to keep it.

    Go to the following web site to check it out and download it.

    http://www.mindspring.com/~us019818/fp/

    Your thoughts are appreciated. :)

    There will be a timer on the way to automatically update it.
     
  22. macrumors 604

    MrMacMan

    Joined:
    Jul 4, 2001
    Location:
    1 Block away from NYC.
    #22
    Okay so it runs good on Java 1.3.1.

    I noticed a small really insignificant glitch, when I slected the protien first and hit update it didn't but when I re-launched the app it loaded fine
     
  23. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #23
    It's been updated to remove that annoying 1st time glitch and the new version is on the website.
     
  24. thread starter Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #24
    I'm currently adding support for the Gromacs and SPG log file formats.

    When the Gromacs core is brought online for Macintosh, the progress monitor will be ready to handle it, even if that's this week.
     
  25. macrumors 604

    MrMacMan

    Joined:
    Jul 4, 2001
    Location:
    1 Block away from NYC.
    #25
    How could you do work on something that hasn't been implemented on the mac yet? :confused:

    sure PC's have it... but... is it the same exact file and file log?
     

Share This Page