name, ll = l.split()
        ll.strip()
        moving_mol = Read(name)[0]
        indices = list(map(int, ll.split(',')))
        moving_ats = AtomSet()
        for i in indices:
            new_atoms = moving_mol.allAtoms.get(lambda x: x.number == i)
            if not len(new_atoms):
                print("There is no atom in %s with number %d" % (name, i))
                break
            else:
                moving_ats.append(new_atoms[0])
            #moving_ats.append(moving_mol.allAtoms.get(lambda x: x.number==i)[0])
        num_moving_ats = len(moving_ats)
        if num_moving_ats != num_ref_ats:
            print(
                "Number of moving_ats (%d) does not match number of reference atoms (%d). Skipping %s"
                % (num_moving_ats, num_ref_ats, name))
            continue
        #for i in indices: moving_ats.append(moving_mol.allAtoms[i-1])
        RFA.rigidFit(moving_ats.coords)
        newCoords = RFA.transformCoords(moving_mol.allAtoms.coords)
        if not newCoords is None and newCoords.shape[1] != 3:
            newCoords = newCoords[:, :3]
        outputfilename = prefix + name
        moving_mol.parser.write_with_new_coords(newCoords, outputfilename)
        if verbose: print('wrote %s' % outputfilename)

# To execute this command type:
# superpose_molecules.py  -d data_filename [-p prefix] -v
        )
    mobAtoms = get_atoms(mobMol, moblist, names_to_use, verbose)
    mobCoords = mobAtoms.coords
    if len(mobCoords) == 0:
        print("NO MOB COORDS!!!")
        raise Exception(
            'Unable to superimpose because no mobile coordinates were specified!!!'
        )
    #check that moblist and reflist are of the same length
    assert len(refCoords) == len(mobCoords)

    rigidfitAligner.setRefCoords(refCoords)
    rigidfitAligner.rigidFit(mobCoords)
    #now rigidfitAligner has attributes 'rotationMatrix' and 'translationMatrix'

    newCoords = rigidfitAligner.transformCoords(mobMol.allAtoms.coords)
    #make sure the coordinates have the correct shape, ie (num_atoms, 3)
    if not newCoords is None and newCoords.shape[1] != 3:
        newCoords = newCoords[:, :3]
    #newCoords is 2D Numeric array with dimensions  num_atoms, and length of each coordinate
    #if verbose: print "newCoords[0]=", newCoords[0]
    # end by writing a file with the transformed coordinates:
    #the parser of the moving molecule knows about all the input lines
    # so use it to write a file with the new coords:
    if outputfilename is None:
        EXT = os.path.splitext(refMol.parser.filename)[1]
        outputfilename = refMol.name + "_superimposed" + EXT
    mobMol.parser.write_with_new_coords(newCoords, outputfilename)
    if verbose: print("wrote ", outputfilename)

# To execute this command type:
            rat3.bonds.remove(b)
            if verbose: print "removed %s-%s bond from %s and from %s"%(b.atom1.name, b.atom2.name, otherAt.full_name(), rat3.full_name())
    if bond_to_break is None:
        print "unable to locate the bond to break in receptor residue %s: expected a bond from %s to an atom other than %s"%(resP.full_name(), rat3.name, rat2.name)
        raise 'invalid input'

    #setup for the superposition
    ref_coords = ref_atoms.coords 
    lig_coords = lig_atoms.coords
    #(1) create the tool
    rigidfitAligner = RigidfitBodyAligner()
    rigidfitAligner.setRefCoords(ref_coords)
    rigidfitAligner.rigidFit(lig_coords)
    #(2) get new coordinates for the moving atoms
    #    here all the ligand atoms move
    new_coords = rigidfitAligner.transformCoords(lM.allAtoms.coords)
    # get the correct shape for the coords (natoms,3)
    #new_coords.shape
    #(25, 4)
    new_coords=new_coords[:,:3] 
    #(3) add the new to ligand
    lM.allAtoms.addConformation(new_coords)
    confNum = len(lM.allAtoms[0]._coords)-1
    #(4) set the coordinates to use to the new ones 
    lM.allAtoms.setConformation(confNum)
    if verbose: print "new coordinates added to ligand"

    #add the ligand atoms other than at1 + at2 to the residue
    #(1) get the atoms to add
    atoms_to_adopt = lM.allAtoms[:]
    #atoms_to_adopt = lM.allAtoms.get(lambda x: not x in lig_atoms)
        indices = map(int, ll.split(','))
        moving_ats = AtomSet()
        for i in indices: 
            new_atoms = moving_mol.allAtoms.get(lambda x: x.number==i)
            if not len(new_atoms):
                print "There is no atom in %s with number %d" %(name, i)
                break
            else:
                moving_ats.append(new_atoms[0])
            #moving_ats.append(moving_mol.allAtoms.get(lambda x: x.number==i)[0])
        num_moving_ats = len(moving_ats)
        if num_moving_ats!=num_ref_ats:
            print "Number of moving_ats (%d) does not match number of reference atoms (%d). Skipping %s" %(num_moving_ats,num_ref_ats,name)
            continue
        #for i in indices: moving_ats.append(moving_mol.allAtoms[i-1])
        RFA.rigidFit(moving_ats.coords)
        newCoords = RFA.transformCoords(moving_mol.allAtoms.coords)
        if not newCoords is None and newCoords.shape[1]!=3:
            newCoords=newCoords[:,:3]
        outputfilename = prefix + name
        moving_mol.parser.write_with_new_coords(newCoords,outputfilename) 
        if verbose: print 'wrote %s' %outputfilename


