PDA

View Full Version : folding@home progress monitor




bousozoku
Mar 1, 2003, 03:57 PM
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.



pepeleuepe
Mar 1, 2003, 04:27 PM
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 :) .

bousozoku
Mar 1, 2003, 07:32 PM
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.

dwaxman
Mar 1, 2003, 08:54 PM
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?

bousozoku
Mar 4, 2003, 09:33 PM
Here's an early screenshot of the application actually running.

MrMacMan
Mar 4, 2003, 09:41 PM
Originally posted by bousozoku
Here's an early screenshot of the application actually running.
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?

pepeleuepe
Mar 4, 2003, 09:53 PM
Originally posted by bousozoku
Here's an early screenshot of the application actually running.

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 :) .

bousozoku
Mar 4, 2003, 09:54 PM
Originally posted by MrMacman
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?

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.

mc68k
Mar 4, 2003, 11:40 PM
very nice, can't wait to try it out! :D

MrMacMan
Mar 5, 2003, 04:45 PM
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. :o

bousozoku
Mar 5, 2003, 06:18 PM
Originally posted by MrMacman
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. :o

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.

bousozoku
Mar 6, 2003, 09:30 PM
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.

MrMacMan
Mar 7, 2003, 09:40 PM
Originally posted by bousozoku
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.

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

bousozoku
Mar 10, 2003, 06:55 PM
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.

bousozoku
Mar 10, 2003, 06:56 PM
Now for something different, a Windows/Metal look-and-feel.

MrMacMan
Mar 10, 2003, 07:34 PM
Sweet. :D

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

BTW, get on AIM :D

bousozoku
Mar 10, 2003, 10:00 PM
Originally posted by pepeleuepe
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 :) .

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

MrMacMan
Mar 10, 2003, 10:20 PM
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

maradong
Mar 13, 2003, 12:46 AM
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 :)

bousozoku
Mar 13, 2003, 12:24 PM
Originally posted by maradong
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 :)

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.

bousozoku
Mar 13, 2003, 04:31 PM
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.

MrMacMan
Mar 13, 2003, 09:18 PM
Originally posted by bousozoku
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.

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

bousozoku
Mar 15, 2003, 07:47 AM
It's been updated to remove that annoying 1st time glitch and the new version is on the website.

bousozoku
Mar 17, 2003, 11:49 AM
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.

MrMacMan
Mar 17, 2003, 02:15 PM
Originally posted by bousozoku
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.

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?

bousozoku
Mar 17, 2003, 02:45 PM
Originally posted by MrMacman
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?

Supposedly so. There would be no reason for them to write special code for the log files for one operating system over another. This would just be more work for them, which would be unnecessary and unwanted.

bousozoku
Mar 17, 2003, 07:21 PM
Gromacs support has been added and is working, hopefully glitch-lessly. :)

I'll know when I hear more from the Stanford forums.

I've also made a change to show the build date when you double-click on the dialog box, away from the regular controls.

bousozoku
Mar 22, 2003, 01:05 PM
I've implemented a way to estimate the time to completion for a work unit, as you can see from the dialog box.

As soon as I've worked it out, the changes will be on the website.

GeeYouEye
Mar 22, 2003, 05:52 PM
Hmm... any chance we could get a version that doesn't use 40-odd percent of my CPU time? I'd rather have that going into F@H itself.

bousozoku
Mar 22, 2003, 06:31 PM
Originally posted by GeeYouEye
Hmm... any chance we could get a version that doesn't use 40-odd percent of my CPU time? I'd rather have that going into F@H itself.

You have to ask Apple why Java is such a pig. I've been implementing it as efficiently as possible. I keep it minimised in the dock, which leaves it at zero percent (or as near as any app comes) and pull it up occasionally to update.

I've thought about using the metal look-and-feel you can see above, which should cut down on the CPU usage since it doesn't use the fluid effects.

alset
Mar 22, 2003, 06:36 PM
Originally posted by GeeYouEye
Hmm... any chance we could get a version that doesn't use 40-odd percent of my CPU time? I'd rather have that going into F@H itself.

I have the same problem. I want to use this app, but I'll wait until it's a little more mature.

Great work!

Dan

bousozoku
Mar 22, 2003, 09:50 PM
Okay, the version on the website currently is unlikely to take so much CPU time.

It also eschews the Aqua look-and-feel to do it, instead using the native Java look-and-feel. It looks as though it's taking 0.40 % CPU now. Those of you who upgraded to v.1.4.1 should be pleased.

By the way, once it's been through a new frame, you can double-click on the progress bar to get an estimated time to completion.

alset
Mar 22, 2003, 10:21 PM
It's hideous, but it only takes up 1.7% of my proc, so thanks! I will definitely keep watching the development of this great app.

Dan

MrMacMan
Mar 22, 2003, 11:22 PM
Originally posted by alset
It's hideous, but it only takes up 1.7% of my proc, so thanks! I will definitely keep watching the development of this great app.

Dan

I'm still running 1.31 because of the -performance with 1.4 Java. And why again do you all need to keep the app up all the time?

I launch it when I want to see progress. okay...

MrMacMan
Mar 23, 2003, 03:51 PM
Problem with latest version:

alset
Mar 23, 2003, 05:04 PM
Originally posted by MrMacman
I'm still running 1.31 because of the -performance with 1.4 Java. And why again do you all need to keep the app up all the time?

I launch it when I want to see progress. okay...

I'm a progress junkie. I check it all the time. Besides, it makes me feel like a big man! :)

Dan

MrMacMan
Mar 23, 2003, 06:44 PM
Originally posted by alset
I'm a progress junkie. I check it all the time. Besides, it makes me feel like a big man! :)

Dan

But what your acually doing is eating up the amount of CPU, slowing your folding slightly. :o

bousozoku
Mar 23, 2003, 06:55 PM
Originally posted by MrMacman
Problem with latest version:

That's not a problem. I'm telling you that there is not enough information to calculate anything because no other frames have been processed yet.

It takes at least one more frame to calculate an estimate. Leave it running long enough to let another frame be shown.

The amount of CPU usage is minimal. You can leave it minimised in the dock, if you prefer and bring it back to full size when you want to see the progress.

MrMacMan
Apr 28, 2003, 11:13 PM
The progress monitor has been updated for the gromac core and other slight improvments.

In case you get a gromac unit the completion date isn't perfect and he knows.

Any new members this gives you your current protien, and an estimate on completion. the link again (http://www.mindspring.com/~us019818/fp/)
and your set.

bousozoku
May 3, 2003, 05:29 PM
Gromacs estimated time to completion works correctly now and the new version is available from the website.

If you have questions or suggestions, let me know.

bousozoku
Aug 9, 2003, 01:47 PM
I've updated again to correct some problems when switching proteins. I've also changed it to auto-update on startup. Percentages display in the title, so you can see them when the application is minimised, but I'm still working on implementing the timer.

visor
Aug 23, 2003, 11:52 AM
Very nice,
now I can finally check how my linux box advances its syphicus task as well as the mac at the same time in an ungly metal window ,)

Do you plan to give the newest source away? I'd consider integrating a bit more netwoking into it so I could check the linux box without the need of mounting.

bousozoku
Aug 25, 2003, 10:04 PM
Originally posted by visor
Very nice,
now I can finally check how my linux box advances its syphicus task as well as the mac at the same time in an ungly metal window ,)

Do you plan to give the newest source away? I'd consider integrating a bit more netwoking into it so I could check the linux box without the need of mounting.

Thanks.

I let one person have the source and he was supposedly almost done with it several weeks ago, but I've seen nothing so I guess he's not going to finish.

I was a little leery of letting the source go but I may consider it again.

Plutronics
Aug 26, 2003, 09:39 AM
Eureka, I've Switched to the Console Client with "FoldingProgress.jar" and I like it!!! I did have a problem getting FP going ....

