Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.NMR.xpktools.Peaklist Class Reference

List of all members.

Public Member Functions

def __init__
def residue_dict
def write_header

Public Attributes

 data
 firstline
 axislabels
 dataset
 sw
 sf
 datalabels
 dict

Detailed Description

Definition at line 42 of file xpktools.py.


Constructor & Destructor Documentation

def Bio.NMR.xpktools.Peaklist.__init__ (   self,
  infn 
)

Definition at line 46 of file xpktools.py.

00046 
00047     def __init__(self,infn):
00048     
00049         self.data=[]    # init the data line list
00050 
00051         infile=open(infn,'r')
00052 
00053         # Read in the header lines
00054         self.firstline=infile.readline().split("\012")[0]
00055         self.axislabels=infile.readline().split("\012")[0]
00056         self.dataset=infile.readline().split("\012")[0]
00057         self.sw=infile.readline().split("\012")[0]
00058         self.sf=infile.readline().split("\012")[0]
00059         self.datalabels=infile.readline().split("\012")[0]
00060 
00061         # Read in the data lines to a list 
00062         line=infile.readline()
00063         while line:
00064             self.data.append(line.split("\012")[0])
00065         line=infile.readline()


Member Function Documentation

def Bio.NMR.xpktools.Peaklist.residue_dict (   self,
  index 
)

Definition at line 66 of file xpktools.py.

00066 
00067     def residue_dict(self,index):
00068         # Generate a dictionary idexed by residue number or a nucleus
00069         # The nucleus should be given as the input argument in the
00070         # same form as it appears in the xpk label line (H1, 15N for example)
00071 
00072         maxres=-1; minres=-1
00073 
00074         # Cast the data lines into the xpentry class
00075         self.dict={}
00076         for i in range(len(self.data)):
00077             line=self.data[i]
00078             ind=XpkEntry(line,self.datalabels).fields[index+".L"]
00079             key=ind.split(".")[0]
00080 
00081             res=int(key)
00082 
00083             if (maxres==-1):
00084                 maxres=res
00085             if (minres==-1):
00086                 minres=res
00087 
00088             maxres=max([maxres,res])
00089             minres=min([minres,res])
00090 
00091             if str(res) in self.dict:
00092                 # Append additional data to list under same key
00093                 templst=self.dict[str(res)]
00094                 templst.append(line)
00095                 self.dict[str(res)]=templst
00096 
00097             else:
00098                 # This is a new residue, start a new list
00099                 self.dict[str(res)]=[line]  # Use [] for list type
00100 
00101         self.dict["maxres"]=maxres
00102         self.dict["minres"]=minres
00103 
00104         return self.dict

def Bio.NMR.xpktools.Peaklist.write_header (   self,
  outfn 
)

Definition at line 105 of file xpktools.py.

00105 
00106     def write_header(self,outfn):
00107         outfile=_try_open_write(outfn)
00108         outfile.write(self.firstline);outfile.write("\012")
00109         outfile.write(self.axislabels);outfile.write("\012")
00110         outfile.write(self.dataset);outfile.write("\012")
00111         outfile.write(self.sw);outfile.write("\012")
00112         outfile.write(self.sf);outfile.write("\012")
00113         outfile.write(self.datalabels);outfile.write("\012")
00114         outfile.close() 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 54 of file xpktools.py.

Definition at line 48 of file xpktools.py.

Definition at line 58 of file xpktools.py.

Definition at line 55 of file xpktools.py.

Definition at line 74 of file xpktools.py.

Definition at line 53 of file xpktools.py.

Definition at line 57 of file xpktools.py.

Definition at line 56 of file xpktools.py.


The documentation for this class was generated from the following file: