Skip to content

Instantly share code, notes, and snippets.

@MelanieS
Created September 11, 2015 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MelanieS/74b578ac2d2a0dd50372 to your computer and use it in GitHub Desktop.
Save MelanieS/74b578ac2d2a0dd50372 to your computer and use it in GitHub Desktop.
permute_tri.rb
a = [60, -60]
# 4 refers to number of 60s or -60s in each element of array
a = a.repeated_permutation(6).to_a
puts "The array contains #{a.length} elements."
#creates output file called permute.txt
out_file = File.new("permute_out.txt", "w")
while a.length != 0
#Removes last element from array and saves it in new array
individual_struc = a.pop
#Change this line to match your sequence
line1 = "var = sequence {ACE PHE ALA PHE NHE}"
#puts "Currently building structure: #{individual_struc.to_s}."
phi3 = individual_struc.pop
#puts "phi3 = #{phi3}"
psi3 = individual_struc.pop
#puts "psi3 = #{psi3}"
phi2 = individual_struc.pop
#puts "phi2 = #{phi2}"
psi2 = individual_struc.pop
#puts "psi2 = #{psi2}"
phi1 = individual_struc.pop
#puts "phi1 = #{phi1}"
psi1 = individual_struc.pop
#puts "psi1 = #{psi1}"
psi1 = psi1.to_s
psi2 = psi2.to_s
psi3 = psi3.to_s
phi1 = phi1.to_s
phi2 = phi2.to_s
phi3 = phi3.to_s
line2 = 'impose var {2} {{"N" "CA" "C" "N" ' + psi1 + '}}'
line3 = 'impose var {1} {{"C" "N" "CA" "C" ' + phi1 + '}}'
line4 = 'impose var {3} {{"N" "CA" "C" "N" ' + psi2 + '}}'
line5 = 'impose var {2} {{"C" "N" "CA" "C" ' + phi2 + '}}'
line6 = 'impose var {4} {{"N" "CA" "C" "N" ' + psi3 + '}}'
line7 = 'impose var {3} {{"C" "N" "CA" "C" ' + phi3 + '}}'
puts line1
file_slug = "#{psi1}_#{phi1}_#{psi2}_#{phi2}_#{psi3}_#{phi3}"
#puts file_slug
#change faf to your structure
line8 = "saveamberparm var faf_#{file_slug}.prmtop faf_#{file_slug}.inpcrd"
#puts "The array now contains #{a.length} elements."
out_file.puts(line1)
out_file.puts(line2)
out_file.puts(line3)
out_file.puts(line4)
out_file.puts(line5)
out_file.puts(line6)
out_file.puts(line7)
out_file.puts(line8)
out_file.puts("\n")
end
out_file.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment