示例#1
0
    def _create_gn(seqScrDict, args, seqLength, resultsQueue, repertoire):
        # Get a reference to the bit manipulator
        bitManip = BitManipFactory.getBitSeqManip(args.moleculeType,
                                                  seqLength,
                                                  args.useIndels,
                                                  args.use_reverse_complements)

        # Get the sequences for the given repertoire
        sequences = seqScrDict.keys()

        # Get the list of scores for the given repertoire
        scores = [seqScrDict[sequence] for sequence in sequences]

        # Create a network builder object
        netBuilder = NetworkBuilder(bitManip)

        # Create the genotype network
        network = netBuilder.createGenoNet(repertoire, sequences, scores)

        # Get the number of components in the network
        numComponents = len(netBuilder.getComponents(network))

        # If there are more than one components,
        if numComponents > 1:
            # Get the giant component
            giant = netBuilder.getGiantComponent(network)

            # Set 'name' attribute for giant
            giant["name"] = repertoire + "_dominant"
        else:
            # The network and giant component are the same
            giant = network

        # Create a tuple in which to put the results
        netTuple = (repertoire, (network, giant))

        # Add the created network objects to the shared queue
        resultsQueue.put(netTuple)

        # Close the queue for this process
        resultsQueue.close()
示例#2
0
 def _bit_manipulator(self):
     return BitManipFactory.getBitSeqManip(self.cmdArgs.moleculeType,
                                           self.seqLength,
                                           self.cmdArgs.useIndels,
                                           self.cmdArgs.use_reverse_complements)
示例#3
0
    def __init__(self, arguments=None):
        # Initialize the parser object
        parser = argparse.ArgumentParser()

        # ---------------- Mandatory arguments ------------------ #

        # Add 'alphabetType' as an argument
        parser.add_argument("alphabetType",
                            help="Each genotype in the input file must be a string " +
                                 "of letters from the alphabet selected here.",
                            choices=BitManipFactory.getMoleculeTypes())

        # Add 'includeIndels' as an argument
        parser.add_argument("includeIndels",
                            help="Should be set to 'True' if mutations that shift " +
                                 "the entire genotype sequence by one letter should " +
                                 "also be considered. Only single point mutations are " +
                                 "considered when this parameter is set to 'False'.",
                            choices=["True", "true", "False", "false"])

        # Add 'inFilePath' as an argument
        parser.add_argument("inFilePath",
                            help="Complete path to the input file, relative to the " +
                                 "current directory.")

        # Add 'tau' as an argument
        parser.add_argument("tau",
                            help="Minimum score threshold: all genotypes in the input " +
                                 "file with 'score' values below 'Tau' will be ignored." +
                                 "Tau must be a number.",
                            type=float)

        # Add 'outPath' as an argument
        parser.add_argument("outPath",
                            help="Path to the directory where output files should be " +
                                 "generated. The directory will be created if it does " +
                                 "not already exist.")

        # ---------------- Optional arguments ------------------ #

        # Add 'use_reverse_complements' as an argument
        parser.add_argument("-rc", "--use_reverse_complements", dest="use_reverse_complements", action="store_const",
                            const=True,
                            help="When specified, reverse complements are considered during creation " +
                                 "and analysis of genotype networks for alphabet type DNA. This option is " +
                                 "not valid for other alphabet types.")

        # Add 'num_processes' as an argument
        parser.add_argument("-np", "--num_processes", dest="num_procs", action="store",
                            type=int, default="4",
                            help="No. of processes to be used in parallel processing")

        # Add 'verbose' as an argument
        parser.add_argument("-v", "--verbose", dest="verbose", action="store_const",
                            const=True,
                            help="Processing steps are printed to the screen during " +
                                 "program execution.")

        # Keep an object level copy of the arguments dict
        if arguments:
            # Parse the string of arguments received
            self.args = parser.parse_args(arguments)
        else:
            # Parse sys.argv
            self.args = parser.parse_args()