def createXml(args): if args.dsType is None: dset = openDataFile(*args.infile, strict=args.strict, skipCounts=args.skipCounts, generateIndices=args.generateIndices) else: dsTypes = DataSet.castableTypes() dset = dsTypes[args.dsType](*args.infile, strict=args.strict, skipCounts=args.skipCounts, generateIndices=args.generateIndices) if args.generateIndices: # we generated the indices with the last open, lets capture them with # this one: dset = dsTypes[args.dsType](*args.infile, strict=args.strict, skipCounts=args.skipCounts) if args.dsName != '': dset.name = args.dsName log.debug("Dataset created") dset.write(args.outfile, validate=args.novalidate, modPaths=True, relPaths=args.relative) log.debug("Dataset written") return 0
def createXml(args): dsTypes = DataSet.castableTypes() dset = dsTypes[args.dsType](*args.infile, strict=args.strict, skipCounts=args.skipCounts) log.debug("Dataset created") dset.write(args.outfile, validate=args.novalidate, modPaths=True, relPaths=args.relative) log.debug("Dataset written")
def createXml(args): dsTypes = DataSet.castableTypes() dset = dsTypes[args.dsType]( *args.infile, strict=args.strict, skipCounts=args.skipCounts, generateIndices=args.generateIndices ) if args.generateIndices: # we generated the indices with the last open, lets capture them with # this one: dset = dsTypes[args.dsType](*args.infile, strict=args.strict, skipCounts=args.skipCounts) log.debug("Dataset created") dset.write(args.outfile, validate=args.novalidate, modPaths=True, relPaths=args.relative) log.debug("Dataset written")
def createXml(args): if os.path.exists(args.outfile) and not args.force: raise IOError("Output file {} already exists. Use --force to " "clobber".format(args.outfile)) if args.dsType is None: dset = openDataFile(*args.infile, strict=args.strict, skipCounts=args.skipCounts, trustCounts=args.trustCounts, generateIndices=args.generateIndices, referenceFastaFname=args.reference_fasta_fname) else: dsTypes = DataSet.castableTypes() dset = dsTypes[args.dsType]( *args.infile, strict=args.strict, skipCounts=args.skipCounts, trustCounts=args.trustCounts, generateIndices=args.generateIndices, referenceFastaFname=args.reference_fasta_fname) if args.dsName != '': dset.name = args.dsName if args.metadata: dset.loadMetadata(args.metadata) if args.well_sample_name or args.bio_sample_name: if args.metadata: log.warning( "Setting the WellSample or BioSample name will overwrite fields pulled from %s", args.metadata) n_new_collections = add_mock_collection_metadata(dset) if n_new_collections > 0: log.warning( "Created new CollectionMetadata from blank template for %d movies", n_new_collections) if args.well_sample_name: force_set_all_well_sample_names(dset, args.well_sample_name) if args.bio_sample_name: force_set_all_bio_sample_names(dset, args.bio_sample_name) log.debug("Dataset created") if isinstance(dset, ContigSet): if args.organism: dset.metadata.organism = args.organism if args.ploidy: dset.metadata.ploidy = args.ploidy dset.newUuid() if args.no_sub_datasets: dset.subdatasets = [] if args.unique_collections: uniqueify_collections(dset.metadata) dset.write(args.outfile, validate=args.novalidate, relPaths=args.relative) log.debug("Dataset written") return 0
def createXml(args): if args.dsType is None: dset = openDataFile(*args.infile, strict=args.strict, skipCounts=args.skipCounts, generateIndices=args.generateIndices) else: dsTypes = DataSet.castableTypes() dset = dsTypes[args.dsType](*args.infile, strict=args.strict, skipCounts=args.skipCounts, generateIndices=args.generateIndices) if args.generateIndices: # we generated the indices with the last open, lets capture them with # this one: dset = dsTypes[args.dsType](*args.infile, strict=args.strict, skipCounts=args.skipCounts) if args.dsName != '': dset.name = args.dsName if args.metadata: dset.loadMetadata(args.metadata) log.debug("Dataset created") dset.write(args.outfile, validate=args.novalidate, relPaths=args.relative) log.debug("Dataset written") return 0
def createXml(args): dsTypes = DataSet.castableTypes() dset = dsTypes[args.dsType](*args.infile) log.debug("Dataset created") dset.write(args.outfile, validate=args.novalidate, relPaths=args.relative) log.debug("Dataset written")
def create_options(parser): parser.description = ('Create an XML file from fofn, BAM, or DataSet XML ' 'files.') pad = parser.add_argument pad("outfile", help="The XML file to create") pad("infile", nargs='+', help=("The fofn, BAM, or XML file(s) to make into a DataSet XML")) pad("--force", default=False, action='store_true', help=("Clobber output file if it already exists")) pad("--type", type=str, dest='dsType', choices=DataSet.castableTypes(), help=("The type of XML to create (may be inferred " "if not provided). ")) pad("--name", default='', dest='dsName', help="The name (in metadata) of the new DataSet") pad("--generateIndices", action='store_true', default=False, help=("Generate index files (.pbi and .bai for BAM, .fai for FASTA). " "Requires pysam and pbindex.")) pad("--metadata", help=("A Sequel metadata.xml file (or DataSet) to supply metadata")) pad("--novalidate", action='store_false', default=True, help=("Don't validate the resulting XML, don't modify paths")) pad("--relative", action='store_true', default=False, help=("Make the included paths relative instead of " "absolute (not compatible with --novalidate)")) pad("--organism", action="store", default="unknown", help="Organism name (for ReferenceSet only)") pad("--ploidy", action="store", default="haploid", help="Genome ploidy (for ReferenceSet only)") pad("--well-sample-name", help=("Set the WellSample name for all movies (will generate new " "CollectionMetadata from blank template for any movies that are " "not already represented).")) pad("--bio-sample-name", help=("Set the BioSample name for all movies (will generate new " "CollectionMetadata from blank template for any movies that are " "not already represented).")) pad("--reference-fasta-fname", help=("A path to a reference fasta file for the new AlignmentSet")) pad("--no-sub-datasets", action="store_true", default=False, help="Don't nest sub-datasets in output XML") pad("--unique-collections", action="store_true", default=False, help="Make sure CollectionMetadata records are unique") pad("--trustCounts", action="store_true", default=False, help="Assuming record counts in input dataset are correct, and " + "skip reading index files to get overall count") parser.set_defaults(func=createXml)