proc phipsi {start end filename {output phipsi_data.txt}} {
	set outFile [open $output w]
	for {set s $start} {$s <= $end} {incr s} {
		set myMolid [mol new .step3_pbcsetup.psf waitfor all]
		mol addfile $filename$s.0.dcd molid $myMolid waitfor all
		set num_frames [molinfo $myMolid get numframes]
		set sel [atomselect $myMolid "alpha"]
		#puts $outFile "\n$filename$s.0.dcd"
		for {set i 0} {$i < $num_frames} {incr i} {
			$sel frame $i
			$sel update
			#puts -nonewline $outFile "\nframe$i"
			set res [$sel num]
			for {set j 0} {$j < $res} {incr j} {
				puts $outFile " [lindex [$sel get {resname phi psi}] $j]"
			}
		}
		mol delete $myMolid
	}
	close $outFile
	puts "End phipsi"
}
