Category Archives: Coder

fastqc Output Per sequence GC content, Sequence Duplication Levels and Overrepresented sequences

 

C content distribution map per sequence GC content

This graph should theoretically conform to the normal distribution (i.e. bell curve) , unless there are over represented sequences [i.e. there is a sharp peak on the basis of normal distribution], or there is pollution of other species [i.e. multiple peaks]

It can be seen from this figure that this should be the case that is in line with the over expression sequence, indicating that either there is sequence contamination or there is a gene with extremely high expression in the sequence

sequence duplication levels

This map can help to judge the complexity of the library. If the number of PCR amplification is too many or the initial amplification substrate is too few, the complexity of the library will be reduced

As can be seen in this figure, seems to have a large number of repetitive sequences, that is to say, the complexity of the library is low, which may be related to the overexpression of a gene

over expressed sequences

this table is also very important

It shows the length of at least 20 BP, the number of more than 0.1% of the total number of reads base composition, it can help to determine pollution (such as: carrier, adaptor sequence)

If the above GC content distribution is “hung”, this table can help us to determine the source. If it is a known carrier or connector, it will be listed if not, you can copy the sequence to blast

For example, here, we can copy the first sequence with the most expression to blast, and then find that it is actually a gene, so we can verify the previous conjecture: gene overexpression

 

 

How to Solve Issue: ScrollView can host only one direct child

There are some differences when Android uses Scrollview layout

Scrollview can host only one direct child.

 

The main reason is that there can only be one child element in the Scrollview, that is, the

You can’t juxtapose two child elements, so you need to put all child elements together

Elements inside a LinearLayout or Relative layout and other layout methods

How to not display “Commit point reached – logical record count”

You can use the keywordsilent, which is available in theoptions clause. You can set thefollowing thingsto be silent:

HEADER – Suppresses the SQL*Loader header messages that normally appear on the screen. Header messages still appear in the log file.

FEEDBACK – Suppresses the “commit point reached” feedback messages that normally appear on the screen.

ERRORS – Suppresses the data error messages in the log file that occur when a record generates an Oracle error that causes it to be
written to the bad file. A count of rejected records still appears.

DISCARDS – Suppresses the messages in the log file for each record written to the discard file.

PARTITIONS – Disables writing the per-partition statistics to the log file during a direct load of a partitioned table.

ALL – Implements all of the suppression values: HEADER, FEEDBACK, ERRORS, DISCARDS, and PARTITIONS.

You would want to suppressfeedback.

You can either use on the command line, for instance:

sqlldr schema/pw@db silent=(feedback, header)

On in the options clause of the control file, for instance:

options (bindsize=100000, silent=(feedback, errors) )

Spring boot trample log (@ springbootapplication conflicts with @ componentscan)

1. Introduction

Let’s take a look at the phenomenon. You can download the code here first

Let’s briefly introduce the classes inside

package com.iceberg.springboot.web;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
//@ComponentScan("com.iceberg.springboot.biz")
//@ComponentScan("com.iceberg.springboot.manager")
public class WebApplication {

    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class, args);
    }
}

Application startup class: I won’t say much about this. The above annotation is the key to this step

package com.iceberg.springboot.web.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class TestController implements ApplicationListener<ApplicationReadyEvent> {

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        log.warn("--------------------------TestController had loaded-----------------------------");
    }
}

Testcontroller: applicationlistener is implemented here. When the spring container is started, this method will be called. Of course, the precondition is that testcontroller must be loaded into the spring container, so we can judge whether this class is loaded by spring through this log

As we all know, @ springbootapplication annotation will automatically scan the subpackages of the same package, so testcontroller will be loaded by spring

Let’s start the app and see the results

The log can be printed. It’s easy to understand. If it’s not printed, it’s the hell

Then we uncomment one of the @ componentscan and run it again

package com.iceberg.springboot.web;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@ComponentScan("com.iceberg.springboot.biz")
//@ComponentScan("com.iceberg.springboot.manager")
public class WebApplication {

    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class, args);
    }
}

The log is gone! What the fuck???

Don’t panic. Let’s open the second comment to see the result

package com.iceberg.springboot.web;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@ComponentScan("com.iceberg.springboot.biz")
@ComponentScan("com.iceberg.springboot.manager")
public class WebApplication {

    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class, args);
    }
}

The log appears again

I don’t know what’s your mood, but my mood is probably the same as that of the two expression packs above. I even suspected that spring had a bug, but in the end I found out the cause of the problem. As for whether it was a bug or not… You can judge for yourself

2、 Analysis of spring boot startup process

The complete process analysis can be seen here. We only analyze the parts used here, and directly look at reading @ componentscans

//ConfigurationClassParser.java
//Line 258
protected final SourceClass doProcessConfigurationClass(ConfigurationClass configClass, SourceClass sourceClass) throws IOException {
    //Omit part of the code
    
    Set<AnnotationAttributes> componentScans = AnnotationConfigUtils.attributesForRepeatable(
				sourceClass.getMetadata(), ComponentScans.class, ComponentScan.class);
    
    //Omit part of the code
}

//AnnotationConfigUtils.java
//line 288
static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata,
                                                         Class<?> containerClass, Class<?> annotationClass) {

    return attributesForRepeatable(metadata, containerClass.getName(), annotationClass.getName());
}

//AnnotationConfigUtils.java
//Line 295
//containerClassName:org.springframework.context.annotation.ComponentScans
//annotationClassName:org.springframework.context.annotation.ComponentScan
static Set<AnnotationAttributes> attributesForRepeatable(
    AnnotationMetadata metadata, String containerClassName, String annotationClassName) {

    Set<AnnotationAttributes> result = new LinkedHashSet<>();

    //find @ComponentScan
    addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName, false));

    //find @ComponentScans
    Map<String, Object> container = metadata.getAnnotationAttributes(containerClassName, false);
    if (container != null && container.containsKey("value")) {
        for (Map<String, Object> containedAttributes : (Map<String, Object>[]) container.get("value")) {
            addAttributesIfNotNull(result, containedAttributes);
        }
    }

    //Combine results
    return Collections.unmodifiableSet(result);
}

The upper part is the code of the overall process, and the problem part is the lower part. Let’s look at these two methods one by one

metadata.getAnnotationAttributes(annotationClassName, false))
metadata.getAnnotationAttributes(containerClassName, false)

Let’s look at the logic of metadata. Getannotationattributes (annotationclassname, false))

I’ve omitted the middle process. Anyway, if you go all the way down, you’ll get to the bottom

//AnnotatedElementUtils.java
//line 903
//element:class com.iceberg.springboot.web.WebApplication
//annotationName:org.springframework.context.annotation.ComponentScan
private static <T> T searchWithGetSemantics(AnnotatedElement element,
                                            Set<Class<?extends Annotation>> annotationTypes, @Nullable String annotationName,
                                            @Nullable Class<?extends Annotation> containerType, Processor<T> processor,
                                            Set<AnnotatedElement> visited, int metaDepth) {
    if (visited.add(element)) {
        try {
            //Get all annotations on the WebApplication class
            // This will fetch @SpringBootApplication and the unannotated @ComponentScan
            List<Annotation> declaredAnnotations = Arrays.asList(AnnotationUtils.getDeclaredAnnotations(element));
            T result = searchWithGetSemanticsInAnnotations(element, declaredAnnotations,
                                                           annotationTypes, annotationName, containerType, processor, visited, metaDepth);
            if (result != null) {
                return result;
            }

            //Omit part of the code
        }
        catch (Throwable ex) {
            AnnotationUtils.handleIntrospectionFailure(element, ex);
        }
    }

    return null;
}

The code at the top of

gets all the annotations on the application startup class, and then calls the searchWithGetSemanticsInAnnotations method to make the actual judgement. Here are three cases

Only @ springbootapplication annotation exists

There is @ springbootapplication and a @ componentscan annotation

There are @ springbootapplication and multiple @ componentscan annotations

Let’s analyze them one by one

(1) Only @ springbootapplication annotation exists

//AnnotatedElementUtils.java
//line 967
private static <T> T searchWithGetSemanticsInAnnotations(@Nullable AnnotatedElement element,
                                                         List<Annotation> annotations, Set<Class<?extends Annotation>> annotationTypes,
                                                         @Nullable String annotationName, @Nullable Class<?extends Annotation> containerType,
                                                         Processor<T> processor, Set<AnnotatedElement> visited, int metaDepth) {
    //The first for loop serves to detect the presence of the @ComponentScan annotation
    //Obviously there is no such annotation in the first case, so the code for the first loop is directly omitted
    
    //Omit part of the code
    
    //The second loop recursively looks for the presence of the @ComponentScan and @ComponentScans annotations in the annotation
    //This is where you find the @ComponentScan in @SpringBootApplication and return it
    //If you want to go deeper into how it works, you can look at the code yourself
    for (Annotation annotation : annotations) {
        Class<?extends Annotation> currentAnnotationType = annotation.annotationType();
        if (!AnnotationUtils.hasPlainJavaAnnotationsOnly(currentAnnotationType)) {
            T result = searchWithGetSemantics(currentAnnotationType, annotationTypes,
                                              annotationName, containerType, processor, visited, metaDepth + 1);
            if (result != null) {
                processor.postProcess(element, annotation, result);
                if (processor.aggregates() && metaDepth == 0) {
                    processor.getAggregatedResults().add(result);
                }
                else {
                    return result;
                }
            }
        }
    }
}

(2) There is @ springbootapplication and a @ componentscan annotation

//AnnotatedElementUtils.java
//line 967
private static <T> T searchWithGetSemanticsInAnnotations(@Nullable AnnotatedElement element,
                                                         List<Annotation> annotations, Set<Class<?extends Annotation>> annotationTypes,
                                                         @Nullable String annotationName, @Nullable Class<?extends Annotation> containerType,
                                                         Processor<T> processor, Set<AnnotatedElement> visited, int metaDepth) {
    for (Annotation annotation : annotations) {
        Class<?extends Annotation> currentAnnotationType = annotation.annotationType();
        if (!AnnotationUtils.isInJavaLangAnnotationPackage(currentAnnotationType)) {
            //Determine if the annotation is a @ComponentScan annotation
            if (annotationTypes.contains(currentAnnotationType) ||
                currentAnnotationType.getName().equals(annotationName) ||
                processor.alwaysProcesses()) {
                T result = processor.process(element, annotation, metaDepth);
                if (result ! = null) {
                    //we don't know what the function of this judgment is
                    //If you know, please tell us.
                    //but the judgment here is false, so the result will be returned directly
                    if (processor.aggregates() && metaDepth == 0) {
                        processor.getAggregatedResults().add(result);
                    }
                    else {
                        return result;
                    }
                }
            }
            
            //Omit part of the code
            
        }
    }
    
    //Omit the second loop
}

You can see that when there is a @ componentscan annotation, it will directly return this annotation, and will not parse the configuration in @ springbootapplication, so testcontroller is not loaded into the spring container

(3) There are @ springbootapplication and multiple @ componentscan annotations

If one @ componentscan annotation can override the corresponding configuration in @ springbootapplication, why can multiple @ componentscan annotations be used again

Haha, let’s first explain that the source code we analyzed before is under the spring core package, so even if you don’t use spring boot, its logic is the same. Then we usually use multiple @ componentscan without any problems

Here we will introduce a new annotation – @ repeatable. Let’s take a look at the code of @ componentscan

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Documented
@Repeatable(ComponentScans.class)
public @interface ComponentScan {
}

You can see that there is a @ repeatable annotation on the top. This is a new annotation added in jdk8. When there are multiple @ componentscan annotations, they will be converted into an array as the value of @ componentscans

So the third case is @ springbootapplication and a @ componentscans annotation. Note that there is s in this case, so the package scan in @ springbootapplication will still take effect

@The parsing logic of componentscans annotation is in the metadata. Getannotationattributes (containerclassname, false) method. The specific logic will not be analyzed. After all, we have found the root of the problem

3、 Summary

Then we summarize the reasons for the three phenomena

(1) Only @ springbootapplication can print the log normally

@Springbootapplication will scan the same package and sub package by default, so testcontroller will be scanned and the log will be printed

(2) There is @ springbootapplication and a @ componentscan annotation, and the log is not printed

@The componentscan annotation will be processed first and then returned so that the configuration in @ springbootapplication does not take effect

(3) There are @ springbootapplication and multiple @ componentscan annotations, and the log is printed normally

Multiple @ componentscan annotations will be integrated into one @ componentscan annotation, which will not affect the correct reading of the configuration in @ springbootapplication

Solution:

Use @ componentscan annotation instead of using @ componentscan annotation directly

This is the most perfect solution, which will not affect the configuration of springboot itself. You can also customize your own configuration at will

@SpringBootApplication
@ComponentScans({
        @ComponentScan("com.iceberg.springboot.biz"),
        @ComponentScan("com.iceberg.springboot.manager")  
})
public class WebApplication {

    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class, args);
    }
}

Steps of MyEclipse / eclipse importing sun.misc.base64encoder jar package

MyEclipse/Eclipse Import sun.misc.BASE64Encoder jar package steps

1. Right-click the project –>Properties –>JavaBulidPath-> Libraries –>JRESystem Library –>Access rules –>Double-click Type Access Rules in Accessible add accessible, fill in the following ** click OK.

2. When writing Java code in MyEclipse, use BASE64Decoder, import sun.misc.

sun.misc.BASE64Encoder and sun.misc.BASE64Encoder can’t find the solution

1. right click the project – “properties – “java bulid path – “jre System Library – “access rules – “resolution select accessible. fill in the following ** click OK on it.!

2.When writing Java code in MyEclipse, BASE64Decoder is used, import sun.misc.BASE64Decoder; but Eclipse prompts.

Access restriction: The type BASE64Decoder is not accessible due to restriction on required library C:\Program

files\java\jre6\lib\rt.jar

Access restriction : The constructor BASE64Decoder() is not accessible due to restriction on required library C:\Program files\java\jre6\lib\rt.jar

 

Solution 1 (recommended).

Simply remove the JRE System Library from the project build path, then add the library JRE System Library, and compile again and everything will be fine.

Solution 2.

Windows -> Preferences -> Java -> Compiler -> Errors/Warnings ->

Deprecated and trstricted API -> Forbidden reference (access rules): -> change to warning

How to Solve stale element reference: element is not attached to the page document

1. Phenomenon

When executing a script, sometimes some element objects will throw the following exception

org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document

2. Cause of error

The official explanation is as follows:

The element has been deleted entirely.
The element is no longer attached to the DOM.

I personally understand that:

That is, the page element is out of date, the referenced element is out of date, and it is no longer attached to the current page, so the element object needs to be relocated

If JavaScript refreshes the web page, it will encounter a stale element reference exception during operation

Official address: http://docs.seleniumhq.org/exceptions/stale_ element_ reference.jsp

Solution:

The constructor of the webdriverwait class accepts a webdriver object and a maximum waiting time (30 seconds). The until method is then invoked, where the apply method in the ExpectedCondition interface is rewritten, so that it returns a WebElement, that is, the finished element, and then clicks. By default, webdriverwait calls expectedcondition every 500 milliseconds until it returns successfully. Of course, if it does not return successfully after exceeding the set value, it will throw an exception and loop for five times to search. The actual experiment shows that although the function tries five times at most, it generally queries three times at most, and there is no error, which is much better than thread waiting

The code is as follows:

/**
     * Wait for the text of the specified element to appear
     *
     * @param xpath
     * @param text
     * @return
     * @throws Exception
     */
    public Boolean isDisplay(final String xpath, final String text) {
        logger.info("Wait for the specified element text to be displayed");
        boolean result = false;
        int attempts = 0;
        while (attempts < 5) {
            try {
                attempts++;
                logger.info("The scan start element starts the first" + attempts + "次");
                result = new WebDriverWait(driver, 30)
                        .until(new ExpectedCondition<Boolean>() {
                            public Boolean apply(WebDriver driver) {
                                return driver.findElement(By.xpath(xpath)).getText().contains(text);
                            }
                        });
                logger.info("End of scan start element");
                return true;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return result;
    }

[Solved] Run-Time Check Failure #2 – Stack around the variable ‘a’ was corrupted

 

The code is as follows.

// EOF example.cpp: Define the entry point of the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>

int main()
{
  char ch;
  FILE *f;
  char a[300];
  printf("enter the file name:");
  scanf("%s", a);
  f = fopen(a,"r");


  if (f == NULL)
  {
    printf("failed to open file. ");
    exit(1);
  }
  while (( ch=getc(f)) != EOF)
  {
    putchar(ch);
  }
  fclose(f);
  getchar();
  return 0;
}

 

Solution: project property page (ALT + F7) – > Configuration properties – > C++ -> Code generation – > Basic runtime check defaults

But it can’t solve the problem, so I set the input. TXT file format to ANSI instead of UTF-8 or Unicode, which is correct

In addition, when using scanf and fopen functions, the solution is as follows

Right click the project name – > Attributes – > C/C++–> Preprocessor – > To define the preprocessor, edit the input box on the right and add:
to it_ CRT_ SECURE_ NO_ WARNINGS

How to Understand >

When you look at Java container classes, you can often see & lt; T extends Comparable<? super T>>, Feel very puzzled

We feel & lt; T extends Comparable< T>> As we know, t is the type that implements the comparable interface, so they can be compared

<? super T> If the table name type parameter needs to be a parent of T or T, then & lt; T extends Comparable<? super T>> What does it mean

The constraint on t is a subclass of comparable, and the constraint on generics in comparable is,?At least it is the parent of T, so it means t is?Subclass of

In a word, elements must be classes or their subclasses that implement the comparable interface. You can use the parent class method to compare subtypes elements

/**
 * Created by wangbin10 on 2018/9/18.
 * The elements in mySort2() list must be classes that implement the Comparable interface or its subclasses
 * Java takes a type-erasing approach to implementing generics and constrains the upper and lower bounds of generics with the extends and super keywords.
 * The extends keyword is used to determine the upper bound of a generic type. <A extends B> indicates class B or its subclasses.
 * The super keyword is used to determine the lower bound of the generic type. <A super B> indicates class B or its parent class, all the way up to Object.? then is a wildcard.
 * Thus, <T extends Comparable<?super T>> indicates the upper bound for classes that implement the Comparable interface, <?super T> then indicates that subclasses of classes that implement the Comparable interface are also possible, thus determining the lower bound
 */
public class Test {
    public static void main(String[] args) {
        List<Animal> animals = new ArrayList<>();
        animals.add(new Animal(25));
        animals.add(new Dog(34));
        mySort1(animals);//ok

        List<Dog> dogs = new ArrayList<>();
        dogs.add(new Dog(18));
        dogs.add(new Dog(19));
        /**
         * This compilation can't pass, because T inferred is Animal, the result is Dog, Dog does not implement Comparable, so it can't
         * mySort1(dogs);
         * */

        mySort2(animals);//ok
        mySort2(dogs);//ok
    }

    /**
     * The type parameter of mySort1 is T extends Comparable<T>, who requires that T must implement Comparable
     * @param list
     * @param <T>
     */
    public static <T extends Comparable<T>> void mySort1(List<T> list) {
        Collections.sort(list);
        System.out.println("mySort1 Success!");
    }

    /**
     * The elements in the list must be classes that implement the Comparable interface or its subclasses
     * @param list
     * @param <T>
     */
    public static <T extends Comparable<?super T>> void mySort2(List<T> list) {
        Collections.sort(list);
        System.out.println("mySort2 Success!");

    }
}

class Animal implements Comparable<Animal> {
    int age;

    public Animal(int age) {
        this.age = age;
    }

    @Override
    public int compareTo(Animal o) {
        return Integer.compare(this.age, o.age);
    }
}

/**
 * Dog simply cannot implement Comparable<Dog>, because that would implement two identical interfaces
 */
class Dog extends Animal {
    public Dog(int age) {
        super(age);
    }
}

Transcoding of system.web.httputility.urlencode in C #

Recently, we need to interface with Java program. The URL transcoding problem we encountered is as follows:

The characters generated by urlencoder.encode used in Java URL encoding are uppercase, and the English ‘(‘, ”) are converted to ‘(‘, ‘) 28’ and ‘(‘) 29 ‘ respectively

However, the characters generated by httputility.urlencode in c#are lowercase and the English brackets are not transcoded , so the characters generated by the two are inconsistent, leading to system errors

The solution is posted below:

1. Character case problem:

//Uppercase conversion of transcoded characters does not convert parameters to uppercase (used)
 public static string GetUpperEncode(string encodeUrl)
        {
            var result = new StringBuilder();
            int index = int.MinValue;
            for (int i = 0; i < encodeUrl.Length; i++)
            {
                string character = encodeUrl[i].ToString();
                if (character == "%")
                    index = i;
                if (i - index == 1 || i - index == 2)
                    character = character.ToUpper();
                result.Append(character);
            }
            return result.ToString();
        }
//Other methods searched on the web, by this method instead of calling HttpUtility.UrlEncode directly
private static string UrlEncode(string temp, Encoding encoding)
    {
      StringBuilder stringBuilder = new StringBuilder();
      for (int i = 0; i < temp.Length; i++)
      {
        string t = temp[i].ToString();
        string k = HttpUtility.UrlEncode(t, encoding);
        if (t == k)
        {
          stringBuilder.Append(t);
        }
        else
        {
          stringBuilder.Append(k.ToUpper());
        }
      }
      return stringBuilder.ToString();
    }

2. English bracket question:

//Solved by replacing the string
encodeurl= encodeurl.Replace("(","%28");
encodeurl=encodeurl.Replace(")", "%29");