Back to The tech awesomeness
Table of contents
Free starter chapters

The article for today.


public class Test34245354436546 {
    class Part {
        String uid = UUID.randomUUID().toString();
        private List < Part > parts = new ArrayList < >();
        private Part closee;
        private String name;
        public Part() {
            parts.add(this);
        }
        public Part part(final Part part) {
            parts.add(part);
            return this;
        }
        
        public Part close(final Part part) {
            closee = part;
            return part;
        }
        
        public List < Part > getParts () {
            return parts;
        }
        
        public String getName() {
            return name;
        }
    }
    class Nitrogenousbase extends Part {}
    /* class Nucleoside extends Nitrogenousbase {
        //consists
    }
    class Nucleotide extends Nucleoside {
        //consists
    }
    class Polynucleotide extends Nucleotide {
        //consists
    }
    class RNA extends Acid {
        //consists
    }
    class DNA extends Acid {
        //consists
    }*/

    interface HashCodeable {
        /**
         * Java, sha sum, other hash code algorithm.
         * @return 
         */
        String getHashCode();
    }

    abstract class LineFormat implements HashCodeable {}

    class TwoLineFormat extends LineFormat {/*f.a.s.t., version a.; 2LF*/
        public String identifier;
        public String content;

        @Override
        public String getHashCode() {
            return "" + content.hashCode();
        }
    }

    class FourLineFormat extends LineFormat {/*f.a.s.t., version q.; 4LF*/
        public String identifier;
        public String content;
        public String qualityScore1;
        public String qualityScore2;

        @Override
        public String getHashCode() {
            return "" + content.hashCode();
        }
    }
    
    class O extends Part implements ConventionalStandardAtomicWeightCalculatable {
        @Override
        public String getName() {
            return "oxygen";
        }
        private Double conventionalStandardAtomicWeight = 15.999;
        @Override
        public Double getConventionalStandardAtomicWeight() {
            return conventionalStandardAtomicWeight;
        };
    }
    class C extends Part implements ConventionalStandardAtomicWeightCalculatable {
        @Override
        public String getName() {
            return "carbon";
        }
        private Double conventionalStandardAtomicWeight = 12.011;
        @Override
        public Double getConventionalStandardAtomicWeight() {
            return conventionalStandardAtomicWeight;
        };
    }
    class N extends Part implements ConventionalStandardAtomicWeightCalculatable {
        @Override
        public String getName() {
            return "nitrogen";
        }
        private Double conventionalStandardAtomicWeight = 14.007;
        @Override
        public Double getConventionalStandardAtomicWeight() {
            return conventionalStandardAtomicWeight;
        };
    }
    class H extends Part implements ConventionalStandardAtomicWeightCalculatable {
        @Override
        public String getName() {
            return "hydrogen";
        }
        private Double conventionalStandardAtomicWeight = 1.008;
        @Override
        public Double getConventionalStandardAtomicWeight() {
            return conventionalStandardAtomicWeight;
        };
    }
    
    interface ConventionalStandardAtomicWeightCalculatable {
        Double getConventionalStandardAtomicWeight();
    }
    
    class Line extends Part {}
    class DoubleLine extends Part {}
    class WaveLine extends Part {}
    
    class Uracil extends Nitrogenousbase {
        public Part getUracil() {
            Part o1 = new O();
            Part o2 = new O();//32
            Part c1 = new C();
            Part c2 = new C();//24
            Part doubleLine1 = new DoubleLine();
            Part doubleLine2 = new DoubleLine();
            Part doubleLine3 = new DoubleLine();
            Part line1 = new Line();
            Part line2 = new Line();
            Part line3 = new Line();
            Part line4 = new Line();
            Part nh1 = new N().part(new H());//4
            Part nh2 = new N().part(new H());//28
            Part ch1 = new C().part(new H());
            Part ch2 = new C().part(new H());//24
            
            Part C4H4N2O2result = (c1.part(doubleLine2).part(o1))
                    .part(doubleLine1)
                    .part(ch1).part(doubleLine2)
                    .part(ch2).part(line1).part(nh1).part(line2)
                    .part(c2.part(doubleLine3).part(o2))
                    .part(line3).part(nh2).part(line4).close(c1);
            return C4H4N2O2result;
        }
    }
    class Adenine extends Nitrogenousbase {/* ... */}
    class Cytosine extends Nitrogenousbase {/* ... */}
    class Guanine extends Nitrogenousbase {/* ... */}
    class Thymine extends Nitrogenousbase {/* ... */}
    
