input
stringlengths
10
828
output
stringlengths
5
107
private void read total string tokens get tokens try if tokens 2 starts with energy in an optimization an energy is reported in a follow up step that energy i don t want so only set the energy once if have at set energies e tokens 1 tokens tokens length 1 equivalent atom sets catch exception e ignore any problems in dealing with the line
interpret a line starting with a line with total in it
private string fix tag string tag make sure that bq s are not interpreted as boron if tag equals ignore case bq return x if tag to lower case starts with bq tag tag substring 2 bq return character to upper case tag char at 0 tag length 1 character to lower case tag char at 1
returns a modified identifier for a tag so that the element can be
private void process symmetry operations loop block throws exception parse loop parameters symmetry operations fields int n refs 0 for int i property count i 0 if field of i none n refs if n refs 1 logger warn que symmetry equiv or space group symop property not found skip loop return while tokenizer get data for int i 0 i tokenizer field count i switch field property i case symop xyz case sym equiv xyz set symmetry operator field break
retrieves symmetry operations
private void set energy string tokens get tokens energy key energy energy string tokens 1 atom set collection set atom set names energy tokens 1 equivalent atom sets atom set collection set atom set energy energy string parse float energy string
interpret the energy line for non scf type energy output
private void add new bond int i int j atom set collection add new bond i j if is molecular return bs connected i set j bs connected j set i
add the bond and mark it for molecular processing
private void set bs atom atoms int iatom bit set bs bonds bit set bs bit set bs bond bs bonds iatom bs set iatom for int i bs bond next set bit 0 i 0 i bs bond next set bit i 1 if bs get i set bs atoms i bs bonds bs
iteratively run through connected atoms adding them to the set
public boolean check last model if is last model model number do process lines continuing false return false do process lines false return true
sets continuing and do process lines
public boolean is last model int model number return desired model number 0 model number last model number
after reading a model q is this the last model
private void set point4f pt float factor pt null 0 pt distance q zero if factor 0 q0 1 return q0 pt w factor q1 pt x factor q2 pt y factor q3 pt z factor
x y z w q1 q2 q3 q0 and factored
public void set max size int max size if max size this max size return if max size 2 max size 2 while next command max size command list remove 0 next command if next command max size next command max size 1 cursor pos next command this max size max size
resets maximum size of command queue
private string get command return command list get cursor pos
calculates the command to return
public void add command string str command if is on str command ends with error flag return if str command ends with nohistoryatall flag return int i i don t think jmol can deliver a multiline parameter here while i str command index of n 0 string str str command substring 0 i if str length 0 add command line str str command str command substring i 1 if str command length 0 add command line str command
adds any number of lines to the command history
private void add command line string command if command null command length 0 return if command ends with nohistoryline flag return if next command max size command list remove 0 next command max size 1 command list add next command command next command cursor pos next command command list add next command for int i 0 i next command i system out println history i command list get i
adds a single line to the bottom of the list resets list position
public point3f to supercell point3f fpt fpt x na fpt y nb fpt z nc return fpt
convenience return only after changing fpt
public float quantize float x boolean is low end int n get palette color count current palette x int x n is low end 0f 1f n return x 0 lo x 1 hi lo hi lo x
gets the value at the color boundary for this color range fraction
protected void fill data block string data int min line len throws exception int n lines data length for int i 0 i n lines i data i get tokens discard lines until non blank if data i length min line len i
fills an array with a pre defined number of lines of token data
public boolean get data throws exception line is already present and we leave with the next line to parse for int i 0 i field count i if loop data i get next data token null return false return true
general reader for loop data
private void set string string str this str line str cch str null 0 str length ich 0
sets a string to be parsed from the beginning
public string peek token throws exception while has more tokens if set string next line null return null int ich this ich str peeked next token ich peeked this ich this ich ich return str peeked
just look at the next token
public string full trim string str int pt0 0 int pt1 str length for pt0 pt1 pt0 if n t index of str char at pt0 0 break for pt0 pt1 pt1 if n t index of str char at pt1 1 0 break return str substring pt0 pt1
specially for names that might be multiline
protected void log print stream out int level string txt throwable e if out system err system out flush if out null txt null e null txt txt null txt out println logger log level logger get level level txt e null e get message if e null stack trace element elements e get stack trace if elements null for int i 0 i elements length i out println elements i get class name elements i get line number elements i get method name if out system err system err flush
method to output a log
private token token next return itoken infix atoken infix length null atoken infix itoken infix
increments the pointer does not set the token or the value
protected void set element and isotope atom atom string str int isotope parse int str if isotope integer min value atom element symbol str else str str substring isotope length atom element number short str length 0 isotope isotope 7 jmol adapter get element number str
allow 13 c 15 n 2 h etc
public void set atom set name string atom set name if is trajectory set trajectory name atom set name return set atom set auxiliary info name atom set name current atom set index todo trajectories could have different names need this for vibrations if allow multiple set collection name atom set name
sets the name for the current atom set
public void set atom set names string atom set name int n for int idx current atom set index n 0 idx 0 idx set atom set auxiliary info name atom set name idx
sets the atom set names of the last n atom sets
public void set atom set number int atom set number set atom set number current atom set index is trajectory trajectory step count 0 atom set number
sets the number for the current atom set
public void set atom set model property string key string value set atom set model property key value current atom set index
sets a property for the current atom set
public void set atom set model property string key string value int atom set index lazy instantiation of the properties object properties p properties get atom set auxiliary info atom set index model properties if p null set atom set auxiliary info model properties p new properties atom set index p put key value
sets the a property for the an atom set
public void set atom set auxiliary info string key object value set atom set auxiliary info key value current atom set index
sets auxiliary information for the atom set
public script context check script silent string script script context sc compiler compile null script false true false true if sc error type null return sc restore script context sc false false false is syntax check true is cmd line c or c option is cmd line c option false pc 0 try instruction dispatch loop false catch script exception e set error message e to string sc get script context is syntax check false return sc
a method for just checking a script
public void set atom set auxiliary info string key object value int atom set index if atom set index 0 return if atom set auxiliary info atom set index null atom set auxiliary info atom set index new hashtable string object if value null atom set auxiliary info atom set index remove key else atom set auxiliary info atom set index put key value
sets auxiliary information for an atom set
public int calculate struts bit set bs1 bit set bs2 select only one model make connections 0 float max value jmol edge bond strut token delete bs1 bs2 null false false 0 int i atom bs1 next set bit 0 if i atom 0 return 0 model model models atoms i atom model index return model is bio model model calculate struts model set this bs1 bs2 0
see comments in org
public void set atom set property for sets string key string value int n for int idx current atom set index n 0 idx 0 idx set atom set model property key value idx
sets the same properties for the last n atom sets
public void clone last atom set properties clone atom set properties current atom set index 1
clones the properties of the last atom set and associates it
public bit set get model atom bit set including deleted bit set bs models bit set bs new bit set if bs models null bs all null bs all bit set util set all atom count if bs models null bs or bs all else for int i bs models next set bit 0 i 0 i bs models next set bit i 1 bs or get model atom bit set including deleted i false return bs
note this method returns all atoms including deleted
private string clean script comments string script int pt script index of 1 if pt 0 these are for jmol console and script editor script extensions script substring pt 1 script script substring 0 pt have comments script index of 0 speeds processing return get embedded script script
in addition we can have
private void get bs ok if no values at all n molecules 1 return bs ok new bit set n x n y n z set xyzbohr null for int ix 0 index 0 ix counts xyz 0 ix for int iy 0 iy counts xyz 1 iy for int iz 0 iz counts xyz 2 index iz process atoms ix iy iz index logger info nci calculation scf type type intra intra inter molecular grid points bs ok cardinality
grid based discrete scf calculation needs to know which
public void set planes float planes yz planes raw planes yz count n y n z
raw file data planes are passed to us here from volume file reader
public string get next statement return pc aatoken length set error line message function name filename get linenumber null pc statement as string aatoken pc 9999 log messages
when paused indicates what statement will be next
private string get command int pc boolean all this line boolean add semi if pc line indices length return if all this line int pt0 1 int pt1 script length for int i 0 i line numbers length i if line numbers i line numbers pc if pt0 0 pt0 line indices i 0 pt1 line indices i 1 else if line numbers i 0 line numbers i line numbers pc break if pt1 script length 1 script ends with pt1 return pt0 script length pt1 pt0 script substring math max pt0 0 math min script length pt1
used for recall of commands in the application console
public void set background argb int argb bgcolor argb background of jmol transparent in front of certain applications vlc player when background 0 0 1
sets background color to the specified argb value
public void initialize point3f center float radius boolean hemisphere only this center center this radius radius t hemisphere false cx center values 0 center x cy center values 1 center y cz center values 2 center z leaf null stack 0 bspt ele root sp 1 find left leaf t hemisphere hemisphere only
initialize to return all points within the sphere defined
public void release set bspt
nulls internal references
private boolean is within radius point3f t dx t x cx return t hemisphere dx 0 dx math abs dx radius dy math abs t y cy radius dz math abs t z cz radius
checks one point3f for distance
public void set console jmol app console interface console get property data api get app console console
sets a custom console should be called immediately following allocate viewer
public void fill sphere int diameter point3f center fill sphere diameter int center x int center y int center z
fills a solid sphere
public void fill rect int x int y int z int z slab int width fill int height fill hover and labels only slab at atom or front simple z window clip if is clipped z z slab return if x 0 width fill x if width fill 0 return x 0 if x width fill width width fill width x if width fill 0 return if y 0 height fill y if height fill 0 return y 0 if y height fill height height fill height y while height fill 0 plot pixels unclipped width fill x y z
fills background rectangle for label
public boolean set symbol string symbol is aromatic symbol equals symbol to lower case has symbol true if symbol equals is aromatic false but is aromatic ambiguous true element number 2 return true if symbol equals xx but is aromatic ambiguous true element number 0 return true aromatic ambiguous false if symbol equals a symbol equals a allow 6a if element number 0 element number 1 return true if is aromatic symbol symbol substring 0 1 to upper case symbol length 1 symbol substring 1 element number elements element number from symbol symbol true return element number 0
sets the symbol of the atm
public short get element number return element number
returns the atomic number of the element or 0
public short get atomic mass return atomic mass
returns the atomic mass of the atom
public void set atomic mass int mass atomic mass short mass
sets the atomic mass of the atom
public void set charge int charge this charge charge
sets the charge of the atom
public int get matching atom return matching atom
returns the number of a matching atom in a molecule
public void set matching atom int atom matching atom atom
sets the number of a matching atom in a molecule
public int get chiral class return chiral class
returns the chiral class of the atom
public void set chiral class int chiral class this chiral class chiral class
sets the chiral class of the atom
public int get chiral order return chiral order
returns the chiral order of the atom
public void set chiral order int chiral order this chiral order chiral order
sets the chiral order of the atom
public void set explicit hydrogen count int count missing hydrogen count count
sets the number of explicit hydrogen atoms bonded with this atom
public void set implicit hydrogen count int count implicit hydrogen count count
sets the number of implicit hydrogen atoms bonded with this atom
public smiles bond get bond int number return parent null parent get bond number number 0 number bond count bonds number null
returns the bond at index code number code
public int get covalent bond count return get bond count
returns the number of bonds of this atom
public boolean are equal string smiles smiles search molecule bit set ret find smiles molecule false true true return ret null ret length 1
for junit test mainly
private char get bond stereochemistry jmol edge bond jmol node atom from if bond null return 0 int i bond index boolean is first atom from null bond get atom index1 atom from get index return bs bonds up get i is first bs bonds dn get i is first 0
retrieves the saved character based on the index of the bond
protected void render dots int n points g3d set colix colix g3d draw points n points screen coordinates dot scale
also called by geo surface when in motion
public boolean is claimed return group null
the gesture server needs to know whether an incoming
public void set group group group group group group update this
set the group for this touch point
public void update location location long time int state location location state state changed true time time if group null group update this
update this touch point with a new location and state
private boolean read touch points throws ioexception with count int count in read int if count 0 in close return false int touch point data length if count 0 count count touch point data length in read int else original sparsh ui style touch point data length 13 boolean do consume false system out println reading count input events for int i 0 i count i do consume read touch point touch point data length remove dead touch points return do consume
n where n is the number of points to be transmitted
private boolean read touch point int len throws ioexception int id in read int float x in read float float y in read float int state in read byte long time len 21 in read long system current time millis if len 21 in read new byte len 21 location location new location x y boolean do consume gesture server process touch point touch points id location time state if state touch state death flag touch point for removal id return do consume
modified for jmol to also transmit the time as a long
public int get group id touch point touch point throws ioexception byte temp float new byte 4 send the x and y coordinates converter float to byte array temp float 0 touch point get location get x buffer out write temp float converter float to byte array temp float 0 touch point get location get y buffer out write temp float send buffer message type get group id get the group id int ret in read int return ret
retrieve a list of allowed gestures for the provided group id
public void process events int group id list event events throws ioexception for int i 0 i events size i buffer out write int group id buffer out write events get i serialize send buffer message type event
instruct the client to process the events that have been generated by a
public void process error int err code throws ioexception buffer out write int 1 buffer out write int err code send buffer message type event
send an error message to the client
public void start gesture server client server new gesture server network configuration client port this client thread new thread client server client thread set name jmol sparsh ui client gesture server on port network configuration client port client thread start device server new gesture server network configuration device port this device thread new thread device server device thread set name jmol sparsh ui device gesture server on port network configuration device port device thread start
two independent threads one accepting multiple clients one not
public void run try open socket accept connections catch exception e logger info gesture server connection unavailable
start accepting connections
private void add directory string directory string ext string type allowed checking files if test one null directory equals test one return file dir new file datafile directory directory string exts text format split ext for int ie 0 ie exts length ie final string e exts ie string files dir list new filename filter public boolean accept file dir string name return name ends with e if files null logger warn no files in directory directory for extension e else for int i 0 i files length i add file e ends with gz directory files i type allowed
add tests for each file in a directory
public jsonarray put int index map object object value throws jsonexception put index new jsonobject value return this
put a value in the jsonarray where the value will be a
public void process string args process command line arguments if args null for int i 0 i args length i if config equals ignore case args i force config true once configured process for the checking process
check for missing files
private void process configuration load configuration if force config configuration is configured show sent projects true configure else process directories
check for missing files
public void process directories if configuration get loop process directories once system exit 0 else do available projects downloaded false available ambers downloaded false system out println starting processing date format get date time instance format new date boolean special interval process directories once system out println processing done date format get date time instance format new date system out println int interval special interval configuration get special interval configuration get basic interval try thread sleep interval 60 1000 catch interrupted exception e while true
process all directories for files
private boolean process directory string directory if directory null return false return process directory new file directory
process a directory for files
private boolean process file file file if file null file is file return false boolean special interval false if configuration get detailed output system out print file file get name string project extract project number file if project null if configuration get detailed output system out print unable to find project number else if configuration get detailed output system out print project n project special interval process project number file project if configuration get detailed output system out println return special interval
check a xyz file
private string extract project number file file string project project extract project number from content file if project null return project project extract project number from name file if project null return project return null
analyze the code file code to find the project number
private string extract project number from name file file string file name file get name removing p if file name length 0 file name substring 0 1 equals ignore case p file name file name substring 1 extracting the project number int index 0 while index file name length character is digit file name char at index index if index 0 index file name length return null if file name char at index file name char at index return null return file name substring 0 index
analyze the code file code name to find the project number
private void download available files try file utils copy urlto file new url http www jmol org fah available projects txt available projects catch malformed urlexception e catch ioexception e system out println error retrieving available projects txt from jmol website try file utils copy urlto file new url http www jmol org fah available amber txt available ambers catch malformed urlexception e catch ioexception e system out println error retrieving available amber txt from jmol website
download the list of available files from http www
public string get project name int project num string name null retrieve project information information info get info project num if info null initialize with static name name info static name long date info static date replace eventually with ps name if info ps name null info ps date date name null name info ps name date info ps date return name
get name for a project
public void add information string user name int team num for int i 0 i pages count i add information user name team num i projects by page
add information from stanford stats site
public void display contributions for int i 0 i infos size i try integer count integer infos get i if count null system out println p i t count catch class cast exception e
displays contribution informations
public writer write writer writer throws jsonexception try boolean commanate false iterator string keys this keys writer write while keys has next if commanate writer write string key keys next writer write quote key writer write object value this map get key if value instanceof jsonobject jsonobject value write writer else if value instanceof jsonarray jsonarray value write writer else writer write value to string value commanate true writer write return writer catch ioexception exception throw new jsonexception exception
write the contents of the jsonobject as json text to a writer
private void output emprotz dat file int unknown projects 0 for int ii 0 ii project info size ii information info get info ii if info null if info static preferred null info static value null info static frames null system out println ii non nls 1 non nls 2 system out println info static preferred non nls 1 system out println info static value non nls 1 system out println info static frames non nls 1 else unknown projects system out println unknown unknown projects non nls 1
output data in the same format as emprotz
private void add hydrogen smiles search molecule smiles atom bonded no longer testable this way smiles parser does not add h atoms smiles atom atom h molecule add atom atom h set symbol h if bonded null create bond bonded atom h smiles bond type single false
adds an hydrogen
private void output new line system out println
output a new line
private void output info s object object boolean separator output info txt s object separator
output static information
private void output info ps object object boolean separator output info txt ps object separator
output psummary information
private void output info em object object boolean separator output info txt em object separator
output em information
private void output info fci object object boolean separator output info txt fci object separator
output fci information
private void output info qd object object boolean separator output info txt qd object separator
output qd information
public void to cartesian point3f pt boolean as absolute symmetry interface unit cell get current unit cell if unit cell null unit cell to cartesian pt as absolute
absolute or relative to origin of unitcell x y z
public void to fractional point3f pt boolean as absolute symmetry interface unit cell get current unit cell if unit cell null unit cell to fractional pt as absolute
absolute or relative to origin of unitcell x y z
public void to unit cell point3f pt point3f offset symmetry interface unit cell get current unit cell if unit cell null unit cell to unit cell pt offset
relative to origin without regard to unitcell x y z