concat.pdb <- function (a, b)
  {

    num.atoms.a <- length(a$atom[,"eleno"])
    num.res.a <- length(unique( a$atom[,"resno"]))
	##as.numeric( a$atom[nrow(a$atom),"resno"] )

    num.atoms.b <- length(b$atom[,"eleno"])
    num.res.b <- length(unique( b$atom[,"resno"]))

    ##num.atoms.b <- as.numeric( b$atom[nrow(b$atom),"eleno"] )
    ##num.res.b <- as.numeric( b$atom[nrow(b$atom),"resno"] )

    ##end.atoms.b <- num.atoms.a + num.atoms.b
    new.eleno.b <- seq(num.atoms.a+1, num.atoms.a+num.atoms.b, 1)



    tmpres <- as.numeric( b$atom[,"resno"] ) - as.numeric(b$atom[1,"resno"]) + 1
    new.resno.b <- tmpres + num.res.a

    b$atom[,"eleno"] = new.eleno.b
    b$atom[,"resno"] = new.resno.b
    
    new <- NULL
    new$atom = rbind(a$atom, b$atom)
    new$xyz = c(a$xyz, b$xyz)

    out <- list(newpdb = new, a=a, b=b)
    
    return(out)

  }
