["Unk"])[0] if 'Name' in feature.qualifiers: if feature.qualifiers['Name'][0].startswith('tRNA-'): tRNA_type = feature.qualifiers['Name'][0] newfeature = wa.annotations.addFeature(featureData, trustme=True) def func0(): wa.annotations.setName( newfeature['features'][0]['uniquename'], tRNA_type, ) retry(func0) if args.source: gene_id = newfeature['features'][0]['parent_id'] def setSource(): wa.annotations.addAttributes( gene_id, {'DatasetSource': [args.source]}) retry(setSource) sys.stdout.write('\t'.join([ feature.id, newfeature['features'][0]['uniquename'], 'success', ]))
new_name = data[feature["parent_id"]] elif feature["uniquename"] in data: new_name = data[feature["uniquename"]] else: sys.stdout.write("%s\tNot Found\n" % feature["uniquename"]) continue else: if feature["uniquename"] in data: new_name = data[feature["uniquename"]] else: sys.stdout.write("%s\tNot Found\n" % feature["uniquename"]) continue if args.set == "name": def fn0(): wa.annotations.setName(feature["parent_id"], new_name) def fn1(): wa.annotations.setName(feature["uniquename"], new_name) retry(fn0) retry(fn1) else: def fn0(): wa.annotations.addAttributes(feature["parent_id"], {"locus_tag": [new_name]}) retry(fn0) sys.stdout.write("%s\t%s\n" % (feature["uniquename"], new_name))
# Then get a list of features. features = wa.annotations.getFeatures() # For each feature in the features for feature in sorted(features['features'], key=lambda x: random.random()): if args.type: if args.type == 'tRNA': if feature['type']['name'] != 'tRNA': continue elif args.type == 'terminator': if feature['type']['name'] != 'terminator': continue elif args.type == 'mRNA': if feature['type']['name'] != 'mRNA': continue else: raise Exception("Unknown type") # We see that deleteFeatures wants a uniqueName, and so we pass # is the uniquename field in the feature. def fn(): wa.annotations.deleteFeatures([feature['uniquename']]) print('Deleted %s [type=%s]' % (feature['uniquename'], feature['type']['name'])) if not retry(fn, limit=3): print('Error %s' % feature['uniquename'])