package PDBResidue;

use lib qw(./Core ./ );
use PDBAtom;
use String;

sub new {
    my ($class) = @_;
    my $self = {
	_name => '',
	_res_no => '',
	_atoms => undef,
	_atoms_hash => undef
    };

    bless $self, $class;
    return $self;
}

sub parseLines {
    my ($self, $lines) = @_;
    my @line_s = split(/\n/, $lines);
    my @atoms ;
    my %atoms_hash = ();
    foreach my $line (@line_s){
	my $atom = new PDBAtom();
	$atom->parseLine($line);
	push @atoms, $atom;
	$atoms_hash{$atom->{_name}} = $atom;
	$self->{_name} = trim(substr($line, 17, 3));
	$self->{_res_no} = trim(substr($line, 22, 4));
    }
    if (scalar(@atoms) > 0){
      $self->{_atoms} = \@atoms;
      $self->{_atoms_hash} = \%atoms_hash;
    }
    return ;
}

1;
