GLYLIB  0.3.0b
add_to_moiety_selection.c File Reference
#include <mylib.h>
#include <molecules.h>
Include dependency graph for add_to_moiety_selection.c:

Go to the source code of this file.

Functions

void add_to_moiety_selection (moiety_selection *M, const char *SEL)

Detailed Description

Parses input string and adds selection to a "moiety_selection" structure.

This function might not be complete -- it is being written for a certain project, and should be expanded as needed.

NOTE!!! The moiety_selection *MUST* be allocated and initialized before calling this function. Initialization means that sub-arrays must have had an initial allocation (so that realloc won't choke).

It also must be initialized so that the "nX" variables start at zero. They need not be zero when they come to this function, but they need to be something real and not whatever garbage was left in memory.

The current syntax is:

number moiety-size-class moiety-designation optional_NOT designation_list

Only one such 'sentence' is allowed per call.

Syntax Examples:

Add residues number 1, 2, 8 and 38 to the selection:

4 Residue Numbers 1 2 8 38

Add atoms not named O5 and O6

2 Atoms Names -NOT- O5 O6

NOTE: Regarding entries, the function inspects only the smallest number of characters necessary to differentiate keywords. So, for the moiety-size-class entry, the strings "Residue" "R" "Raisin" and "RESI" are all the same to the program.

Acceptable values for input. The star (*) indicates the part of the function that will be written now (starting 20080910-ish):

Number: integer Eventually, this could be written to also read "range", but not today.

moiety-size-class: Atom Residue(*) Molecule Assembly Ensemble Group First letter differentiates.

moiety-designation: Name Number Index First two letters differentiate (actually, using second character in the string presently). Number = the number in the input data set (e.g., pdb file). Index = the array index as stored internally to the program

optional_NOT: -NOT- Must include all five characters, case sensitive. A single moiety_selection must be all positive or all negative. The calling function should decide before adding info to it. If SEL doesn't match, an error will be produced.

designation_list: (varies) Space-separated list of names or numbers. Names must exactly match the string contained in "N". Currently, spaces are not permitted in the names. (someone could re-write to allow it...)

More about the selections:

  • Selections will be set only within the relevant class. For example, if the class is set to "residue", then only residues will be added to the structure; their associated atoms will not be explicitly included. Similarly, if the -NOT- option is chosen with class residue, all residues except those listed will be added to the selection, but not the associated atoms.
  • Only the first "number" designations will be scanned from the designation_list. Any trailing characters or words will be ignored after the first "number" words are found.
  • Empty selection strings will be ingored and no error returned. The moiety_selection structure will be unaltered.
  • Errors will be returned if:
    • The first word in SEL is not an integer
    • Fewer than "number" words are found in the designation list
    • No match is found for either class or designation
    • The existing moiety_selection is set to be a positive list but SEL is negative or vice-versa.
    • Note, of course, that this function merely parses a selection string. It has no knowledge whether the molecule, etc., actually contains the selected items.

Definition in file add_to_moiety_selection.c.


Function Documentation

void add_to_moiety_selection ( moiety_selection M,
const char *  SEL 
)

< counter

< counter

< counter

< flag for negative selection

< number of designations in the list

< Temporary pointer

< Temporary string

< The trimmed selection

< The class

< The designation

< The designation_list

Make sure there is no leading or trailing whitespace in S to cause confusion

grab three items, place into number, class and designation

< Find length of first word -- this should be the integer

< Scan in the first integer

< Find length of second word -- this should be the class

< Find length of third word -- this should be the designation

< Find length of the ab'th item in the designation_list

< First letter of class differentiates molecule, residue or atom

< Second letter of designation differentiates name, number or index

< Second letter of designation differentiates name, number or index

< Second letter of designation differentiates name, number or index

Definition at line 89 of file add_to_moiety_selection.c.

References moiety_selection::ai, moiety_selection::an, moiety_selection::aN, moiety_selection::mi, moiety_selection::mn, moiety_selection::mN, mywhine(), moiety_selection::nai, moiety_selection::naN, moiety_selection::nan, moiety_selection::nmi, moiety_selection::nmN, moiety_selection::nmn, moiety_selection::nri, moiety_selection::nrN, moiety_selection::nrn, moiety_selection::posneg, prune_string_whitespace(), moiety_selection::ri, moiety_selection::rn, and moiety_selection::rN.

Here is the call graph for this function:

 All Classes Files Functions Variables Typedefs Defines