Exemple #1
0
    def saveSelections(self, event=None):
        headers = ['class_num']
        spiderDictionary = {}
        key = 0
        selectKeys = self.select_dictionary.keys()
        selectKeys.sort()
        #	print "keys:", selectKeys

        for counter in selectKeys:
            key = key + 1
            spiderDictionary[key] = [counter, self.select_dictionary[counter]]


#	    print "spiderDictionary:", key, counter, self.select_dictionary[counter]

# if non-empty, backup prior versions
        if len(self.select_dictionary) > 0: backup(self.savefilename)

        if Spiderutils.writeSpiderDocFile(self.savefilename,
                                          spiderDictionary,
                                          headers=headers,
                                          append=1):
            print 'Wrote', key, 'keys to %s' % os.path.basename(
                self.savefilename)
        else:
            #	    showerror("Error!", "Unable to write to %s" % os.path.basename(self.savefilename))
            print "Unable to write to", self.savefilename
Exemple #2
0
    def saveSelections(self, event=None) :
        headers = ['class_num']
        spiderDictionary = {}
        key = 0
        selectKeys = self.select_dictionary.keys()
        selectKeys.sort()

        for counter in selectKeys:
            key = key + 1
            spiderDictionary[key] = [counter, self.select_dictionary[counter]]

        # if non-empty, backup prior versions
        if len(self.select_dictionary) > 0 : backup(self.savefilename)

        if Spiderutils.writeSpiderDocFile(self.savefilename, spiderDictionary, headers=headers, append=1):
            print 'Wrote', key, 'keys to %s' % os.path.basename(self.savefilename)
        else:
            print "Unable to write to", self.savefilename
        # read contents
        for line in listL:
    	    key += 1
	    split = line.split()

	    xdim = float(split[2])
	    ydim = float(split[3])
	    xcoord = float(split[0])
	    ycoord = float(split[1])

	    xcenter = xcoord + xdim/2
	    ycenter = ycoord + ydim/2
#	    ycenter = mic_y - (ycoord + ydim/2)

            dictF[key] = [xcenter,ycenter,key,dummy]
#           print filenum
	
#        headers = ['XCOORD','YCOORD','PARTICLE','PEAK_HT','XDIM','YDIM']
        headers = ['XCOORD','YCOORD','PARTICLE','PEAK_HT']
	backup(outputdoc)
        if Spiderutils.writeSpiderDocFile(outputdoc,dictF, headers=headers, append=0):
            print 'Wrote', key, 'keys to %s' % os.path.basename(outputdoc)
        else:
            print "Error!", "Unable to write to %s" % os.path.basename(outputdoc)
    else:
        print "Error!", "Unable to read %s" % file
else:
    print "syntax: emancoords2spiderdoc.py input_eman_coords output_spider_doc"
#    print "syntax: emancoords2spiderdoc.py input_eman_coords input_micrograph output_spider_doc"

Exemple #4
0
        # read contents
        for line in listL:
    	    key += 1
	    split = line.split()

	    xdim = float(split[2])
	    ydim = float(split[3])
	    xcoord = float(split[0])
	    ycoord = float(split[1])

	    xcenter = xcoord + xdim/2
	    ycenter = ycoord + ydim/2
#	    ycenter = mic_y - (ycoord + ydim/2)

            dictF[key] = [key,xcenter,ycenter,xcenter,ycenter,dummy]
#           print filenum
	
#        headers = ['XCOORD','YCOORD','PARTICLE','PEAK_HT','XDIM','YDIM']
        headers = ['XCOORD','YCOORD','PARTICLE','PEAK_HT']
	backup(outputdoc)
        if Spiderutils.writeSpiderDocFile(outputdoc,dictF, headers=headers, append=0):
            print 'Wrote', key, 'keys to %s' % os.path.basename(outputdoc)
        else:
            print "Error!", "Unable to write to %s" % os.path.basename(outputdoc)
    else:
        print "Error!", "Unable to read %s" % file
else:
    print "syntax: emanrctcoords2spiderdoc.py input_eman_coords output_spider_doc"
#    print "syntax: emancoords2spiderdoc.py input_eman_coords input_micrograph output_spider_doc"

    filename = sys.argv[2]

    F = {}  # initialize dictionary
    key = 0  # initialize key

    if os.path.exists(file):
        input = open(file, 'r')
        L = input.readlines()  # read line-by-line
        input.close()

        # read contents
        for line in L:
            filenum = Spiderutils.getfilenumber(line)
            key += 1
            F[key] = [filenum]
#           print filenum

        headers = ['file_number']
        if Spiderutils.writeSpiderDocFile(filename,
                                          F,
                                          headers=headers,
                                          append=0):
            print 'Wrote', key, 'keys to %s' % os.path.basename(filename)
        else:
            print "Error!", "Unable to write to %s" % os.path.basename(
                filename)
    else:
        print "Error!", "Unable to read %s" % file
else:
    print "Syntax: makefilenums.py inputtextfile outputspiderdoc"