示例#1
0
文件: goqm.go 项目: rmera/gopymol
//This is a very inefficient way to get the residue IDs. I am kind of hoping that
//the QM optimization will allways take longer than this function.
func GetResidueIds(mol chem.Atomer) ([]int, []string) {
	residues := make([]int, 0, int(mol.Len()/10))
	chains := make([]string, 0, int(mol.Len()/10))
	for i := 0; i < mol.Len(); i++ {
		curr := mol.Atom(i)
		if !scu.IsInInt(curr.MolID, residues) {
			residues = append(residues, curr.MolID)
			chains = append(chains, curr.Chain)
		}

	}
	return residues, chains
}
示例#2
0
文件: gorama.go 项目: rmera/gopymol
func main() {
	//This is the part that collects all the data from PyMOL, with all  the proper error checking.
	stdin := bufio.NewReader(os.Stdin)
	options, errj := chemjson.DecodeOptions(stdin)
	if errj != nil {
		fmt.Fprint(os.Stderr, errj.Marshal())
		log.Fatal(errj)
	}
	mols := make([]*chem.Topology, 0, len(options.SelNames))
	coordset := make([]*v3.Matrix, 0, len(options.SelNames))
	for k, _ := range options.SelNames {
		mol, coords, errj := chemjson.DecodeMolecule(stdin, options.AtomsPerSel[k], 1)
		if errj != nil {
			fmt.Fprint(os.Stderr, errj.Marshal())
			log.Fatal(errj)
		}
		mols = append(mols, mol)
		coordset = append(coordset, coords[0])
	}
	//The program itself
	ramadata := make([][][]float64, 0, 0)
	var HLS [][]int
	var HL []int
	for k, mol := range mols {

		fmt.Println("len in go", mol.Len(), coordset[k].NVecs()) //////
		HL = []int{}
		oldres1 := mol.Atom(0).MolID + 1 //the residues should be contiguous!!!
		chem.FixNumbering(mol)
		ramalist, errj := chemplot.RamaList(mol, "ABC DEFGHI", []int{0, -1}) ////
		if errj != nil {
			log.Fatal(errj)
		}
		ramalist2, index := chemplot.RamaResidueFilter(ramalist, options.StringOptions[0], false)
		rama, errj := chemplot.RamaCalc(coordset[k], ramalist2)
		if errj != nil {
			log.Fatal(errj)
		}
		ramadata = append(ramadata, rama)
		var i int
		if options.IntOptions != nil && options.IntOptions[0] != nil {
			for i = 0; i < len(ramalist); i++ {
				fmt.Println(i, i+oldres1, index[i], options.IntOptions[0])
				if index[i] != -1 && scu.IsInInt(i+oldres1, options.IntOptions[0]) {
					HL = append(HL, index[i])
					fmt.Println("NAME:", ramalist[index[i]].Molname)
				}
			}
			HLS = append(HLS, HL)
		}
	}
	name := append(options.SelNames, "Rama")
	var err error
	if len(ramadata) == 1 {
		err = chemplot.RamaPlot(ramadata[0], HL, "Ramachandran plot", strings.Join(name, "_"))
	} else {
		err = chemplot.RamaPlotParts(ramadata, HLS, "Ramachandran plot", strings.Join(name, "_"))
	}
	if err != nil {
		fmt.Fprint(os.Stderr, chemjson.NewError("process", "main", err).Marshal())
	}
}