    static List < Part > getParts(
            final List < Part > parts,
            final List < String > uids,
            final int depthScanLevel) {
        List < Part > result = new ArrayList < >();
        if (depthScanLevel >= 1)
        for (Part part: parts) {
            //System.out.println("parts: " + parts.size());
            if (!uids.contains(part.uid)) {
                uids.add(part.uid);
                result.add(part);
                if (depthScanLevel >= 2)
                for (Part part2: part.getParts()) {
                    if (!uids.contains(part2.uid)) {
                        uids.add(part2.uid);
                        result.add(part2);

                        if (depthScanLevel >= 3)
                        for (Part part3: part2.getParts()) {
                            if (!uids.contains(part3.uid)) {
                                uids.add(part3.uid);
                                result.add(part3);
                            }
                        }
                    }
                }
            }
        }
        return result;
    }
    
    //public static void convert() {}
    //public static void map() {}
    //public static void assemble() {}

    public static void main(String[] args) {
        Test34245354436546 test = new Test34245354436546();
        Cytosine c = test.new Cytosine();
        Adenine a = test.new Adenine();
        Thymine t = test.new Thymine();
        Part catNucleicAcid = c.part(a).part(t);
        TwoLineFormat catNucleicAcidInTwoLineFormat = new TwoLineFormat();
        catNucleicAcidInTwoLineFormat.identifier = "catNucleicAcid";
        catNucleicAcidInTwoLineFormat.content = "CAT";
        System.out.println(catNucleicAcidInTwoLineFormat.getHashCode());
        FourLineFormat catNucleicAcidInFourLineFormat = new FourLineFormat();
        //catNucleicAcidInFourLineFormat.identifier = "catNucleicAcid";
        catNucleicAcidInFourLineFormat.content = "CAT";
        System.out.println(catNucleicAcidInFourLineFormat.getHashCode());
        
        Double conventionalStandardAtomicWeightSum = 0D;
        List < String > uids = new ArrayList < >();
        for (Part part:
                getParts(test.new Uracil().getUracil().getParts(), uids, 3)) {
            
            if (part instanceof ConventionalStandardAtomicWeightCalculatable) {
                conventionalStandardAtomicWeightSum =
                    conventionalStandardAtomicWeightSum +
                    ((ConventionalStandardAtomicWeightCalculatable)part)
                            .getConventionalStandardAtomicWeight();
                System.out.println("name: " + part.getName());
                System.out.println("zz    " +
                        ((ConventionalStandardAtomicWeightCalculatable)part)
                                .getConventionalStandardAtomicWeight());
            }
        }
        System.out.println("ConventionalStandardAtomicWeight: "
                + conventionalStandardAtomicWeightSum);
    }
}

The update from 2020-05-13.

Standard several line formats are existing for keeping the content and other data of the acids.

The update from 2020-05-29.

There was an addition of the hash code for the contents of the line formats.

Оновлення від 2022-07-07.

The update from 2022-07-07.

До цих http://thetechawesomeness.ideasmatter.info/part-recomposer.html та http://thetechawesomeness.ideasmatter.info/part-recomposer-for-another-application.html кодів є застосованими someStringifiedCondition та як у PingerAndMover у http://thetechawesomeness.ideasmatter.info/accelerator-of-code-progress.html від 2022-01-29 для запуска.

Або ж об'єднанням за допомогою якогось з http://thetechawesomeness.ideasmatter.info/summation.html наприклад для ApplicationAsAParameter як класом що збільшує і залишає такий код в одному з них застарілим і не потрібним тобто як у DRY . Адже таких ApplicationAsAParameter декілька принаймні два з тих двох веб сторінок це застосовуєме й як до http://thetechawesomeness.ideasmatter.info/ від 2022-06-19 і дещо зменшує повторення .