Chem-Structure-Parser

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

    │   ├── pmid        '9571026'
    │   └── doi         '10.1006/JMBI.1998.1669'
    ├── compound                                COMPND, by MOL_ID
    │   ├── 1
    │   │   ├── mol_id      '1'
    │   │   ├── molecule    'GROWTH HORMONE'
    │   │   ├── chain       [ 'A' ]
    │   │   ├── engineered  'YES'
    │   │   └── mutation    'YES'
    │   └── 2           { molecule 'GROWTH HORMONE RECEPTOR', chain [ 'B' ],
    │                     fragment 'EXTRACELLULAR DOMAIN', engineered 'YES' }
    ├── source                                  SOURCE, by MOL_ID
    │   └── 1           { organism_scientific 'HOMO SAPIENS', organism_common
    │                     'HUMAN', organism_taxid '9606', mol_id '1',
    │                     expression_system 'ESCHERICHIA COLI',
    │                     expression_system_taxid '562' }
    ├── entity_of_chain                         COMPND and SOURCE, by chain
    │   ├── A           { mol_id '1', molecule 'GROWTH HORMONE', fragment undef,
    │   │                 ec undef, organism 'HOMO SAPIENS', taxid '9606',
    │   │                 expressed_in 'ESCHERICHIA COLI' }
    │   └── B           { ..., fragment 'EXTRACELLULAR DOMAIN' }
    ├── seqres                                  what SEQRES says was in the crystal
    │   ├── A
    │   │   ├── sequence    'FPTIPLSRLFDNAMLRAHRLHQLAFDTYQEFEEAYIPKEQKYSFLQ...'
    │   │   ├── residues    [ 'PHE', 'PRO', 'THR', 'ILE', ... ]        191 of them
    │   │   └── length      191
    │   └── B               { sequence, residues, length 238 }
    ├── dbref
    │   └── A           [ { database 'UNP', accession 'P01241',
    │                       db_id 'SOMA_HUMAN', seq_begin '1', seq_end '191',
    │                       db_begin '27', db_end '217', chain 'A' } ]

README.md  view on Meta::CPAN

        │   ├── missing_residues
        │   │                   [ 130, 131, 132, 133, 134, 135,
        │   │                     149, 150, 151, 152, 153 ]
        │   ├── first           1           the first and last polymer residue keys
        │   ├── last            191
        │   ├── residue_types   { amino_acid 180, water 26 }
        │   ├── molecule        'GROWTH HORMONE'            from COMPND
        │   ├── organism        'HOMO SAPIENS'              from SOURCE
        │   ├── mol_id          '1'
        │   ├── dbref           [ { ... } ]     as in the top-level dbref
        │   │                                   ec and fragment are here too, in a
        │   │                                   chain whose file gives them
        │   ├── residue_order   [ '1', '2', '3', ... '574' ]        file order, 206
        │   └── residues                    keyed number + insertion code
        │       ├── 54
        │       │   ├── resname     'PHE'
        │       │   ├── number      54
        │       │   ├── icode       ''
        │       │   ├── key         '54'
        │       │   ├── chain       'A'
        │       │   ├── one         'F'     '' when there is no letter for it

lib/Chem/Structure/Parser.pm  view on Meta::CPAN

		my $c = $info->{chains}{$cid};
		if (my $s = $info->{seqres}{$cid}) {
			$c->{seqres}        = $s->{sequence};
			$c->{seqres_length} = $s->{length};
			$c->{n_missing}     = $s->{length} - $c->{n_polymer} if defined $s->{length};
		}
		if (my $e = $info->{entity_of_chain}{$cid}) {
			$c->{mol_id}   = $e->{mol_id};
			$c->{molecule} = $e->{molecule} if defined $e->{molecule};
			$c->{organism} = $e->{organism} if defined $e->{organism};
			$c->{fragment} = $e->{fragment} if defined $e->{fragment};
			$c->{ec}       = $e->{ec}       if defined $e->{ec};
		}
		$c->{dbref} = $info->{dbref}{$cid} if $info->{dbref}{$cid};
	}
	return $info;
}

