import numpy
import scipy
import matplotlib
import dadi

with open('file_name', 'r') as myfile:
    dadi_input=myfile.read().replace('\n', '')

dd = dadi.Misc.make_data_dict(dadi_input)

with open(dadi_input, 'r') as myfile:
    headerline=myfile.readline().replace('\n', '').split('\t')

headerline.remove('ingroup')
headerline.remove('outgroup')
headerline.remove('Allele1')
headerline.remove('Allele2')

no_of_pops = (len(headerline)-2)/2
pop_name = headerline[0:no_of_pops]

final_fs = 0
final_spectrum = 0




fs = dadi.Spectrum.from_data_dict(dd , pop_ids =pop_name ,projections =[6 , 22, 2, 2,3] ,polarized = False)
if fs.S() > final_fs:
    final_fs=fs.S()
    final_spectrum = fs


final_spectrum.to_file("spectrum_output.txt")

@@ -504,20 +504,198 @@
 rum = 0%0A
-%0A%0A%0A%0A
+pop_projections = 0%0A%0Awith open('fs_combos.txt', 'r') as myfile:%0A    for line in myfile:%0A        line=line.replace('%5Cn', '').split(' ')%0A        line = %5Bint(i) for i in line%5D%0A%0A        
 fs = dad
@@ -761,24 +761,12 @@
 ns =
-%5B6 , 22, 2, 2,3%5D
+line
  ,po
@@ -782,16 +782,24 @@
  False)%0A
+        
 if fs.S(
@@ -812,16 +812,24 @@
 nal_fs:%0A
+        
     fina
@@ -840,16 +840,24 @@
 =fs.S()%0A
+        
     fina
@@ -872,16 +872,48 @@
 um = fs%0A
+            pop_projections=line
 %0A%0Afinal_
@@ -952,8 +952,197 @@
 t.txt%22)%0A
+print 'The optimum fs.S. is'%0Aprint final_fs%0Aprint 'The projection for this optimum is'%0Aprint pop_name%0Aprint pop_projections%0Aprint 'The spectrum for this is saved as %22spectrum_output.txt%22'%0A%0A

Update fs_downproject.py