#!/usr/bin/env python

import sys
from Bio.PDB import *

#get the PDB's path from user command line
struct_path1 = sys.argv[1]
name_struct1 = struct_path1.split('/')[-1].split('.')[0]

struct_path2 = sys.argv[2]
name_struct2 = struct_path2.split('/')[-1].split('.')[0]

#parsing the PDBs
parser = PDBParser()

struct1 = parser.get_structure(name_struct1, struct_path1)
struct2 = parser.get_structure(name_struct2, struct_path2)

#get atoms list
atoms1 = struct1.get_atoms()
atoms2 = struct2.get_atoms()

latoms1 = []
latoms2 = []

for a in atoms1:
    latoms1.append( a )
for a in atoms2:
    latoms2.append( a )

print latoms1
print latoms2

#SuperImpose
sup = Superimposer()
# Specify the atom lists
# ""fixed"" and ""moving"" are lists of Atom objects
# The moving atoms will be put on the fixed atoms
sup.set_atoms(latoms1, latoms2)
# Print rotation/translation/rmsd
print "ROTRAN: "+ sup.rotran
print "RMS: " + sup.rms
# Apply rotation/translation to the moving atoms
sup.apply(moving)

