Chem-Structure-Parser
view release on metacpan or search on metacpan
t/data/generate.pl view on Meta::CPAN
'EXPDTA X-RAY DIFFRACTION ',
'NUMMDL 1 ',
'AUTHOR D.E.CONDON,A.N.OTHER ',
'REVDAT 2 01-FEB-20 9XYZ 1 COMPND SOURCE KEYWDS JRNL REMARK SEQRES ',
'REVDAT 2 2 1 HELIX SHEET ',
'REVDAT 1 01-JAN-20 9XYZ 0 ',
'JRNL AUTH D.E.CONDON,A.N.OTHER ',
'JRNL TITL A STRUCTURE MADE UP FOR A TEST SUITE, AND WHAT IT ',
'JRNL TITL 2 CONTAINS ',
'JRNL REF J.INVENTED.RES. V. 10 42 2020 ',
'JRNL PMID 12345678 ',
'JRNL DOI 10.1000/INVENTED.2020.42 ',
'REMARK 2 ',
'REMARK 2 RESOLUTION. 1.85 ANGSTROMS. ',
'REMARK 3 ',
'REMARK 3 R VALUE (WORKING SET) : 0.174 ',
'REMARK 3 FREE R VALUE : 0.219 ',
'REMARK 3 BIN FREE R VALUE : 0.999 ',
'REMARK 200 TEMPERATURE (KELVIN) : 100.0 ',
'REMARK 200 PH : 7.5 ',
'REMARK 465 MISSING RESIDUES ',
);
# The fixed-field annotation records, placed by the column numbers in the PDB
# format specification (v3.3). Written this way so that a record can be
# checked against the spec by reading the numbers, not by counting spaces --
# which is how the LINK record in an earlier draft of this file ended up two
# columns to the left and silently parsed its chain ids as blanks.
push @mini,
# DBREF: idCode 8-11, chain 13, seqBegin 15-18, seqEnd 21-24,
# database 27-32, dbAccession 34-41, dbIdCode 43-54,
# dbseqBegin 56-60, dbseqEnd 63-67
cols(1,6,'DBREF', 8,4,'9XYZ', 13,1,'A', 15,4,1,'R', 21,4,11,'R',
27,6,'UNP', 34,8,'P12345', 43,12,'TEST_HUMAN', 56,5,1,'R', 63,5,11,'R'),
# DBREF1: idCode 8-11, chain 13, seqBegin 15-18, seqEnd 21-24,
# database 27-32, dbIdCode 48-67
# DBREF2: idCode 8-11, chain 13, dbAccession 19-40,
# dbseqBegin 46-55, dbseqEnd 58-67
# the pair a reference too long for DBREF's columns is written as
cols(1,6,'DBREF1', 8,4,'9XYZ', 13,1,'B', 15,4,1,'R', 21,4,4,'R',
27,6,'GB', 48,20,'TEST_SEQUENCE_LONG'),
cols(1,6,'DBREF2', 8,4,'9XYZ', 13,1,'B', 19,22,'AB0123456789',
46,10,101,'R', 58,10,104,'R'),
# SEQADV: resName 13-15, chain 17, seqNum 19-22, database 25-28,
# dbAccession 30-38, dbRes 40-42, dbSeq 44-48, conflict 50-70
cols(1,6,'SEQADV', 8,4,'9XYZ', 13,3,'MSE', 17,1,'A', 19,4,7,'R',
25,4,'UNP', 30,9,'P12345', 40,3,'MET', 44,5,7,'R', 50,21,'MODIFIED RESIDUE'),
# SEQRES: serNum 8-10, chain 12, numRes 14-17, residues from 20 in 4s
cols(1,6,'SEQRES', 8,3,1,'R', 12,1,'A', 14,4,11,'R',
20,51,join('', map { sprintf('%3s ', $_) } qw(MET ALA GLY LEU LYS CYS MSE HIS HIS SER CYS))),
cols(1,6,'SEQRES', 8,3,1,'R', 12,1,'B', 14,4,4,'R',
20,51,join('', map { sprintf('%3s ', $_) } qw(DA DC DG DT))),
# MODRES: idCode 8-11, resName 13-15, chain 17, seqNum 19-22,
# stdRes 25-27, comment 30-70
cols(1,6,'MODRES', 8,4,'9XYZ', 13,3,'MSE', 17,1,'A', 19,4,7,'R',
25,3,'MET', 30,41,'SELENOMETHIONINE'),
# HET: hetID 8-10, chain 13, seqNum 14-17, iCode 18, numHetAtoms 21-25
cols(1,6,'HET', 8,3,'NAG','R', 13,1,'A', 14,4,201,'R', 21,5,14,'R'),
cols(1,6,'HET', 8,3,'ZN', 'R', 13,1,'A', 14,4,202,'R', 21,5,1, 'R'),
# HETNAM: continuation 9-10, hetID 12-14, text 16-70
cols(1,6,'HETNAM', 12,3,'NAG','R', 16,55,'2-ACETAMIDO-2-DEOXY-BETA-D-GLUCOPYRANOSE'),
cols(1,6,'HETNAM', 12,3,'ZN', 'R', 16,55,'ZINC ION'),
# FORMUL: compNum 9-10, hetID 13-15, continuation 17-18, asterisk 19, text 20-70
cols(1,6,'FORMUL', 9,2,3,'R', 13,3,'NAG','R', 20,51,'C8 H15 N O6'),
cols(1,6,'FORMUL', 9,2,4,'R', 13,3,'ZN', 'R', 20,51,'ZN 2+'),
cols(1,6,'FORMUL', 9,2,5,'R', 13,3,'HOH','R', 19,1,'*', 20,51,'2(H2 O)'),
# HELIX: serNum 8-10, helixID 12-14, initResName 16-18, initChain 20,
# initSeqNum 22-25, endResName 28-30, endChain 32, endSeqNum 34-37,
# helixClass 39-40, length 72-76
cols(1,6,'HELIX', 8,3,1,'R', 12,3,'AA1', 16,3,'MET', 20,1,'A', 22,4,1,'R',
28,3,'GLY', 32,1,'A', 34,4,3,'R', 39,2,1,'R', 72,5,3,'R'),
# SHEET: strand 8-10, sheetID 12-14, numStrands 15-16, initResName 18-20,
# initChain 22, initSeqNum 23-26, endResName 29-31, endChain 33,
# endSeqNum 34-37, sense 39-40
cols(1,6,'SHEET', 8,3,1,'R', 12,3,'AA1', 15,2,2,'R', 18,3,'CYS', 22,1,'A',
23,4,6,'R', 29,3,'HIS', 33,1,'A', 34,4,8,'R', 39,2,0,'R'),
# the second strand, antiparallel to the first
cols(1,6,'SHEET', 8,3,2,'R', 12,3,'AA1', 15,2,2,'R', 18,3,'SER', 22,1,'A',
23,4,9,'R', 29,3,'CYS', 33,1,'A', 34,4,10,'R', 39,2,-1,'R'),
# SSBOND: serNum 8-10, CYS 12-14, chain1 16, seqNum1 18-21,
# CYS 26-28, chain2 30, seqNum2 32-35, sym1 60-65, sym2 67-72, length 74-78
cols(1,6,'SSBOND', 8,3,1,'R', 12,3,'CYS', 16,1,'A', 18,4,6,'R',
26,3,'CYS', 30,1,'A', 32,4,10,'R', 60,6,'1555', 67,6,'1555', 74,5,'2.03','R'),
# LINK: name1 13-16, resName1 18-20, chain1 22, resSeq1 23-26,
# name2 43-46, resName2 48-50, chain2 52, resSeq2 53-56, length 74-78
cols(1,6,'LINK', 13,4,'ZN', 18,3,'ZN','R', 22,1,'A', 23,4,202,'R',
43,4,' SG', 48,3,'CYS', 52,1,'A', 53,4,6,'R', 74,5,'2.31','R'),
# CISPEP: serNum 8-10, pep1 12-14, chain1 16, seqNum1 18-21,
# pep2 26-28, chain2 30, seqNum2 32-35, modNum 44-46, measure 54-59
cols(1,6,'CISPEP', 8,3,1,'R', 12,3,'GLY', 16,1,'A', 18,4,3,'R',
26,3,'CYS', 30,1,'A', 32,4,6,'R', 44,3,0,'R', 54,6,'-0.42','R'),
# CRYST1: a 7-15, b 16-24, c 25-33, alpha 34-40, beta 41-47, gamma 48-54,
# sGroup 56-66, z 67-70
cols(1,6,'CRYST1', 7,9,'40.100','R', 16,9,'50.200','R', 25,9,'60.300','R',
34,7,'90.00','R', 41,7,'95.50','R', 48,7,'90.00','R',
56,11,'P 1 21 1', 67,4,4,'R');
push @mini, atom('ATOM ', 'A', 'MET', 1, '', [ bb([ 'CB', 'C' ]) ], [ 10, 10, 10 ]);
# an alternate conformer: two CB records, altlocs A and B, unequal occupancy
push @mini, atom('ATOM ', 'A', 'ALA', 2, '', [ bb() ], [ 13, 11, 11 ]);
push @mini, atom_line(record => 'ATOM ', serial => ++$serial, name => 'CB', element => 'C',
altloc => 'A', resname => 'ALA', chain => 'A', resseq => 2, icode => '',
x => 19.0, y => 15.0, z => 13.0, occ => 0.40, b => 22);
push @mini, atom_line(record => 'ATOM ', serial => ++$serial, name => 'CB', element => 'C',
altloc => 'B', resname => 'ALA', chain => 'A', resseq => 2, icode => '',
x => 19.5, y => 15.5, z => 13.5, occ => 0.60, b => 25);
push @mini, atom('ATOM ', 'A', 'GLY', 3, '', [ bb() ], [ 16, 12, 12 ]);
# residues 4 and 5 are in SEQRES but were never modelled: a gap
push @mini, atom('ATOM ', 'A', 'CYS', 6, '', [ bb([ 'SG', 'S' ]) ], [ 19, 13, 13 ]);
# a modified residue, written as HETATM, that is still an M in the sequence
push @mini, atom('HETATM', 'A', 'MSE', 7, '', [ bb([ 'CB', 'C' ], [ 'SE', 'SE' ]) ], [ 22, 14, 14 ]);
push @mini, atom('ATOM ', 'A', 'HIS', 8, '', [ bb([ 'CB', 'C' ]) ], [ 25, 15, 15 ]);
push @mini, atom('ATOM ', 'A', 'HIS', 8, 'A', [ bb([ 'CB', 'C' ]) ], [ 28, 16, 16 ]);
# a hydrogen, so that hydrogens => 0 has something to remove
push @mini, atom('ATOM ', 'A', 'SER', 9, '', [ bb([ 'CB', 'C' ], [ 'HB2', 'H' ]) ], [ 31, 17, 17 ]);
push @mini, atom('ATOM ', 'A', 'CYS', 10, '', [ bb([ 'SG', 'S' ]) ], [ 34, 18, 18 ]);
push @mini, sprintf('%-6s%5d %3s %1s%4d%1s', 'TER', ++$serial, 'CYS', 'A', 10, '');
push @mini, atom('HETATM', 'A', 'NAG', 201, '', [ [ 'C1', 'C' ], [ 'C2', 'C' ], [ 'O5', 'O' ], [ 'N2', 'N' ] ], [ 40, 20, 20 ]);
push @mini, atom('HETATM', 'A', 'ZN', 202, '', [ [ 'ZN', 'ZN' ] ], [ 45, 22, 22 ]);
push @mini, atom('HETATM', 'A', 'HOH', 301, '', [ [ 'O', 'O' ] ], [ 50, 24, 24 ]);
push @mini, atom('HETATM', 'A', 'HOH', 302, '', [ [ 'O', 'O' ] ], [ 52, 25, 25 ]);
t/data/generate.pl view on Meta::CPAN
# a category with one row, written as plain tags
sub cif_pairs {
my ($cat, @kv) = @_;
my @out;
while (@kv) {
my ($k, $v) = splice @kv, 0, 2;
push @out, sprintf('%-52s %s', "_$cat.$k", cifq($v));
}
return @out;
}
# a category with several rows, written as a loop_
sub cif_loop {
my ($cat, $items, @rows) = @_;
my @out = ('loop_', map { "_$cat.$_" } @$items);
push @out, join ' ', map { cifq($_) } @$_ for @rows;
return @out;
}
my @minicif = ('data_9XYZ', '#');
push @minicif,
cif_pairs('entry', id => '9XYZ'), '#',
# a semicolon text field, which is the only way the format has of writing
# a value too long for a line -- and the only token that spans lines
'_struct.entry_id 9XYZ',
'_struct.title',
';A SMALL TEST STRUCTURE WITH A GAP, AN INSERTION CODE, AN ALTERNATE CONFORMER AND A LIGAND',
';', '#',
cif_pairs('struct_keywords',
entry_id => '9XYZ',
pdbx_keywords => 'HYDROLASE/PEPTIDE INHIBITOR',
text => 'HYDROLASE, TEST STRUCTURE, COMPLEX (HYDROLASE-PEPTIDE)'), '#',
cif_pairs('pdbx_database_status', entry_id => '9XYZ',
recvd_initial_deposition_date => '2020-01-01'), '#',
cif_pairs('exptl', entry_id => '9XYZ', method => 'X-RAY DIFFRACTION'), '#',
cif_pairs('refine',
entry_id => '9XYZ',
'ls_d_res_high' => '1.85',
'ls_R_factor_R_work'=> '0.174',
'ls_R_factor_R_free'=> '0.219'), '#',
cif_pairs('diffrn', id => 1, ambient_temp => '100.0'), '#',
cif_pairs('exptl_crystal_grow', crystal_id => 1, pH => '7.5'), '#',
cif_loop('audit_author', [qw(name pdbx_ordinal)],
[ 'Condon, D.E.', 1 ], [ 'Other, A.N.', 2 ]), '#',
cif_loop('citation',
[qw(id title journal_abbrev journal_volume page_first year
pdbx_database_id_PubMed pdbx_database_id_DOI)],
[ 'primary', 'A STRUCTURE MADE UP FOR A TEST SUITE, AND WHAT IT CONTAINS',
'J.Invented.Res.', 10, 42, 2020, 12345678, '10.1000/INVENTED.2020.42' ]), '#',
cif_loop('citation_author', [qw(citation_id name ordinal)],
[ 'primary', 'Condon, D.E.', 1 ], [ 'primary', 'Other, A.N.', 2 ]), '#',
cif_pairs('cell', entry_id => '9XYZ',
length_a => '40.100', length_b => '50.200', length_c => '60.300',
angle_alpha => '90.00', angle_beta => '95.50', angle_gamma => '90.00',
'Z_PDB' => 4), '#',
cif_pairs('symmetry', entry_id => '9XYZ', 'space_group_name_H-M' => 'P 1 21 1'), '#',
cif_loop('entity', [qw(id type src_method pdbx_description pdbx_ec pdbx_fragment)],
[ 1, 'polymer', 'man', 'TEST PROTEIN', '3.4.21.5', 'CATALYTIC DOMAIN' ],
[ 2, 'polymer', 'syn', 'TEST DNA', undef, undef ],
[ 3, 'non-polymer', 'syn', '2-ACETAMIDO-2-DEOXY-BETA-D-GLUCOPYRANOSE', undef, undef ],
[ 4, 'non-polymer', 'syn', 'ZINC ION', undef, undef ],
[ 5, 'water', 'nat', 'water', undef, undef ]), '#',
cif_loop('entity_poly', [qw(entity_id type pdbx_seq_one_letter_code_can pdbx_strand_id)],
[ 1, 'polypeptide(L)', 'MAGLKCMHHSC', 'A' ],
[ 2, 'polydeoxyribonucleotide', 'ACGT', 'B' ]), '#',
cif_loop('entity_poly_seq', [qw(entity_id num mon_id hetero)],
(map { [ 1, $_->[0], $_->[1], 'n' ] }
map { [ $_ + 1, (qw(MET ALA GLY LEU LYS CYS MSE HIS HIS SER CYS))[$_] ] } 0 .. 10),
(map { [ 2, $_->[0], $_->[1], 'n' ] }
map { [ $_ + 1, (qw(DA DC DG DT))[$_] ] } 0 .. 3)), '#',
cif_pairs('entity_src_gen',
entity_id => 1,
pdbx_gene_src_scientific_name => 'HOMO SAPIENS',
pdbx_gene_src_ncbi_taxonomy_id => 9606,
pdbx_host_org_scientific_name => 'ESCHERICHIA COLI'), '#',
cif_pairs('pdbx_entity_src_syn',
entity_id => 2,
organism_scientific => 'SYNTHETIC CONSTRUCT',
ncbi_taxonomy_id => 32630), '#',
cif_loop('chem_comp', [qw(id name formula type)],
[ 'MSE', 'SELENOMETHIONINE', 'C5 H11 N O2 Se', 'L-peptide linking' ],
[ 'NAG', '2-ACETAMIDO-2-DEOXY-BETA-D-GLUCOPYRANOSE', 'C8 H15 N O6', 'D-saccharide' ],
[ 'ZN', 'ZINC ION', 'ZN 2+', 'non-polymer' ],
[ 'HOH', 'WATER', 'H2 O', 'water' ]), '#',
cif_loop('pdbx_nonpoly_scheme',
[qw(asym_id entity_id mon_id pdb_strand_id pdb_seq_num pdb_ins_code)],
[ 'C', 3, 'NAG', 'A', 201, '.' ],
[ 'D', 4, 'ZN', 'A', 202, '.' ],
[ 'E', 5, 'HOH', 'A', 301, '.' ],
[ 'E', 5, 'HOH', 'A', 302, '.' ]), '#',
cif_loop('pdbx_struct_mod_residue',
[qw(id label_comp_id auth_comp_id auth_asym_id auth_seq_id parent_comp_id details)],
[ 1, 'MSE', 'MSE', 'A', 7, 'MET', 'SELENOMETHIONINE' ]), '#',
# the row's own id is HELX_P1, as the archive writes it; the HELIX
# record's id is pdbx_PDB_helix_id
cif_loop('struct_conf',
[qw(conf_type_id id pdbx_PDB_helix_id beg_auth_comp_id beg_auth_asym_id
beg_auth_seq_id end_auth_comp_id end_auth_asym_id end_auth_seq_id
pdbx_PDB_helix_class pdbx_PDB_helix_length)],
[ 'HELX_P', 'HELX_P1', 'AA1', 'MET', 'A', 1, 'GLY', 'A', 3, 1, 3 ]), '#',
cif_loop('struct_sheet', [qw(id type number_strands details)],
[ 'AA1', undef, 2, undef ]), '#',
cif_loop('struct_sheet_order', [qw(sheet_id range_id_1 range_id_2 offset sense)],
[ 'AA1', 1, 2, undef, 'anti-parallel' ]), '#',
cif_loop('struct_sheet_range',
[qw(sheet_id id beg_auth_comp_id beg_auth_asym_id beg_auth_seq_id
end_auth_comp_id end_auth_asym_id end_auth_seq_id)],
[ 'AA1', 1, 'CYS', 'A', 6, 'HIS', 'A', 8 ],
[ 'AA1', 2, 'SER', 'A', 9, 'CYS', 'A', 10 ]), '#',
cif_loop('struct_conn',
[qw(id conn_type_id ptnr1_label_atom_id ptnr1_auth_comp_id ptnr1_auth_asym_id
ptnr1_auth_seq_id ptnr2_label_atom_id ptnr2_auth_comp_id ptnr2_auth_asym_id
ptnr2_auth_seq_id pdbx_dist_value)],
[ 'disulf1', 'disulf', 'SG', 'CYS', 'A', 6, 'SG', 'CYS', 'A', 10, '2.03' ],
[ 'covale1', 'covale', 'ZN', 'ZN', 'A', 202, 'SG', 'CYS', 'A', 6, '2.31' ]), '#',
cif_loop('struct_mon_prot_cis',
[qw(pdbx_id auth_comp_id auth_asym_id auth_seq_id pdbx_auth_comp_id_2
pdbx_auth_asym_id_2 pdbx_auth_seq_id_2 pdbx_omega_angle)],
[ 1, 'GLY', 'A', 3, 'CYS', 'A', 6, '-0.42' ]), '#',
cif_loop('struct_ref', [qw(id db_name db_code pdbx_db_accession entity_id)],
[ 1, 'UNP', 'TEST_HUMAN', 'P12345', 1 ],
[ 2, 'GB', 'TEST_SEQUENCE_LONG', 'AB0123456789', 2 ]), '#',
cif_loop('struct_ref_seq',
[qw(align_id ref_id pdbx_strand_id pdbx_auth_seq_align_beg
pdbx_auth_seq_align_end pdbx_db_accession db_align_beg db_align_end)],
[ 1, 1, 'A', 1, 11, 'P12345', 1, 11 ],
[ 2, 2, 'B', 1, 4, 'AB0123456789', 101, 104 ]), '#';
push @minicif, atom_site_loop(\@mini), '#';
my @nmrcif = ('data_9NMR', '#');
push @nmrcif,
cif_pairs('entry', id => '9NMR'), '#',
'_struct.title "A THREE MODEL ENSEMBLE"', '#',
cif_pairs('exptl', entry_id => '9NMR', method => 'SOLUTION NMR'), '#',
cif_pairs('pdbx_nmr_ensemble', entry_id => '9NMR',
conformers_submitted_total_number => 3), '#',
cif_loop('entity', [qw(id type pdbx_description)], [ 1, 'polymer', 'TEST PEPTIDE' ]), '#',
cif_loop('entity_poly', [qw(entity_id pdbx_strand_id)], [ 1, 'A' ]), '#',
cif_loop('entity_poly_seq', [qw(entity_id num mon_id)],
[ 1, 1, 'GLY' ], [ 1, 2, 'SER' ], [ 1, 3, 'TRP' ]), '#';
push @nmrcif, atom_site_loop(\@nmr), '#';
( run in 1.128 second using v1.01-cache-2.11-cpan-1bcd28dbaf1 )