sure - that would be fine. Please do add that. There are a lot of new
capabilities lurking in Jmol 11.6 that I just have not had time to demo.
x = (titleLines[3])[11][0].trim()
[n] in general means "the nth element of" and can be applied to strings or
lists. In this case we have a list of lines from a split() of a string. (The
split function can take an argument, but without an argument "new line" is
assumed.) These start at 1 for the first element and have the interesting
capability of being able to count back from the last element using numbers
less than or equal to 0. So "testing"[0] is "g" and "testing[-2] is "i".
Two brackets in a row: [m][n] specify a range of elements of a list or a
subset of characters of a string. The parentheses above are required to
differentiate taking the last line of lines 3-11:
(titleLines[3][11])[0]
and taking the 11th through the last character of line 3:
(titleLines[3])[11][0]
which is what we want here.
On Tue, Sep 23, 2008 at 11:43 AM, Thomas Stout <[EMAIL PROTECTED]>wrote:
>
> 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?
>
you got it! I'm splitting off TITLE as well as the continuation line
character in column 10 on the second an third lines.
>
> 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
>
>
--
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