elif (fea.type == 'gene') or (fea.id in ('p6', 'IN', 'gp41')): assert prot[-1] == '*' assert '*' not in prot[:-1] else: assert '*' not in prot print 'Compare to old sequence' for fea in seqnew.features: if fea.id not in map(attrgetter('id'), seqold.features): continue feaold = seqold.features[map(attrgetter('id'), seqold.features).index(fea.id)] feaseq = fea.extract(seqnew) feaoldseq = feaold.extract(seqold) # NOTE: add an if check here in case of misannotations assert ''.join(feaseq) == ''.join(feaoldseq) print 'Importing additional features from old sequence' for fea in seqold.features: if fea.id not in map(attrgetter('id'), seqnew.features): seqnew.features.append(fea) print 'Added feature:', fea.id print 'Storing new annotated HXB2 sequence' save_custom_reference(seqnew, 'HXB2', 'gb')
assert prot[-1] == '*' assert prot[:-1].count('*') == 1 elif (fea.type == 'gene') or (fea.id in ('p6', 'IN', 'gp41')): assert prot[-1] == '*' assert '*' not in prot[:-1] else: assert '*' not in prot print 'Compare to old sequence' for fea in seqnew.features: if fea.id not in map(attrgetter('id'), seqold.features): continue feaold = seqold.features[map(attrgetter('id'), seqold.features).index(fea.id)] feaseq = fea.extract(seqnew) feaoldseq = feaold.extract(seqold) # NOTE: add an if check here in case of misannotations assert ''.join(feaseq) == ''.join(feaoldseq) print 'Importing additional features from old sequence' for fea in seqold.features: if fea.id not in map(attrgetter('id'), seqnew.features): seqnew.features.append(fea) print 'Added feature:', fea.id print 'Storing new annotated HXB2 sequence' save_custom_reference(seqnew, 'HXB2', 'gb')
elif 1.0 * L2 / L1 > 1.1: raise ValueError('Feature: '+fea.id+' is too long: '+s) ref.features.append(feature) return ref # Script if __name__ == '__main__': parser = argparse.ArgumentParser(description='Annotate like HXB2', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--refname', required=True, help='Name of reference to annotate') parser.add_argument('--verbose', type=int, default=2, help='Verbosity level [0-3]') parser.add_argument('--save', action='store_true', help='Save annotated sequence to file') args = parser.parse_args() refname = args.refname VERBOSE = args.verbose save = args.save ref = annotate_like_HXB2(refname, VERBOSE=VERBOSE) if save: save_custom_reference(ref, refname, format='gb')
return ref # Script if __name__ == '__main__': parser = argparse.ArgumentParser( description='Annotate like HXB2', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--refname', required=True, help='Name of reference to annotate') parser.add_argument('--verbose', type=int, default=2, help='Verbosity level [0-3]') parser.add_argument('--save', action='store_true', help='Save annotated sequence to file') args = parser.parse_args() refname = args.refname VERBOSE = args.verbose save = args.save ref = annotate_like_HXB2(refname, VERBOSE=VERBOSE) if save: save_custom_reference(ref, refname, format='gb')