The old Graphic setup was: Users/pluto/Library/Folding@home...
I deleted the folder's CONTENTS and installed the Console Client
The new Console setup was: Users/pluto/F@H1...
I couldn't get "FoldingProgress.jar" to work until I deleted the old "Folding@home" FOLDER , deleted the "Users/pluto/fpsettings" and then reran "FoldingProgress.jar"
The New work Unit on my B&W 450MHz G4 ( I.E. the Guinea Pig) is a 51.4 pointer due to finish Friday at 6:09AM ....COOOOL... Thanks bousozoku and Friends!!
I was going to do the same on my QuickSilver 1.26GHz G4 but the new work unit on it this morning was a 9 pointer (go figure) due to finish after lunch.
At fifty Years old, I can't afford to pass up a Quickie!
The Wife's iMac FP 700MHz G4, the one that really needs the Console due to 3 users, won't get done with it's WU till Friday sometime. Gotta finish the points before starting over! Now I've got time to bring my Pismo and B&W G3 up to OSX Jaguar and start them folding ( if Work don't get in the Way)
Later Dudes

bousozoku
Aug 26, 2003, 02:02 PM
I'm glad it's working for you now. I'm not sure why it wouldn't work with two different work folders unless you just had it pointed toward the old one.

It's good to have someone else folding. :)

bousozoku
Dec 7, 2005, 04:25 AM
I made a recent change to this to support Double Gromacs work units and to revive my work after the disk scramble way back when. Plus, with Quads available, it might be extremely useful to support them easily and that work was underway right before the scramble.

Anyway, I don't know if anyone other else is still using it, but it's available here and now.

trainguy77
Dec 11, 2005, 10:19 PM
Could we combine this with the Widget?

bousozoku
Dec 11, 2005, 10:28 PM
Could we combine this with the Widget?

I don't think so since this works on most any platform that supports Java 1.3.x

redeye be
Dec 12, 2005, 05:45 AM
It should be technically possible, if the progress monitor would update a simple text or xml file on the HD with current progress.
The widget could then go get and parse that file to show.

Does this mean you're interested in taking over the widget development ? ;)

bousozoku
Dec 12, 2005, 04:28 PM
It should be technically possible, if the progress monitor would update a simple text or xml file on the HD with current progress.
The widget could then go get and parse that file to show.

Does this mean you're interested in taking over the widget development ? ;)

I'm not even sure I'm interested in doing any widget development. Besides, I've not seen anything of it, though I'm reasonably good with JavaScript.

Right now, I'm more interested in implementing changes for my progress monitor that I planned for 2004 before the drive crash killed my spirit.

It would be nice to see 8 process support as well as single process support in the same, flexible code.

redeye be
Dec 12, 2005, 04:51 PM
I'm not even sure I'm interested in doing any widget development. Besides, I've not seen anything of it, though I'm reasonably good with JavaScript.

Right now, I'm more interested in implementing changes for my progress monitor that I planned for 2004 before the drive crash killed my spirit.

It would be nice to see 8 process support as well as single process support in the same, flexible code.
I was talking to trainguy about being interested in taking over the widget. ;)
And i have no intention at all to burden you with any work on it. If trainguy77 decides to take up development, it's up to him wether to nag you for widget support :D

Good luck on coding, keep up the spirit!

Cheers

trainguy77
Dec 12, 2005, 04:53 PM
If i knew enough coding i would do it but......I have only done a little Java, a little Cocoa, and C. So i don't know how much I would have to learn to do it.
O and i know HTML/CSS/XHTML
I would be willing but......

O I just thought of 1 more thing, I don't have 10.4 but i can use Amnestry to test them, then i could have someone else make sure it also works on 10.4. But i bet it if it works with Amnestry it would work with 10.4. I am a fast learner so maybe i will do some poking around with the current code i see if i can figure it out.

bousozoku
Dec 12, 2005, 05:08 PM
I could end up eliminating the need for a widget but I'm not sure how interested I am in making a whole lot of extra work for myself. Right now, I have to focus on basics and re-creating source code.

My current enhancements list is:


Flexible process support (1-8 processes with only those active showing--possible compact interface option)
Preferences displays to support various options, some prior to availability
Networking interface with future ability to show all configured machines, regardless of location


I'd like to be able to suppport displaying off queue data and various data given by Stanford and Overclockers but a lot of these things are wish list only.

trainguy77
Dec 12, 2005, 05:29 PM
I really think that the Widget could be combined with your program. I am not sure how this would look. But all the code for getting info from the stats site is already in the widget.

trainguy77
Dec 12, 2005, 06:46 PM
I was a little bored so......


I just got used to a bit of the code. Not all of it, as there is alot of code.....for me. But i figured this much out. Now i need to find a way to integrate with the program....or we need to talk about if we want to do this....:p

bousozoku
Dec 12, 2005, 09:00 PM
I was a little bored so......


I just the used to a bit of the code. Not all of it as there is alot of code.....for me. But i figured this much out. Now i need to find a way to integrate with the program....or we need to talk about if we want to do this....:p

I'll take a look at it when I get a couple of minutes. I need to read up on the equivalent HTML reading bits for Java that JavaScript and widgets have available to them.

Dreadnought
Dec 13, 2005, 12:25 PM
I hereby volunteer for the widget test team!

bousozoku
Dec 13, 2005, 10:07 PM
I hereby volunteer for the widget test team!

widget give us a few minutes to decide what we're doing before anyone has a widget to test? :p

I downloaded a Konfabulator widget to check that as well. If we can make it work many places, I would be more inclined to be involved with something else but Java can already do that. I just need to figure it out. That way, it works on Linux as well.