STAR::Parser(3pm)
π STAR::Parser π
okay bestie, welcome to the Perl extension for parsing STAR compliant files (with no nested loops) β that's the NAME, and she's serving exactly what she says on the tin πΈ
β¨ Version β¨
This documentation refers to version 0.59 of this module. yes, we're old money, we're vintage, we're iconic π
π SYNOPSIS π
use STAR::Parser;
($data) = STAR::Parser->parse('1fbm.cif');
($dict) = STAR::Parser->parse(-file=>'mmcif_dict',
-dict=>1,
-options=>'l'); #logs activity
π¦ DESCRIPTION π¦
okay so STAR::Parser is one of several related Perl modules for parsing STAR compliant files β think CIF and mmCIF files, the whole vibe π Currently, these modules include STAR::Parser, STAR::DataBlock, STAR::Dictionary, STAR::Writer, STAR::Checker, and STAR::Filter. the squad fr fr π
STAR::Parser is the parsing module, with the class method parse for parsing any STAR compliant files or dictionaries, as long as they do not contain nested loops β meaning only one level of loop is supported, that's the boundary, no cap π§
So when you parse a file, you get back an array of DataBlock objects (one for each data_ entry in the file) π The class STAR::DataBlock contains object methods for these objects, and STAR::DataBlock is automatically accessible through STAR::Parser. Main character energy, honestly β¨
When you parse a dictionary (which you signal with the -dict=>1 parameter), you get back an array of Dictionary objects instead. And plot twist: STAR::Dictionary is a sub-class of STAR::DataBlock π the family tree is thriving.
The methods of this module and the accompanying modules (STAR::DataBlock, STAR::Checker, etc.) support "named parameters" style for passing arguments. And here's the tea: if only one argument is mandatory, then it may be passed in either a "named parameters" or "unnamed parameters" style, for example:
@objs = STAR::Parser->parse( -file=>$file, -options=>'d' ); #debugging
@objs = STAR::Parser->parse( -file=>$file ); #no options
or: @objs = STAR::Parser->parse( $file );
π CLASS METHODS π
π parse
Usage: @objs = STAR::Parser->parse(-file=>$file[,
-dict=>1,
-options=>$options]);
or: @objs = STAR::Parser->parse($file);
Examples, bestie, because examples are everything π:
1)
@objs = STAR::Parser->parse('1fbm.cif');
$data = $objs[0];
OR:
($data) = STAR::Parser->parse('1fbm.cif');
2)
@objs = STAR::Parser->parse('7files.txt');
foreach $obj (@objs) {
# do something, see STAR::DataBlock
}
3)
@objs = STAR::Parser->parse(-file=>'mmcif_dict',
-dict=>1,
-options=>'l'); #logs activity
$dict = @objs[0];
So here's what this method is actually doing, step by step π§
First, it searches the file and creates a DataBlock object for each data_ identifier found in the file. And if no data_ identifier is found? Then only one DataBlock object will be created (with $d='untitled', see below). If parse is invoked with the -dict=>1 option, then a Dictionary object is created for each data_ identifier found instead. glow up π₯
Next, the method populates the data structure of each DataBlock or Dictionary object. The parsed data may be queried or accessed by object methods of the STAR::DataBlock and STAR::Dictionary modules. See the documentation for STAR::DataBlock and STAR::Dictionary π
The method always returns an array of objects β even if it contains only one object (which is what happens if there's only one data_ block in the file). consistency queen π
Internally, the parsed data is stored in a multidimensional hash with keys for data blocks ($d), save blocks ($s), categories ($c), and items ($i) π
Let's break it down:
- For a file,
$swill always be'-', since there are no save blocks in files. - For a dictionary,
$swill be'-'outside ofsave_blocks, and'CATEGORY'or'_item'insidesave_CATEGORYorsave__itemblocks (capitalization depends on the user's dictionary, so watch out, iykyk). - If a file is parsed that contains no
data_identifier, then$dbecomes'untitled'. $crefers to a category, such as_atom_site.$irefers to an item, such as_atom_site.id.
The method may be invoked with an $options string. These options are the following letters, which may be concatenated in any order π:
dβ writes debugging output toSTDERRlβ writes program activity log toSTDERR
π COMMENTS π
ngl, we gotta be real here: this module provides no error checking of files or objects β either against the dictionary, or otherwise. While the module is applicable to parsing either a file or a dictionary, dictionary information is not currently used in the parsing of files. So, for example, information about parent-child relationships between items is not present in a DataBlock object π
Functionality related to these issues is being provided in additional modules such as STAR::Checker, and STAR::Filter. so like, it's not abandoned, it's just living in another module's house π β¨
πΈ AUTHOR πΈ
Wolfgang Bluhm, mail@wbluhm.com β legend behaviour, we stan π«Ά
π Acknowledgments π
Thanks to Phil Bourne, Helge Weissig, Anne Kuller, Doug Greer, Michele Bluhm, and others for support, help, and comments. the group chat came THROUGH π
π COPYRIGHT π
A full copyright statement is provided with the distribution.
Copyright (c) 2000 University of California, San Diego.
β SEE ALSO β
STAR::DataBlock, STAR::Dictionary. go read them next, bestie, they're the sequel πβ¨
and that's the whole page, no notes π
this lil doc was brought to you by perl v5.18.1 and dated 2004-04-08 β vintage diva behaviour, ate and left no crumbs πππ
π¦ where this page comes from
- debian bookworm: libstar-parser-perl 0.59-4
- debian trixie: libstar-parser-perl 0.59-4
- ubuntu jammy: libstar-parser-perl 0.59-4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms