#!/usr/bin/python #-*- coding: UTF-8 -*- #************************************************ # showDep.py # # This script process the output of the perl # script used to retrieve the dependencies information # from the bioconductor SVN. # It aims to get the list of dependencies for a # specified list of libraries. # # # Made by Pierre-Yves chibon # # Version 1.1 -- 28th July 2008 # * Add the number of libraries to package at the end # * Small layout fix # # Version 1.0 -- 25th July 2008 # * Gives for a list of libraries all their # dependencies and sub-dependencies # # Distributed under License GPLv3 or later # You can find a copy of this license on the website # http://www.gnu.org/licenses/gpl.html # #*********************************************** import getopt, sys, re#, shutil, os ## Here is defined list of libraries of interest Rlib = ['affy', 'affydata', 'affyPLM', 'annaffy', 'annotate', 'Biobase', 'Biostrings', 'DynDoc', 'gcrma', 'genefilter', 'geneplotter', 'hgu95av2.db', 'limma', 'marray', 'matchprobes', 'multtest', 'ROC', 'vsn', 'xtable', 'affyQCReport'] # Empty list that will contain the list of library # investigated by the program libProcessed=[] ################################################# USAGE =""" This program is designed to parse the output generated by the perl script that retrieve the dependencies information from the Bioconductor SVN. Usage: python probe2seq.py -i file python probe2seq.py --inpuFile=file The list of library investigate is defined line 29 of the script. """ ################################################# ################################################# ### argument # retrieve the arguments given and show the help when needed def argument(): try: opts, args = getopt.getopt(sys.argv[1:], "i:", ["inputFile="]) except getopt.GetoptError: print USAGE sys.exit(1) inputfile = None for option, argument in opts: if option in ("-i", "--inputFile"): inputfile = argument return (inputfile) ################################################ ################################################# ### search # search in the file given the dependencies of the library def search(File,lib, Rlib, libProcessed): # Open the input file sF=open(File, 'r') # Print the library for which the dependancies are looked for print lib # Read the file for line in sF.readlines(): # Clean each line of the file line = line.replace(";\n","").replace("\"","").replace("\t","") # Check wether the line has the '->' versionMotif = re.compile('->') tmp = versionMotif.findall(line) if tmp: # Split the line in two part among the '->' (rlib,libDep) = line.split( ' -> ' ) # If the library in the first part of the line == the library # of interest #if (rlib == lib and not libDep in libProcessed ): #reduced the number of libraries shown, does not reflect really the reality if (rlib == lib ): # Add this library to the list and print it Rlib.append(libDep) print "\t\t",libDep # Add the library looked for to the list of already processed library libProcessed.append(lib) # Close the file and return the values sF.close() return(Rlib, libProcessed) #sys.exit(0) ######### Main ############# inputfile=argument() # Show all the argument given #Debugging purpose #print "\ninputFile from sys.argv ==> ", inputfile,"\n" # Return the usage message if one arguments is missing if (inputfile == None): print USAGE sys.exit(0) # Layout print "The script starts for the libraries :",Rlib,"\n" print "Library \t Dependencies" # Process all the libraries for lib in Rlib: if not lib in libProcessed: (Rlib,libProcessed) = search(inputfile,lib, Rlib,libProcessed) # print Rlib # For debugging purpose # print '# Number of R libraries',len(Rlib) # print libProcessed # For debugging purpose print '# Number of libraries to package',len(libProcessed)