def __init__(self, n=1, cap_start=True): super(Alkane, self).__init__() if n < 1: raise ValueError('n must be 1 or more') if cap_start: #if n == 1, will simply return a a methane molecule if n == 1: self.add(CH4(), 'methyl_start') if n > 1: self.add(Backbone(n=n-1, cap_start_mol=CH3(), cap_start_name= 'methyl_start', cap_start_port = 'up', cap_end_mol = CH3_down(), cap_end_name='methyl_end', cap_end_port= 'dow')) else: #if n == 1, will simply return a a methane molecule, #with an available 'down' port. #We will label this as 'methyl_start', again for consistency #with longer chain molecules. if n == 1: self.add(CH3_down(), 'methyl_start') if n > 1: self.add(Backbone(n=n-1, cap_start_mol=CH2(), cap_start_name= 'methyl_start', cap_start_port = 'up', cap_end_mol = CH3_down(), cap_end_name='methyl_end', cap_end_port= 'down'))
def __init__(self, n=1, cap_start=True): super(Alcohol, self).__init__() if n < 1: raise ValueError('n must be 1 or more') if cap_start: self.add(Backbone(n=n, cap_start_mol=CH3(), cap_start_name= 'methyl_start', cap_start_port = 'up', cap_end_mol = OH(), cap_end_name='OH_end', cap_end_port= 'down')) else: self.add(Backbone(n=n, cap_start_mol=CH2(), cap_start_name= 'methyl_start', cap_start_port = 'up', cap_end_mol = OH(), cap_end_name='OH_end', cap_end_port= 'down'))
def __init__(self, n=1, cap_start=True): super(Acid, self).__init__() if n < 1: raise ValueError('n must be 1 or more') if cap_start: if n ==1: self.add(Methanol()) if n > 1: self.add(Backbone(n=n-1, cap_start_mol=CH3(), cap_start_name= 'methyl_start', cap_start_port = 'up', cap_end_mol = COOH(), cap_end_name='COOH_end', cap_end_port= 'down')) else: if n ==1: self.add(COOH()) if n > 1: self.add(Backbone(n=n-1, cap_start_mol=CH2(), cap_start_name= 'methyl_start', cap_start_port = 'up', cap_end_mol = COOH(), cap_end_name='COOH_end', cap_end_port= 'down'))
def __init__(self, n=1, cap_start_mol=CH3(), cap_start_name= 'methyl_start', cap_start_port = 'up', cap_end_mol = OH(), cap_end_name='OH', cap_end_port= 'down'): super(Backbone, self).__init__() if n < 1: raise ValueError('n must be 1 or more') if n == 1: cap1 = cap_start_mol self.add(cap1, cap_start_name) cap2 = cap_end_mol self.add(cap2, cap_end_name) mb.force_overlap(cap1, cap1[cap_start_port], cap2[cap_end_port]) if n == 2: cap1 = cap_start_mol self.add(cap1, cap_start_name) chain = CH2() self.add(chain, 'chain') mb.force_overlap(move_this=chain, from_positions=chain['down'], to_positions=cap1[cap_start_port], ) cap2 = cap_end_mol self.add(cap2, cap_end_name) mb.force_overlap(move_this=cap2, from_positions=cap2[cap_end_port], to_positions=chain['up']) if n > 2: cap1 = cap_start_mol self.add(cap1, cap_start_name) chain = mb.recipes.Polymer(CH2(), n=n-1, port_labels=('up', 'down')) self.add(chain, 'chain') mb.force_overlap(move_this=chain, from_positions=chain['down'], to_positions=cap1[cap_start_port]) cap2 = cap_end_mol self.add(cap2, cap_end_name) mb.force_overlap(move_this=cap2, from_positions=cap2[cap_end_port], to_positions=chain['up'])