Changeset fdb134b9 in sasview for sanscalculator/src


Ignore:
Timestamp:
Jan 20, 2013 12:50:50 PM (12 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
a30864b1
Parents:
afcb052
Message:

added bonding lines for pdb data if provided

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sanscalculator/src/sans/calculator/sans_gen.py

    rafd45674 rfdb134b9  
    500500        vol_pix = numpy.zeros(0) 
    501501        pix_symbol = numpy.zeros(0) 
     502        x_line = numpy.zeros(0) 
     503        y_line = numpy.zeros(0) 
     504        z_line = numpy.zeros(0) 
    502505        try: 
    503506            input_f = open(path, 'rb') 
     
    507510            for line in lines: 
    508511                try: 
    509                     #toks = line.split() 
    510512                    # check if line starts with "ATOM" 
    511513                    if line[0:6].strip().count('ATM') > 0 or \ 
     
    553555                        sld_mz = numpy.append(sld_mz, 0) 
    554556                        pix_symbol = numpy.append(pix_symbol, atom_name) 
     557                    elif line[0:6].strip().count('CONECT') > 0 : 
     558                        toks = line.split() 
     559                        for val in toks[2:]: 
     560                            index = int(val) - 1 
     561                            num = int(toks[1]) - 1 
     562                            x_line = numpy.append(x_line,  
     563                                                  [pos_x[num], pos_x[index]]) 
     564                            y_line = numpy.append(y_line,  
     565                                                  [pos_y[num], pos_y[index]]) 
     566                            z_line = numpy.append(z_line,  
     567                                                  [pos_z[num], pos_z[index]])         
    555568                except: 
    556569                    pass 
     
    561574 
    562575            output = MagSLD(pos_x, pos_y, pos_z, sld_n, sld_mx, sld_my, sld_mz) 
     576            output.set_conect_lines(x_line, y_line, z_line) 
    563577            output.filename = os.path.basename(path) 
    564578            output.set_pix_type('atom') 
     
    834848        self.znodes = 10.0 
    835849        self.has_stepsize = False 
     850        self.has_conect = False 
    836851        self.pos_unit = self._pos_unit 
    837852        self.sld_unit = self._sld_unit 
     
    841856        self.pos_z = pos_z 
    842857        self.sld_n = sld_n 
     858        self.line_x = None 
     859        self.line_y = None 
     860        self.line_z = None 
    843861        self.sld_mx = sld_mx 
    844862        self.sld_my = sld_my 
     
    10171035        return self.xstepsize, self.ystepsize, self.zstepsize 
    10181036 
    1019      
     1037    def set_conect_lines(self, line_x, line_y, line_z): 
     1038        """ 
     1039        Set bonding line data if taken from pdb 
     1040        """ 
     1041        if line_x.__class__.__name__ != 'ndarray' or len(line_x) < 1: 
     1042            return 
     1043        if line_y.__class__.__name__ != 'ndarray' or len(line_y) < 1: 
     1044            return 
     1045        if line_z.__class__.__name__ != 'ndarray' or len(line_z) < 1: 
     1046            return 
     1047        self.has_conect = True 
     1048        self.line_x = line_x  
     1049        self.line_y = line_y  
     1050        self.line_z = line_z 
     1051         
     1052 
    10201053def test_load(): 
    10211054    from danse.common.plottools.arrow3d import Arrow3D 
Note: See TracChangeset for help on using the changeset viewer.