That's a good point, the length is not constant. I might change the test to:
----- if len(file_data[0]) > 9 and file_data[0][0:8] == ['Num', 'Name', 'Selected', 'Data_set', 'Nucleus', 'Model', 'Equation', 'Params']: ----- This will then avoid the error situation of elements 0 to 8 not existing in file_data[0]. Thanks, Edward On Thu, May 29, 2008 at 9:42 PM, Sébastien Morin <[EMAIL PROTECTED]> wrote: > Hi Ed, > > Won't the variable "len(file_data[0])" change size depending on the > number of datasets used in relax but also on the diffusion tensor selected ? > > For example, there are 51 fields for a 'local_tm' diffusion using 8 > datasets, but 58 fields for an ellipsoid using 9 datasets... > > Maybe the check for version 1.2 could be something more like : > > -------------------------- > if file_data[0][0:8] == ['Num', 'Name', 'Selected', 'Data_set', > 'Nucleus', 'Model', 'Equation', 'Params']: > -------------------------- > > instead of > > -------------------------- > if len(file_data[0]) == 54 and file_data[0][0:8] == ['Num', 'Name', > 'Selected', 'Data_set', 'Nucleus', 'Model', 'Equation', 'Params']: > -------------------------- > > This change works for the two cases in example above... > > What do you think ? > > Ciao ! > > > Séb > > > > > > [EMAIL PROTECTED] wrote: >> Author: bugman >> Date: Wed May 28 21:35:55 2008 >> New Revision: 6275 >> >> URL: http://svn.gna.org/viewcvs/relax?rev=6275&view=rev >> Log: >> Wrote a method for determining which relax version the results file belongs >> to. >> >> >> Modified: >> 1.3/specific_fns/model_free/results.py >> >> Modified: 1.3/specific_fns/model_free/results.py >> URL: >> http://svn.gna.org/viewcvs/relax/1.3/specific_fns/model_free/results.py?rev=6275&r1=6274&r2=6275&view=diff >> ============================================================================== >> --- 1.3/specific_fns/model_free/results.py (original) >> +++ 1.3/specific_fns/model_free/results.py Wed May 28 21:35:55 2008 >> @@ -38,6 +38,32 @@ >> class Results: >> """Class containing methods specific to the model-free results files.""" >> >> + def __determine_version(self, file_data): >> + """Determine which relax version the results file belongs to. >> + >> + @param file_data: The processed results file data. >> + @type file_data: list of lists of str >> + @return: The relax version number. >> + @rtype: str >> + @raises RelaxError: If the relax version the model-free results >> file belongs to cannot be >> + determined. >> + """ >> + >> + # relax 1.2 results file (test for the 1.2 header line). >> + if len(file_data[0]) == 54 and file_data[0][0:8] == ['Num', 'Name', >> 'Selected', 'Data_set', 'Nucleus', 'Model', 'Equation', 'Params']: >> + version = '1.2' >> + >> + # Can't determine the file version. >> + else: >> + raise RelaxError, "Cannot determine the relax version the >> model-free results file belongs to." >> + >> + # Print out. >> + print "relax " + version + " model-free results file." >> + >> + # Return the version. >> + return version >> + >> + >> def read_columnar_col_numbers(self, header): >> """Function for sorting the column numbers from the columnar >> formatted results file.""" >> >> @@ -721,6 +747,9 @@ >> @type verbosity: int >> """ >> >> + # Determine the results file version. >> + version = self.__determine_version(file_data) >> + >> # Extract and remove the header. >> header = file_data[0] >> file_data = file_data[1:] >> >> >> _______________________________________________ >> relax (http://nmr-relax.com) >> >> This is the relax-commits mailing list >> [EMAIL PROTECTED] >> >> To unsubscribe from this list, get a password >> reminder, or change your subscription options, >> visit the list information page at >> https://mail.gna.org/listinfo/relax-commits >> >> > > _______________________________________________ relax (http://nmr-relax.com) This is the relax-devel mailing list [email protected] To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-devel

