ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Códigos de Java


Enviado por   •  19 de Octubre de 2018  •  Informes  •  2.022 Palabras (9 Páginas)  •  108 Visitas

Página 1 de 9

public class ReactionTest {
   
public static void main(String [] args) throws CDKException, IOException {
       
//Crea una instancia sin crear nuevo elemento!

        IChemObjectBuilder iChemObjectBuilder = SilentChemObjectBuilder.getInstance();    

        //Convierte el texto a una molecula
       
SmilesParser smilesParser = new SmilesParser(iChemObjectBuilder);

        //smilesParser crea la referencia;pareseSmiles es un método que devuelve    

        IAtomContainer
       
IAtomContainer ethanol = smilesParser.parseSmiles("CCO");        

        IAtomContainer aceticAcid = smilesParser.parseSmiles("CC=OO");
       IAtomContainer bleach = smilesParser.parseSmiles(
"ClO");

       Reaction reaction =
new Reaction();
       ethanol.setProperty(CDKConstants.
TITLE,"Ethanol");//Crea un título a la imagen
       
reaction.setProperty(CDKConstants.TITLE,"reaction1");//Crea tíyulo a la reacción
       
reaction.addReactant(ethanol);
       reaction.addAgent(bleach);
       reaction.addProduct(aceticAcid);

       DepictionGenerator depictionGenerator =
new DepictionGenerator();
       depictionGenerator = depictionGenerator.withFillToFit().withAtomColors()

        .withSize(500,500).withMolTitle().withRxnTitle(); //Usando ambos títulos
       //Al depict() se le asigna un elemento de IAtomContainer
       
depictionGenerator.depict(reaction).writeTo("reaction.png");
       depictionGenerator.depict(ethanol).writeTo(
"ethanol.png");
   
}
}

public class Test {
   
public static void main(String [] args) throws CDKException, IOException {
       IAtom hydrogen =
new Atom(Elements.HYDROGEN);
       IAtom hydrogen2 =
new Atom("H");
       IBond bond1 =
new Bond(hydrogen,hydrogen2,IBond.Order.SINGLE);
       IAtomContainer molecularHydrogen =
new AtomContainer();
       molecularHydrogen.addAtom(hydrogen);
       molecularHydrogen.addAtom(hydrogen2);
       molecularHydrogen.addBond(bond1);
       
for(IAtom atom:molecularHydrogen.atoms()){
           System.
out.println(atom.getSymbol());
       }
       Ring cylohexane =
new Ring(6,"CH");
       Ring benzene = cylohexane;
       
int i=2;
       
for(IBond bond:benzene.bonds()){
           bond.setIsAromatic(
true);
           
if(i%2==0){
               bond.setOrder(IBond.Order.
DOUBLE);
           }
           i++;
       }
       DepictionGenerator depictionGenerator =
new DepictionGenerator();
       depictionGenerator = depictionGenerator.withAtomColors().withFillToFit()

        .withSize(500,500);
       depictionGenerator.depict(benzene).writeTo(
"benzene.png");
       
//depict returns a class from the same hierarchy as the class  

        depictionGenerator
       // depict generate the molecule you passed

       
String lsdSmile = "CCN(CC)C(=O)[C@H]1CN([C@@H]2Cc3c[nH]c4c3c(ccc4)C2=C1)C";
       IChemObjectBuilder objectBuilder = SilentChemObjectBuilder.
getInstance();
       SmilesParser smilesParser =
new SmilesParser(objectBuilder);
       smilesParser.parseSmiles(lsdSmile);
       IAtomContainer lsd = smilesParser.parseSmiles(lsdSmile);
       depictionGenerator.depict(lsd).writeTo(
"lsd.png");
       
//Parser takes a string and return another thing
   
}
}

public class Atom {
   
private int atomicNumber;
   
private String symbol;
   
private double weigth;
   
private double radii;

   
public Atom(int atomicNumber, String symbol, double weigth, double radii) {
       
this.atomicNumber = atomicNumber;
       
this.symbol = symbol;
       
this.weigth = weigth;
       
this.radii = radii;
   }
   
public int getAtomicNumber() {
       
return atomicNumber;
   }
   
public void setAtomicNumber(int atomicNumber) {
       
this.atomicNumber = atomicNumber;
   }
   
public String getSymbol() {
       
return symbol;
   }
   
public void setSymbol(String symbol) {
       
this.symbol = symbol;
   }
   
public double getWeigth() {
       
return weigth;
   }
   
public void setWeigth(double weigth) {
       
this.weigth = weigth;
   }
   
public double getRadii() {
       
return radii;
   }
   
public void setRadii(double radii) {
       
this.radii = radii;
   }
}


...

Descargar como (para miembros actualizados)  txt (9.3 Kb)   pdf (163.4 Kb)   docx (18.9 Kb)  
Leer 8 páginas más »
Disponible sólo en Clubensayos.com