# To execute this command type:
# superpose_molecules.py  -d data_filename [-p prefix] -v




    if len(refCoords)==0:
        print "NO REF COORDS!!!"
        raise 'Unable to superimpose because no reference coordinates were specified!!!' 
    mobAtoms = get_atoms(mobMol, moblist, names_to_use, verbose)
    mobCoords = mobAtoms.coords
    if len(mobCoords)==0:
        print "NO MOB COORDS!!!"
        raise 'Unable to superimpose because no mobile coordinates were specified!!!' 
    #check that moblist and reflist are of the same length    
    assert len(refCoords)==len(mobCoords)

    rigidfitAligner.setRefCoords(refCoords)  
    rigidfitAligner.rigidFit(mobCoords)
    #now rigidfitAligner has attributes 'rotationMatrix' and 'translationMatrix'

    newCoords = rigidfitAligner.transformCoords(mobMol.allAtoms.coords)
    #make sure the coordinates have the correct shape, ie (num_atoms, 3)
    if not newCoords is None and newCoords.shape[1]!=3:
        newCoords=newCoords[:,:3]   
    #newCoords is 2D Numeric array with dimensions  num_atoms, and length of each coordinate
    #if verbose: print "newCoords[0]=", newCoords[0]
    # end by writing a file with the transformed coordinates:
    #the parser of the moving molecule knows about all the input lines
    # so use it to write a file with the new coords:
    if outputfilename is None:
        EXT = os.path.splitext(refMol.parser.filename)[1]
        outputfilename = refMol.name + "_superimposed"+ EXT
    mobMol.parser.write_with_new_coords(newCoords, outputfilename)
    if verbose: print "wrote ", outputfilename

# To execute this command type:
                    rat3.full_name())
    if bond_to_break is None:
        print "unable to locate the bond to break in receptor residue %s: expected a bond from %s to an atom other than %s" % (
            resP.full_name(), rat3.name, rat2.name)
        raise 'invalid input'

    #setup for the superposition
    ref_coords = ref_atoms.coords
    lig_coords = lig_atoms.coords
    #(1) create the tool
    rigidfitAligner = RigidfitBodyAligner()
    rigidfitAligner.setRefCoords(ref_coords)
    rigidfitAligner.rigidFit(lig_coords)
    #(2) get new coordinates for the moving atoms
    #    here all the ligand atoms move
    new_coords = rigidfitAligner.transformCoords(lM.allAtoms.coords)
    # get the correct shape for the coords (natoms,3)
    #new_coords.shape
    #(25, 4)
    new_coords = new_coords[:, :3]
    #(3) add the new to ligand
    lM.allAtoms.addConformation(new_coords)
    confNum = len(lM.allAtoms[0]._coords) - 1
    #(4) set the coordinates to use to the new ones
    lM.allAtoms.setConformation(confNum)
    if verbose: print "new coordinates added to ligand"

    #add the ligand atoms other than at1 + at2 to the residue
    #(1) get the atoms to add
    atoms_to_adopt = lM.allAtoms[:]
    #atoms_to_adopt = lM.allAtoms.get(lambda x: not x in lig_atoms)