Thanks very much Bob!  Yes, it's always nice to do everything within
JmolScript itself -- I very much appreciate seeing how to achieve this same
functionality that way (very educational)!  Two questions: 1) Would you mind
if I added your example code to the wiki along with the one that I added
yesterday so that others can find two alternate means to the same end?!  and
2) there is one line in your code that contains a construct I'm not familiar
with.  Would you, or someone else with more programming experience than
myself (read: almost anyone!), explain to me what this is doing:
titleLines[i] = (titleLines[i])[11][0].trim()  ?

It looks to me like you're taking everything "extra" off the beginning and
ends of each line in the titleLines array, but it's the [11][0] syntax that
has me stumped....If they are positions in the line array, then is this a
selection from the beginning of the actual title text to the end of that
line?

12345678901
TITLE     STRUCTURAL BASIS FOR THE PHOSPHOSERINE-PROLINE

Thanks!
-Tom



On Mon, Sep 22, 2008 at 4:02 PM, Robert Hanson <[EMAIL PROTECTED]> wrote:

> Nice. You can save yourself a little trouble with:
>
> var title = jmolEvaluate('getProperty("fileHeader").split().find("TITLE")')
>
> Also, realize that this goes back and retrieves the file again from its
> source. If you know you want to use the file header this way, it's more
> efficient to use
>
> set pdbGetHeader TRUE
>
> (uh, undocumented, I see...)
>
> This setting instructs Jmol to preserve the file header in memory when the
> file is loaded. It is used in Jmol Protein Explorer.
>
> Since you are really wanting to display this in Jmol, you might consider
> something like the following Jmol script, which requires no JavaScript:
>
> function getHeader()
>   var titleLines = getProperty("fileHeader").split().find("TITLE").split()
>   for (var i = 1; i <= titleLines.size;i = i + 1)
>       titleLines[i] = (titleLines[i])[11][0].trim()
>   end for
>   return titleLines.join("|")
> end function
>
> set echo bottom left
> echo @{getheader()}
>
>
> Something like that....
>
>
> Bob
>
> On Mon, Sep 22, 2008 at 3:50 PM, Thomas Stout <[EMAIL PROTECTED]>wrote:
>
>>
>> Here, then -- with my thanks for all the help -- is a working method to
>> pull the "TITLE" lines from a PDB file and echo it to the bottom of the Jmol
>> Applet window:
>>
>>                 var headerInfo = jmolGetPropertyAsString("fileHeader");
>>                 var cutUp = headerInfo.split("\n");
>>
>>                 var headerstring="";
>>
>>                 for (l=0;l<cutUp.length;l++) {
>>                 var regexp = new RegExp("TITLE.{5}(.*)\s*");
>>                 var temp = cutUp[l];
>>
>>                 if (temp.search(regexp) == 0) {
>>                 temp2 = RegExp.$1;
>>                 temp2.replace(/^\s+|\s+$/g, "").replace(/\s+/g, " ");
>>                 temp2 = temp2 + "|";
>>                 headerstring += temp2;
>>                                                 }
>>                 }
>>
>>                 headerstring.replace(/TITLE/, "");
>>                 jmolScript("set echo depth 0; set echo headerecho 2% 2%;
>> font echo 12 sanserif bolditalic; color echo green");
>>                 jmolScript('echo "' + headerstring + '"');
>>
>>
>> Cheers,
>> Tom
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win great
>> prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the
>> world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Jmol-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>
>>
>
>
> --
> Robert M. Hanson
> Professor of Chemistry
> St. Olaf College
> Northfield, MN
> http://www.stolaf.edu/people/hansonr
>
>
> If nature does not answer first what we want,
> it is better to take what answer we get.
>
> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to