Structure Learning and Inference With Applications to Glycans