def constructCorpus(contigs, classMap, binary, target):
    """
    Construct a corpus, or body of training data for the decision tree, as well as the data under test.

    Args:
        contigs: A list of sidr.common.Contig objects with test variables.
        classMap: A dictionary mapping class names to their class id used by scikit-learn.
        binary: Set True to use "binary" (target/nontarget) classification for the model.
        target: The name of the target classification.
    Returns:
        corpus: A list of lists, containing the GC content, coverage, and class number.
        testdata: Data that was not classified by BLAST and will later be classified by the
            trained model.
        features: List of variables used by each contig.
    """
    corpus = []
    testdata = []
    features = []
    for contig in contigs:
        variableBuf = list(contig.variables.values())
        features = list(contig.variables.keys())
        if contig.classification:
            if binary:
                if contig.classification.lower() == target.lower():
                    variableBuf.append("target")
                    corpus.append(variableBuf)
                else:
                    variableBuf.append("nontarget")
                    corpus.append(variableBuf)
            else:
                variableBuf.append(contig.classification)
                corpus.append(variableBuf)
        else:
            variableBuf.insert(0, contig.contigid)
            testdata.append(variableBuf)
    return corpus, testdata, features