From: Ash Johnson (ash__johnson_at_outlook.com)
Date: Thu Aug 13 2015 - 04:29:19 CDT

Works like a charm(m)! The reason I needed different segment names is that I would get an error when trying to merge them. The only problem I have now is that my current method involves parsing through the segnames of all 200k+ atoms in my system, but as far as I can tell this is necessary one way or another, since every atom's segname must be obtained and rewritten anyway. For anyone interested, here is the code to rename the segments before merging: ### Rename the segments in the membrane so that when it is merged, they will not conflict set segnames [[atomselect top all] get segname] set previous { } set uniquenames { } # Loop through every atom's segment name, and add it to the list if it is unique foreach i $segnames { if {$i != $previous} { lappend uniquenames $i } set previous $i } puts "List of unique segment names created" # Append the prefix 0 to every segment in the membrane foreach segname $uniquenames { set sel [atomselect top "segname $segname"] $sel set segname 0$segname } puts "Segment name prefixes added" Thanks again for the help! > Date: Tue, 11 Aug 2015 09:48:47 -0500 > From: vermaas2_at_illinois.edu > To: ash__johnson_at_outlook.com; vmd-l_at_ks.uiuc.edu > Subject: Re: vmd-l: Merging two structures with duplicate segment names using TCL/Tk Console > > Hi Ash, > > Is there a particular reason they need to have different segment names? > There are multiple ways of solving this problem. One is just to rename > the segments using atomselections, so something like: > > mol load file2.psf file2.pdb > set sel [atomselect top "segname X"] > $sel set segname Y > set all [atomselect top "all"] > $all writepsf newfile2.psf > > The other is to use topotools to do the merging if you don't care about > the result having distinct segnames. See > http://www.ks.uiuc.edu/Research/vmd/plugins/topotools/. You'll want > mergemols at the very bottom, which gives an example of how to use it. > > -Josh Vermaas > > On 08/10/2015 07:29 PM, Ash Johnson wrote: >> Hello, >> >> I am writing a TCL script that involves merging two structures. When there are no conflicting segment names, I can use >> >> ::MergeStructs::mergeMolecules {file1.psf file1.pdb} {file2.psf file2.pdb} output >> >> to merge them. However, I would like to merge two nearly-identical sections of membrane (generated with the membrane builder) that are translated away from each other. When using the GUI for MergeStructs, it recognizes the conflict and allows me to add a prefix for the segments, but currently those functions are not called in mergeMolecules. What is the best way to go about implementing this in my script? >> >> Thanks, >> Ash >> >