sub _id_from {
	my ($info, $file) = @_;
	return $info->{header}{id_code} if length($info->{header}{id_code} || '');

lib/Chem/Structure/Parser.pm  view on Meta::CPAN

sub _entities {
	my ($info) = @_;
	my %by_chain;
	for my $id (keys %{ $info->{compound} }) {
		my $c = $info->{compound}{$id};
		my $s = $info->{source}{$id} || {};
		for my $cid (@{ $c->{chain} || [] }) {
			$by_chain{$cid} = {
				mol_id   => $id,
				molecule => $c->{molecule},
				fragment => $c->{fragment},
				ec       => $c->{ec_number} || $c->{ec},
				organism => $s->{organism_scientific},
				taxid    => $s->{organism_taxid},
				expressed_in => $s->{expression_system},
			};
		}
	}
	$info->{entity_of_chain} = \%by_chain;
	return $info;
}

lib/Chem/Structure/Parser.pm  view on Meta::CPAN

 │   ├── pmid        '9571026'
 │   └── doi         '10.1006/JMBI.1998.1669'
 ├── compound                                COMPND, by MOL_ID
 │   ├── 1
 │   │   ├── mol_id      '1'
 │   │   ├── molecule    'GROWTH HORMONE'
 │   │   ├── chain       [ 'A' ]
 │   │   ├── engineered  'YES'
 │   │   └── mutation    'YES'
 │   └── 2           { molecule 'GROWTH HORMONE RECEPTOR', chain [ 'B' ],
 │                     fragment 'EXTRACELLULAR DOMAIN', engineered 'YES' }
 ├── source                                  SOURCE, by MOL_ID
 │   └── 1           { organism_scientific 'HOMO SAPIENS', organism_common
 │                     'HUMAN', organism_taxid '9606', mol_id '1',
 │                     expression_system 'ESCHERICHIA COLI',
 │                     expression_system_taxid '562' }
 ├── entity_of_chain                         COMPND and SOURCE, by chain
 │   ├── A           { mol_id '1', molecule 'GROWTH HORMONE', fragment undef,
 │   │                 ec undef, organism 'HOMO SAPIENS', taxid '9606',
 │   │                 expressed_in 'ESCHERICHIA COLI' }
 │   └── B           { ..., fragment 'EXTRACELLULAR DOMAIN' }
 ├── seqres                                  what SEQRES says was in the crystal
 │   ├── A
 │   │   ├── sequence    'FPTIPLSRLFDNAMLRAHRLHQLAFDTYQEFEEAYIPKEQKYSFLQ...'
 │   │   ├── residues    [ 'PHE', 'PRO', 'THR', 'ILE', ... ]        191 of them
 │   │   └── length      191
 │   └── B               { sequence, residues, length 238 }
 ├── dbref
 │   └── A           [ { database 'UNP', accession 'P01241',
 │                       db_id 'SOMA_HUMAN', seq_begin '1', seq_end '191',
 │                       db_begin '27', db_end '217', chain 'A' } ]

lib/Chem/Structure/Parser.pm  view on Meta::CPAN

     │   ├── missing_residues
     │   │                   [ 130, 131, 132, 133, 134, 135,
     │   │                     149, 150, 151, 152, 153 ]
     │   ├── first           1           the first and last polymer residue keys
     │   ├── last            191
     │   ├── residue_types   { amino_acid 180, water 26 }
     │   ├── molecule        'GROWTH HORMONE'            from COMPND
     │   ├── organism        'HOMO SAPIENS'              from SOURCE
     │   ├── mol_id          '1'
     │   ├── dbref           [ { ... } ]     as in the top-level dbref
     │   │                                   ec and fragment are here too, in a
     │   │                                   chain whose file gives them
     │   ├── residue_order   [ '1', '2', '3', ... '574' ]        file order, 206
     │   └── residues                    keyed number + insertion code
     │       ├── 54
     │       │   ├── resname     'PHE'
     │       │   ├── number      54
     │       │   ├── icode       ''
     │       │   ├── key         '54'
     │       │   ├── chain       'A'
     │       │   ├── one         'F'     '' when there is no letter for it

t/cif.t  view on Meta::CPAN

# chain, every residue, every atom, and the counts over them.
#
# What is taken back out is the handful of things _chain_stats() folds into a
# chain from the header, because those are the header's answer and not the
# coordinates', and the header section below tests them against each other one
# at a time.  A fixture pair cannot be equal on all of them anyway -- mini.cif
# names the entity every ligand belongs to and mini.pdb has no record that
# does -- and burying that in this comparison would only make it say
# 'structures differ' about something the header tests say properly.
my @FROM_HEADER = qw(seqres seqres_length n_missing mol_id molecule organism
                     fragment ec dbref);

sub coords {
	my ($i) = @_;
	my %s = %{ $i->{stats} };
	delete $s{n_lines};    # an mmCIF row and a PDB record are not the same line
	my $strip = sub {
		my ($set) = @_;
		return { map {
			my %c = %{ $set->{$_} };
			delete @c{@FROM_HEADER};

t/real_cif.t  view on Meta::CPAN

	my ($i) = @_;
	canon_charges($i);
	my %s = %{ $i->{stats} };
	delete $s{n_lines};    # an mmCIF row and a PDB record are not the same line
	my %c;
	for my $cid (keys %{ $i->{chains} }) {
		my %x = %{ $i->{chains}{$cid} };
		# what _chain_stats() folded in from the header, which the conversion
		# below does not carry across and which t/cif.t tests on its own
		delete @x{qw(seqres seqres_length n_missing mol_id molecule organism
		             fragment ec dbref)};
		$c{$cid} = \%x;
	}
	return { chains => \%c, chain_order => $i->{chain_order}, stats => \%s };
}

# --- consistency, for a structure with nothing to compare it against -------
sub adds_up {
	my ($info, $name) = @_;
	my $atoms = 0;
	$atoms += $info->{chains}{$_}{n_atoms} for @{ $info->{chain_order} };



( run in 1.767 second using v1.01-cache-2.11-cpan-364913b4093 )